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.