I want to concatenate 5 seconds of blank/black video to the end of different videos I download from net. The process I have for doing this is not working.
First I use ffprobe
to the dimensions of the video (let's say it turns out to be 640x480). Then I create my blank video as so:
ffmpeg -f lavfi -i color=color=black -t 5 -s 640x480 blank.mp4
The resultant video, blank.mp4
, plays back as a 5 second blank video as expected.
Then I concatenate the videos as so:
ffmpeg -i random.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts a.ts
ffmpeg -i blank.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts b.ts
ffmpeg -i concat:a.ts|b.ts -c copy -bsf:a aac_adtstoasc final.mp4
Now, it is worth noting: I have cribbed this together with snippets from all over the web / stackoverflow, and am pretty sure it is not right. In fact, I know it is not right because...
The resultant video, final.mp4
, seems almost right. But during playback, once the playhead enters the end of the video into the 5 seconds of black, the video can then no longer seek to earlier in the video successfully. Instead the video remains black (although I can hear the audio).
Suggestions? I am looking for a general solution that will work with various mp4 files I find on the net. Thank you!
helpful, but requires creating a large blank video with a longer duration than the source video... https://stackoverflow.com/a/36786271/62255