ffmpeg: add 3 seconds of black to video head and tail
The basic method to join videos without re-encoding is to use the concat demuxer. This device requires that the files being joined share certain properties, like codec, framerate, video dimensions, timebase..etc

First step is to create the blank segment, which may be used both at the head and tail.

ffmpeg -i fullvideo.mp4 -vf trim=0:3,geq=0:128:128 -af atrim=0:3,volume=0 -video_track_timescale 600 3sec.mp4


Have to do one bookkeeping step for the full video. If not done, the combined video will likely run at the wrong speed.

ffmpeg -i fullvideo.mp4 -c copy -video_track_timescale 600 full600.mp4


Next, create a text file.

file 3sec.mp4
file full600.mp4
file 3sec.mp4


Then run

ffmpeg -f concat -i list.txt -c copy merged.mp4




My first step assumes that the video stream has the most common pixel format yuv420p. Which should be fine as this is the only pixel format supported by web players and smartphone cameras, consumer camcorders..etc. If it's not, the geq filter may fail.

I also assume, tacitly, that the full video does not use more reference frames than produced by preset medium of x264. It's a safe assumption for 95% of videos.

Finally, I assume the full video has AAC-LC as its audio codec. Expected to be true of most phone/cam/web videos.