Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Is there a way to use FFMPEG to decompose a video into individual image files, and then reassemble those image files into a video with the audio from the original video in sync with the new video track?

I believe that one of the key elements may be setting the frame rates properly, but all the combinations I've tried haven't worked.

The combinations I've tried are as follows:

ffmpeg -i "/InputVideoFilePath" "/OutputImageFilePath" 

(This command returns the same number of output image files regardless of whether a frame rate specification is placed on the input file, output file, or both.)

I then pull the audio into a separate file as well by following with this command:

ffmpeg -i "/InputVideoFilePath" "/OutputAudioFilePath"

I then reassemble the images into another video file by typing one of the following:

  1. ffmpeg -i "/OutputImageFilePath" "/OutputVideoFilePath"
  2. ffmpeg -i "/OutputImageFilePath" -r 23.98 "/OutputVideoFilePath"
  3. ffmpeg -r 23.98 -i "/OutputImageFilePath" -r 23.98 "/OutputVideoFilePath"

(23.98 was the original video framerate)

So far, both 1 and 2 create a video that is shorter than the original video, while 3 creates a video that is of the same length. I don't understand how setting the frame rate for the input can make any difference, since the input is simply a series of images (i.e., how can a series of images have a framerate?). The FFmpeg documentation states that setting frame rate on input causes timestamps to be ignored, but how can images have timestamps if they're not a part of a video?

After using method 3, I then overlay the mp3 audio over the newly created video file with the command:

ffmpeg -i "/PathToVideoFile" -i "/PathToAudioFile" "/PathOfFinalVideoOutput"

The final product is only slightly out of sync, but still noticeably so. I can show the FFmpeg output for each of these steps if necessary (it's a lot of output though of course).

share|improve this question
1  
It's possible, but could you explain why you'd need that? Please show what exactly you've tried, including the uncut console output from FFmpeg. –  slhck Mar 10 '13 at 7:17
    
@slhck I've added the information about what I've tried. Also, I need to do this process for purposes of making a greenscreen video program (i.e.- replacing a green background in a video with a certain image). Thank you so much for your help. –  user1419674 Mar 11 '13 at 7:21
    
Timestamps are ignored for video input when you specify -r as an input option. When it's not specified, FFmpeg will assume a default input frame rate of 25 for a sequence of images. I just tested your process and it worked without synchronization issues. This was with a video of 25 FPS, so I didn't need to specify any frame rate here, but setting both 23.98 as an input and output option would be ideal. Maybe you can show us the output of your first command, and the third reassembling command? Don't worry if it's a little long. –  slhck Mar 11 '13 at 7:56
    
@slhck I believe I got it to work. Thank you so much for your help! –  user1419674 Mar 19 '13 at 5:38
    
Nice! Maybe you could answer your own question below so others can benefit from your solution. –  slhck Mar 19 '13 at 6:08
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.