How to change a video to have one still image and all keyframes & resize it

published Jun 20, 2018 07:55   by admin ( last modified Jun 20, 2018 08:02 )

So I wanted to produce a very small video in size, where the imagery would be meaningless but the sound ok. I needed this for testing https://github.com/jeorgen/align-videos-by-sound that it actually does what it should, that is to correctly analyze how offset in time video files are that are filming the same event. I also wanted all frames to be keyframes, but since it is analyzing sound, that may not have been needed actually.

Make a video only display a static image on every frame (but still have many frames)

ffmpeg -i invideo.mp4 -i still_image.png -filter_complex "[1][0]scale2ref[i][v];[v][i]overlay" -c:a copy out.mp4

Scale the size of the video:

ffmpeg -i invideo.mp4 -filter:v scale=10:-1 -c:a copy out.mp4

The above sets the height proportinally to the width in pixels

Make a video only have keyframes

-force_key_frames 'expr:gte(t,n)'

(I think this works, haven't verified)