I am trying to lengthen the first frame of a video, and encode it to Ogg Theora using ffmpeg and ffmpeg2theora. Here is the script I have that currently works, most of the time:

//Extract first frame, make short video clip
ffmpeg.exe -i video.mov -c:v copy -c:a pcm_s16le firstFrame.png    
ffmpeg.exe -f lavfi -i aevalsrc=0 -loop 1 -i firstFrame.png -c:v libx264 -preset veryslow -pix_fmt yuv420p -t 00:00:00.500 -c:a pcm_s16le halfSecondFreeze.mov    

//For concatenation to work, I need the same audio format in both videos
//or else ffmpeg2theora will fail
ffmpeg.exe -i video.mov -c:v copy -c:a pcm_s16le fixedAudioVideo.mov    
ffmpeg.exe -i halfSecondFreeze,mov -i fixedAudioVideo.mov -filter_complex \"[0:0] [0:1] [1:0] [1:1] concat=n=2:v=1:a=1:unsafe=1 [v] [a]\" -map \"[v]\" -map \"[a]\" -c:v libx264 -preset veryslow -c:a pcm_s16le frameLengthenedVideo.mov

//Encode to theora in ogv container    
ffmpeg2theora.exe frameLengthenedVideo.mov -c 1 -x 800 -y 600 -o finalVid.ogv

The problem is that sometimes, this cuts off the last bit of some videos. I have found that if I use qtrle as my codec when I create the short clip, and when I concatenate the two videos that the final video cuts off early. Instead, it yields a very choppy video instead.

I am using ffmpeg2theora to convert to ogv, because it seems to be the only tool that produces video that my playback application (Unity3d) likes. Using ffmpeg directly results in odd playback issues, like completely black video.

I'm looking for any suggestions on how I could avoid the cut-off issue, or improve this process. If you want any details about one of the videos that is failing, I can paste the relevant output from MediaInfo here.


Consider copying the audio into its own input with the same container as the original input file.

Possible solution. Copy audio to separate file. Create your png. Mux them together. Then concat that with the original.

ffmpeg -i *.mov -c copy -map 0:a audio.mov
ffmpeg -i video.mov -c:v copy -frames:v 1 firstFrame.png 
ffmpeg -loop 1 -i firstFrame.png -i audio.mov -t 0.5 -map 0:v:0 -c:a copy -map 1:a:0 png.mov

For the concat I would use this answer from Stack Overflow.

I left some things out but the basic idea is there. You can skip moving the audio to a separate file but I wanted to emphasize that step. Try to avoid trans-coding unless you have to, copy is your friend.

  • I like this, thanks for taking the time to help! If I am not mistaken this it taking the first .5 seconds of the audio from the original video and using that for the audio in the shortened clip? That's a clever way to get around the audio format issue! – Corey Larson Jun 16 '14 at 14:51
  • Part of my challenge is that the source videos (all 1000+ of them) are not all in the same format, either. Is there a good way to handle that and still use the concat demuxer? – Corey Larson Jun 16 '14 at 16:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.