Log in

View Full Version : Advanced IDR frame placement


kolak
9th October 2015, 21:12
Have very specific IDR frame placement requirement for x264.

I want IDR frames to have min distance of 24 frames (and maximum of 99), but I don't want scene change detection to be off. In case there are scene changes happening inside 24 frames period I want 2nd one to be skipped. Is this possible at all with x264/ffmpeg?
Is the only way to let x264 create 1st pass and than analyse it and overwrite "broken" places with I frames?
Can I copy x264 frame decision from 1st pass and than adjust it (change "bad" IDR frames to I) and start new encode with this as qpfile?
Will this be ok? Is there a faster way?

Desbreko
9th October 2015, 22:27
I think --min-keyint 24 --keyint 99 should do that.

kolak
9th October 2015, 23:15
I also thought it will work, but nope.
min-keyint won't help, it gets overruled by scene change detection.

kabelbrand
10th October 2015, 12:58
min-keyint won't help, it gets overruled by scene change detection.
That's weird. Can you post your complete command line? Maybe some other option overrides min-keyint, e.g. bluray-compat.

kolak
10th October 2015, 13:25
Let me try again, as I'm sure x264 was overruling min-keyint with content with very short scene changes.

.....


Sorry, you are correct- it works fine with min-keyint, but it's not end of my problem.
I also need some forced ones and when I do it with ffmepg than min-keyint is not working around this forced IDR places (which is expected I think).

Maybe I never run a test with min-keyint, but without forced frames :)

I have also found new option in ffmpeg: forced-idr=1, which forces forced frames to be for IDR (e.g. not just I). I think I need to do more tests.

kolak
12th October 2015, 21:51
After some tests I end up using scenecut=0. It actually doesn't destroy quality as much as I thought.

Different question. Can I change frame type in x264 1st pass stats from e.g. I frame to P frame and than run 2nd pass encode?
Is it safe or no go?

benwaggoner
13th October 2015, 00:37
After some tests I end up using scenecut=0. It actually doesn't destroy quality as much as I thought.

Different question. Can I change frame type in x264 1st pass stats from e.g. I frame to P frame and than run 2nd pass encode?
Is it safe or no go?
Use qpfile. Just make a file that lists the frame numbers you want to be IDR, followed by "I".

kolak
13th October 2015, 20:10
I know about qpfile, but first I need to know what frames decisions x264 comes up with and based on this I may/may not need to change some frames from I to P, to avoid short GOPs. It's for DASH.
x264 won't respect min-kyint with qpfile.

kabelbrand
13th October 2015, 21:14
FWIW, do yourself a favour and use fixed GOPs for DASH.

kolak
14th October 2015, 21:52
They are fixed, but in few places they can't be as segment break has to happen on frames chosen by the client. I assume their system will be fine with it (they control hardware box which will be the player).