I'm trying encode a video stream using HEVC with ffmpeg and create a MPEG-TS file. I need to be able to insert IDR frames to certain locations in the stream. I came across the flag -force_key_frames under ffmpeg documentation, but it doesn't seem to work for me.

Here is the command I tried:

ffmpeg -s:v 1280x720 -i input.yuv -c:v libx265 -x265-params crf=20:keyint=25:fps=25:preset=ultrafast -force_key_frames 1,12,30,111 -f mpegts out.ts

Please help me to sort out this issue.


1 Answer 1


ffmpeg's libx265 wrapper is very minimal, and doesn't pass on very many settings. e.g. -pass 1 requires manually setting -x265-params pass=1.

Also, if x265 is anything like x264, don't use ultrafast except for lossless or for testing things.

sorry for not taking the time to dig this up myself, but have a look and see if you can get your desired I frame locations into x265-params. Probably not, though.

If you want to hack some C code, have a look at libx264.c and libx265.c, and maybe you can see how to ffmpeg sends frame-type requests to x264. And maybe you can port that to the libx265 wrapper.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.