0
I want to re-encode a video using H264, and I want to control the number of i-frames contained in the re-encoded video. I've tried the following.
ffmpeg -i video.mp4 -y -c:v libx264 -crf 21 -sc_threshold 40 -c:a copy reencoded_video.mp4
This successfully re-encodes the video, but I can't affect the number of i-frames by adjusting the -crf
and -sc_threshold
values, as I have checked with ffprobe
. Most of the time, the same set of i-frames are obtained regardless of the -crf
and -sc_threshold
values I set.
How do I control (to some extent) the number of i-frames in the re-encoded video? For example, how do I make every frame and i-frame? How do I re-encode it so that there is about 1 i-frame every 2 seconds?
EDIT
It seems that I just wasn't trying a big enough range for -sc_threshold
; setting it to 9999 solved the problem. I still can't find the documentation for a valid range of -sc_threshold
though, could anyone point me to an official documentation that describes its valid range?
Some useful options may be found in this question: https://superuser.com/questions/908280/what-is-the-correct-way-to-fix-keyframes-in-ffmpeg-for-dash
– None – 2018-03-12T13:11:12.347If for whatever reason you require I-frame only encoding, use the
– slhck – 2018-03-13T12:07:13.023-intra
option for x264. The real question though, I guess, is: what actual problem are you trying to solve? Your question seems like an xy-problem.