X265 + BOB deinterlace = High bit rate (2 years old bug)

HandBrake for Windows support
Forum rules
An Activity Log is required for support requests. Please read How-to get an activity log? for details on how and why this should be provided.
Post Reply
selen
Posts: 11
Joined: Fri Nov 22, 2019 8:32 pm

X265 + BOB deinterlace = High bit rate (2 years old bug)

Post by selen »

Description of problem or question:

Hi!
This bug exists for 2 years since HandBrake 1.3.0 with x265 v.3x. I decided to create a new Topic instead of old one. :)

With all versions of HB since 1.3.0 BOB deinterlace filter gives much higher bit rate than it should be.
Here are the numbers:
Old good HB 1.2.2:
HB 1.2.2 + Yadif (25fps) = 2406.34 kbps
HB 1.2.2 + Yadif BOB (50fps) = 2715.37 kbps (+13%) - this is normal value

Latest HB 1.4.2 (and all versions since 1.3.0):
HB 1.4.2 + Yadif (25fps) = 2343.00 kbps (a bit lower than 1.2.2 due to better compression, all settings are same)
HB 1.4.2 + Yadif BOB (50fps) = 3847.11 kbps (+64%) - anomaly gain and too high bit rate

64% vs 13% is the big difference! And if you look at the end of the logs, there are doubling bit rate at the mux stage for new HB.

Steps to reproduce the problem:

Load interlaced sample. Use the same settings for old and new HandBrake. Encode with Yadif default and Yadif BOB deinterlace, interlace detection Off.

HandBrake version:

1.4.2 and 1.2.2

Operating system and version:

Windows 10

HandBrake Activity Log

Archive with 4 logs:

Code: Select all

https://www.solidfiles.com/v/RxkW72mNNVz5K
Deleted User 11865

Re: X265 + BOB deinterlace = High bit rate (2 years old bug)

Post by Deleted User 11865 »

If your source is 25 fps constant, and you're doing yadif bob without interlace detection, you can use Constant Frame Rate and set it to 50 fps in HandBrake.

Alternatively, you can tell x265 the output framerate by adding ":fps=50" (without quotes) to the advanced options text box.

If your source is variable frame rate to begin with, or if you're doing a variable frame rate encode (e.g. bob deinterlace with interlace detection), there is no easy solution.

I'm kind of surprised it worked with an older HB/x265 combo; as far as I know, x265's rate control has never been able to account for each individual frame's duration (unlike x264)-- my guess is, the fact that you didn't get large bitrate variations was probably somewhat coincidental.
selen
Posts: 11
Joined: Fri Nov 22, 2019 8:32 pm

Re: X265 + BOB deinterlace = High bit rate (2 years old bug)

Post by selen »

Rodeo wrote: Tue Oct 19, 2021 5:39 pm If your source is 25 fps constant, and you're doing yadif bob without interlace detection, you can use Constant Frame Rate and set it to 50 fps in HandBrake.
Hi Rodeo! I don't have problem with Frame Rate, I got correct and expected FPS in all cases, 25fps with just Yadif and real 50fps with Yadif Bob without dubbing frames.

This is my interlaced test sample (30 sec): https://www.solidfiles.com/v/a4XD2mqX7aYkZ

The problem is an abnormally high bit rate with HEVC + Yadif Bob since HB 1.3.0. I don't use x264 but just did a quick test and results are fine for both old and new HB, I got almost same bit rate gain 21% and 22% with BOB (logs below).

So, the problem is only with x265. I don't know if it's a bug with x265 library since v.3.0 or something wrongly changed at deinterlace filter code or it's a stream muxing problem... :?

I encode sometimes different interlaced sources and situation is the same, I forced to use old HB 1.2.2 for such cases if I want to do a compact file with high FPS.

Results for x264 test:
HB 1.2.2 x264:
HB 1.2.2 + Yadif (25fps) = 2769.02 kbps
HB 1.2.2 + Yadif BOB (50fps) = 3353.55 kbps (+21%)

HB 1.4.2 x264:
HB 1.4.2 + Yadif (25fps) = 2769.02 kbps
HB 1.4.2 + Yadif BOB (50fps) = 3390.77 kbps (+22%)

Archive with 4 x264 log files: https://www.solidfiles.com/v/RxkRQYn8jz5X3
Deleted User 11865

Re: X265 + BOB deinterlace = High bit rate (2 years old bug)

Post by Deleted User 11865 »

x265 does not have VFR-aware rate control. So if you don't set the framerate manually, it thinks your input is 25 fps.
selen
Posts: 11
Joined: Fri Nov 22, 2019 8:32 pm

Re: X265 + BOB deinterlace = High bit rate (2 years old bug)

Post by selen »

Source is 25 fps constant. I tried Interlace Detection - doesn't help. Then I set Constant Frame Rate = 50 fps and this do the trick! :D

HB 1.4.2 + Yadif BOB (Constant 50fps) = 2603.08 kbps (+11 % versus 25 fps), this is perfect!

But now, why is that? If source is constant fps, why VFR matter? Why old HB 1.2.2 worked fine without forcing constant frame rate? What changed in HB 1.3.0?

Speaking about x265, the only interlace related change was in v.3.1, 18th June, 2019:
x265 can now accept interlaced inputs directly (no need to separate fields), and sends it to the encoder with proper fps and frame-size through --field.
Could this be source of new behavior? Or maybe filter code changed and now I have conflicted logic - FR Same as source (and source is 25 fps) and Bob sends 50 fps at the same time to the muxing?

Anyway, thanks for the tip! :)
Post Reply