[FFmpeg-user] -force_key_frames limits?

Maxim Levkov maxim.levkov at gmail.com
Wed Oct 10 11:15:18 CEST 2012


Hello FFMPEG users,

I've recently ran into a problem that has to do with possible limit of
how many "key" frame positions can be assigned to enforce by FFMPEG.

My attempt 1 command line looks like this:
-----------
b:\ffmpeg.exe -i "F:\tempoutput\Main.avi" -threads 0 ^
-force_key_frames
00:00:29.946,00:00:44.961,00:01:17.368,00:01:32.383,00:02:06.793,00:02:21.808,00:03:04.934,00:03:19.949,00:03:40.136,00:04:10.166,00:04:41.656,00:05:11.686,00:06:06.532,00:06:36.562,00:07:28.990,00:07:59.020,00:08:26.547,00:09:11.592,00:10:03.519,00:10:48.564,00:11:10.961,00:11:56.006,00:12:21.574,00:13:06.619,00:13:35.689,00:14:35.749,00:15:13.037,00:16:13.097,00:16:41.375,00:17:41.435,00:18:14.760,00:19:14.820,00:19:44.766,00:21:14.856,00:21:47.264,00:23:17.354,00:23:51.763,00:25:21.853,00:26:04.980,00:27:35.070,00:27:55.256,00:29:55.376,00:30:26.866,00:32:26.986,00:33:21.833,00:38:22.800,00:36:14.380,00:38:14.500
^ -c:v libx264 -sws_flags lanczos -cmp rd ^
-x264opts bitrate=1500:vbv_maxrate=1750:vbv_bufsize=1900:nal_hrd=vbr:rc_lookahead=40:interlaced=0:scenecut=0:cabac=1:keyint=96:level=3.2:deblock=1,0,0:qpmin=16:qpmax=51:qpstep=10:ref=2:mixed-refs=1:subme=9:me=esa:chroma_me=0:merange=64:8x8dct=0:fast_pskip=0:chroma_qp_offset=0:trellis=2:psy=0:bframes=0:weightp=2:slices=0:sliced_threads=0:ipratio=1.40:qcomp=0.60:partitions=p8x8,b8x8,i8x8,i4x4:direct=auto:mbtree=0:colorprim=bt709:transfer=bt709:colormatrix=bt709
-s 768x432 ^
-vf setsar=1:1,setdar=16:9 -c:a libvo_aacenc -ab 128000 -ar 44100 -ac
2 -r 23.976 -pix_fmt yuv420p -f mp4 -y
"b:\forced_i_frames_1500_768x432_1900_4secGOP.mp4"
--------------------

Note that positions 00:36:14.380 and 00:38:14.500 are not enforced,
they remain to be a P-slice instead of an I-IDR. The transcoding goes
through fine and no errors are displayed. I have made a modification
to the above and reduced the amount of key_frame enforcements to just
these two (00:36:14.380 and 00:38:14.500).

Here is the command line for attempt 2:
-------------
b:\ffmpeg.exe -i "F:\tempoutput\Main.avi" -threads 0 -force_key_frames
00:36:14.380,00:38:14.500 -c:v libx264 -sws_flags lanczos -cmp rd ^
-x264opts bitrate=1500:vbv_maxrate=1750:vbv_bufsize=1900:nal_hrd=vbr:rc_lookahead=40:interlaced=0:scenecut=0:cabac=1:keyint=96:level=3.2:deblock=1,0,0:qpmin=16:qpmax=51:qpstep=10:ref=2:mixed-refs=1:subme=9:me=esa:chroma_me=0:merange=64:8x8dct=0:fast_pskip=0:chroma_qp_offset=0:trellis=2:psy=0:bframes=0:weightp=2:slices=0:sliced_threads=0:ipratio=1.40:qcomp=0.60:partitions=p8x8,b8x8,i8x8,i4x4:direct=auto:mbtree=0:colorprim=bt709:transfer=bt709:colormatrix=bt709
-s 768x432 ^
-vf setsar=1:1,setdar=16:9 -c:a libvo_aacenc -ab 128000 -ar 44100 -ac
2 -r 23.976 -pix_fmt yuv420p -f mp4 -y
"b:\forced_i_frames_1500_768x432_1900_4secGOP_reducedkeypositions.mp4"
---------------------

The second attempt did confirm that these two positions (00:36:14.380
and 00:38:14.500) get I-IDR frame assigned to them, as expected.
Result of this run led me to believe that there is either a bug or a
limit to how many key-frames can be enforced via this specific method.

I'm interested to know if there is a limit to the amount of enforced
key positions. Have I reached the limit by doing the process via the
way listed here? I have 48 time positions that I need to make sure the
I-IDR key is placed at. Also, maybe someone knows of another way to
achieve the same task. I've tried to use the file that contains all of
these key-frames, but was not as fortunate.

Thank you,
Max


More information about the ffmpeg-user mailing list