Media (Intel® oneAPI Video Processing Library, Intel Media SDK)
Access community support with transcoding, decoding, and encoding in applications using media tools from Intel. This includes Intel® oneAPI Video Processing Library and Intel® Media SDK.
2927 Discussions

How can i insert key-frame at specific interval through ffmpeg?


i'm working on ffmpeg with qsv (Xeon E3 1285).

i tried to insert key-frame every 5sec with command below.

ffmpeg -t 1800 -i 2hour.mp4 -c:v h264_qsv -s 1280x720 -b:v 2M -maxrate 2M -minrate 2M -bufsize 917k -an -segment_time 5 -sc_threshold 0 -strict -2 -force_key_frames "expr:gte(t,n_forced*5)" -f segment output%03d.h264

it works fine when i use libx264(-c:v libx264) so that i can cut the video into exactly 5 sec.

But with QSV it doesn't work. video segment is 10 sec now.

How can i insert key-frame when i want?

0 Kudos
2 Replies

Only a subset of parameters are implemented in the h264_qsv interface.  You can check yourself in the ffmpeg libavcodec/qsv* source files.

GOP structure and IDR interval are parameters set up at Media SDK initialization.  Much of this is done in qsvenc.c.  Here you can see that IDR interval is set directly with -idr_interval.

You can add your own QSV-specific parameters (as in qsvenc_h264.c) or figure out a way to plug the FFmpeg general parameters into QSV initialization. 

However, I suspect that there is more going on here than simple parameter setting.  The support for segment processing may still need some more work.  That is out of the scope of this forum, but you can take it to the appropriate FFmpeg lists directly.  (




@joonsik : Could you help us, we are facing problem with QSV and FFMPEG installation. Please refer this forum,