Newest 'ffmpeg' Questions - Stack Overflow

http://stackoverflow.com/questions/tagged/ffmpeg

Les articles publiés sur le site

  • ffmpeg images to video with different start times and durations

    25 mai 2018, par Rich

    I've recently learned of FFMPEG's existence and I am trying to use it on my wordpress site.

    On the site I am working on a html/php/js form page that lets users upload pictures, and set when the image shows and for how long.

    Right now the code I have is only showing one image for the entire video.

    <?php if (isset($_POST['button'])) { 
    echo shell_exec('ffmpeg -t '.$cap_1.' -i /myurl/beach-1866431.jpg -t '.$cap_2.' -i /myurl/orlando-1104481-1.jpg -filter_complex "scale=1280:-2" -i /myurl/audio.mp3 -c:v libx264 -pix_fmt yuv420p -t 30 -y /myurl/'.$v_title.'.mp4 2>&1');
     } ?>
    

    I tried setting "-t" for the duration with my php variables but nothing changes and I cant figure out what to use for the start time of each image.

    Also, when writing shell_exec commands, instead of it all being on one line, is there a way to write working command code in php files with line breaks? For example -

     <?php if (isset($_POST['button'])) { 
        echo shell_exec('ffmpeg -t '.$cap_1.' -i /myurl/beach-1866431.jpg 
        -t '.$cap_2.' -i /myurl/orlando-1104481-1.jpg 
        -filter_complex "scale=1280:-2" 
        -i /myurl/audio.mp3 
        -c:v libx264 -pix_fmt yuv420p -t 30 -y /myurl/'.$v_title.'.mp4 2>&1');
             } ?>
    

    EDIT

    So far the concat text file seems to work, however I do not know how to set the start times for each image ---

    ffconcat version 1.0
    file /path/beach-1866431.jpg
    duration 3
    file /path/orlando-1104481-1.jpg
    duration 5
    file /path/beach-1866431.jpg
    

    And ffmpeg command -

    shell_exec('ffmpeg -f concat -safe 0 -i /path/file.txt -filter_complex "scale=1280:-2" -i /path/audio.mp3 -c:v libx264 -pix_fmt yuv420p -t 30 -y /path/'.$v_title.'.mp4 2>&1');
    

    EDIT 2

    Using the concat method suggested, my code now looks like this --

    <?php if (isset($_POST['button'])) { 
    echo shell_exec('ffmpeg \
    -loop 1 -framerate 24 -t 10 -i goldmetal.jpg \
    -i 3251.mp3 \
    -loop 1 -framerate 24 -t 10 -i cash-register-1885558.jpg \
    -loop 1 -framerate 24 -t 10 -i ice-1915849.jpg \
    -filter_complex "[0:v][1:a][2:v][3:v]concat=n=4:v=1:a=1[v][a]" -map "[v]" -map "[a]" -c:v libx264 /path/'.$v_title.'.mp4 2>&1');
     } ?>
    

    But I'm getting this error --

    **Stream specifier ':v' in filtergraph description [0:v][1:a][2:v][3:v]concat=n=4:v=1:a=1[v][a] matches no streams.**
    

    EDIT 3

    I almost got it working as needed, using 2 commands, one for the images and fade, the other to combine the audio. The only issue I'm having is changing the time each image shows up. --

    echo shell_exec('ffmpeg \
    -loop 1 -t 5 -i '.$thepath .'/'.$v_pix1.' \
    -loop 1 -t 5 -i ' .$thepath . '/cash-register-1885558.jpg \
    -loop 1 -t 5 -i ' .$thepath . '/ice-1915849.jpg \
    -loop 1 -t 5 -i '.$thepath .'/'.$v_pix1.' \
    -loop 1 -t 5 -i ' .$thepath . '/ice-1915849.jpg \
    -filter_complex \
    "[0:v]setpts=PTS-STARTPTS,fade=t=out:st=4:d=1,scale=1280:720,setdar=16/9,setsar=sar=300/300[v0]; \
     [1:v]setpts=PTS-STARTPTS,fade=t=in:st=0:d=1,fade=t=out:st=4:d=1,scale=1280:720,setdar=16/9,setsar=sar=300/300[v1]; \
     [2:v]setpts=PTS-STARTPTS,fade=t=in:st=0:d=1,fade=t=out:st=4:d=1,scale=1280:720,setdar=16/9,setsar=sar=300/300[v2]; \
     [3:v]setpts=PTS-STARTPTS,fade=t=in:st=0:d=1,fade=t=out:st=4:d=1,scale=1280:720,setdar=16/9,setsar=sar=300/300[v3]; \
     [4:v]setpts=PTS-STARTPTS,fade=t=in:st=0:d=1,fade=t=out:st=4:d=1,scale=1280:720,setdar=16/9,setsar=sar=300/300[v4]; \
     [v0][v1][v2][v3][v4]concat=n=5:v=1:a=0,format=yuv420p[v]" -map "[v]" -y '.$thepath .'/fadeout.mp4 2>&1');
    
    
    echo shell_exec('ffmpeg \
    -i '.$thepath .'/fadeout.mp4 \
    -i '.$thepath .'/3251.mp3 \
    -filter_complex "[0:v:0][1:a:0] concat=n=1:v=1:a=1 [vout] [aout]" -map "[vout]" -map "[aout]" -c:v libx264 -r 1 -y '.$thepath .'/mergetest.mp4 2>&1');
    
  • Import ffmpeg into Qt [on hold]

    24 mai 2018, par Infinite

    Could anyone tell me please that how to import DLLs into Qt? Currently, I would like to import the libraries of ffmpeg into Qt. I saw many videos and pages about importing a dll into Qt, but for this process, you also need a header file to the binary. Well, my question is that could anyone send me please a header for that and tell me how to exactly integrate that framework in my software?

  • I need a to keep a PHP process running in background even If I redirect to another URL

    24 mai 2018, par Emmanuel Fernandez

    I have a PHP App that execute FFMPEG commands to encode videos and then upload encoded video to YouTube using Youtube v3 API.

    I'm using shell_exec to perform FFMPEG actions and works very well.The problem it's that I use an AJAX call to start the whole process and I need to keep the user in the the page where I execute the AJAX call, my intention is execute the AJAX call to start the whole process and inmediatly redirect the user to another page, The problem is that when I redirect to another page the PHP process is interrumped, there are any form to execute AJAX call, redirect and keep the PHP process running in background?

  • Batch script to match two filenames in the same folder with different extension

    24 mai 2018, par Ahhhhhhhhhhhhhdfgbv

    I've been looking, but I don't quite understand the regex of matching filenames. I have seen in SO that there are questions that match two filenames in different folders, but I'm looking within the same folder.

    file01.jpg
    file01.wav
    file02.jpg
    file03.jpg
    file04.jpg
    file04.wav
    

    I want it to match if there is a jpg and a wav to run a ffmpeg script, and if the wav doesn't have a matching jpg then run another ffmpeg script, and if there is no matching wav to the jpg do another script.

    if( $jpg == $wav ) // matching filenames without extension
        do script1
    else if( $jpg != $wav ) // if there is no matching jpg to wav
        if( empty($jpg) && $wav )
            do script2
        if( empty($wav) && $jpg )
            do script3
    
  • How to convert DVD chapters to files using ffmpeg, handbrake or other linux tool ?

    24 mai 2018, par Valya

    Handbrake can convert DVD to mkv and put chapter markers, but I could not get it to put chapters in separate files. How can I do so?