Author Topic: Number of x264 reference frames beyond H.264 level setting  (Read 569 times)

madada

  • Newbie
  • *
  • Posts: 4
Number of x264 reference frames beyond H.264 level setting
« on: October 14, 2019, 09:49:03 PM »
Hello,

I've been busy encoding low-resolution footage with good encoding efficiency, and I noticed that some of my output files do not abide the H.264 level I set them to.
I encoded my video with Avidemux using x264 to a frame size (resolution) of 720x540 pixels and set the H.264 level ("IDC Level") to 3.0 and the x264 preset to "slower". This preset uses 8 reference frames but H.264 level 3.0 only allows 5 reference frames at the chosen resolution (see also https://planetcalc.com/3321/).
When encoding the same footage the same way using Handbrake, I noticed that it reduced the number of reference frames correctly despite the preset when selecting level 3.0.
Can this be fixed so that Avidemux behaves like Handbrake does? Or is the less experienced user expected to leave the level setting always at auto? In my case, being able to restrain the level and then know that the encoder will act accordingly, really helps playback on older devices like old iPads (some of which require Main Profile Level 3.0).

Greetings,
M.

eumagga0x2a

  • Moderator
  • Hero Member
  • *****
  • Posts: 3406
Re: Number of x264 reference frames beyond H.264 level setting
« Reply #1 on: October 14, 2019, 11:27:16 PM »
I encoded my video with Avidemux using x264 to a frame size (resolution) of 720x540 pixels and set the H.264 level ("IDC Level") to 3.0 and the x264 preset to "slower". This preset uses 8 reference frames but H.264 level 3.0 only allows 5 reference frames at the chosen resolution (see also https://planetcalc.com/3321/).

Due to decoded picture buffer size constraints?

Quote
When encoding the same footage the same way using Handbrake, I noticed that it reduced the number of reference frames correctly despite the preset when selecting level 3.0.
Can this be fixed so that Avidemux behaves like Handbrake does?

Of course it can as soon as someone actually implements it.

Quote
Or is the less experienced user expected to leave the level setting always at auto? In my case, being able to restrain the level and then know that the encoder will act accordingly, really helps playback on older devices like old iPads (some of which require Main Profile Level 3.0).

Avidemux relies on x264_encoder_open() to perform the necessary checks (which doesn't care).

Rangeles

  • Newbie
  • *
  • Posts: 1
Re: Number of x264 reference frames beyond H.264 level setting
« Reply #2 on: October 16, 2019, 12:02:06 PM »
What are the odds of this being implemented anytime soon?

eumagga0x2a

  • Moderator
  • Hero Member
  • *****
  • Posts: 3406
Re: Number of x264 reference frames beyond H.264 level setting
« Reply #3 on: October 17, 2019, 12:34:14 AM »
No estimate possible. Generally, if you need a feature, the best way to make it happen is writing it yourself. On my part, I'm curious about how Handbrake handles this, might be something well suited to help procrastinate important stuff.

eumagga0x2a

  • Moderator
  • Hero Member
  • *****
  • Posts: 3406
Re: Number of x264 reference frames beyond H.264 level setting
« Reply #4 on: October 18, 2019, 07:54:15 AM »
Should be fixed by [x264] Try to enforce IDC level conformance, code stolen from Handbrake. Please verify with a future nightly.

madada

  • Newbie
  • *
  • Posts: 4
Re: Number of x264 reference frames beyond H.264 level setting
« Reply #5 on: October 18, 2019, 04:41:12 PM »
Wow that's great!
Thanks for the effort. I'll be looking out for the next Nightly to try.

madada

  • Newbie
  • *
  • Posts: 4
Re: Number of x264 reference frames beyond H.264 level setting
« Reply #6 on: October 20, 2019, 07:50:13 PM »
Just tried the latest nightly that was released today (x64, Windows).
It works great now!

Thank you very much for providing this fix so soon!

M.