Log in

View Full Version : Bluray --keyint-min question


iSeries
11th February 2012, 16:52
Hi,

Just trying to understand the command line better - I notice that BD Rebuilder and BDtoAVCHD (and probably others) both set --min-keyint 1, overriding the x264 default which obviously would be --min-keyint 2 for --keyint 24. Is there a good reason for explicitly overriding the default and setting to 1?

Thanks!

LoRd_MuldeR
11th February 2012, 16:57
The BluRay standard enforces a key-frame interval that is equal to the frame-rate. So for 24 fps content, a key-frame needs to be enforced every 24 frames. Thus "--keyint 24".

With such extremely small maximum key-frame distance (normally one would use something like 10 * FPS), it probably doesn't make much sense to enforce a minimum key-frame distance of 2.

Though I am pretty sure that you don't need "--min-keyint 1" to create BluRay compliant encodes. It's probably an arbitrary choice of the BD Rebuilder and BDtoAVCHD team.

(BTW: x264's default minimum key-frame distance, if "--min-keyint" isn't set, is the value of "--keyint" divided by 10. So normally, if we don't encode for BluRay, it would be equal to FPS).

iSeries
11th February 2012, 17:11
Hi LoRd_MuldeR,

The reason I asked is because on www.x264bluray.com no mention is made of the need to explicitly set --min-keyint, and going by your use of the word 'arbitrary', there is no technical reason to override the default?

I guess what I could also ask is....what do you use? :)

LoRd_MuldeR
11th February 2012, 17:40
No, there should be no technical reason.

poisondeathray
11th February 2012, 17:41
Did you look here ?



commit 236763e39d8a756db0e8179745396ed88c1bfc2d r2149
Author: Jason Garrett-Glaser <jason@x264.com>
Date: Sat Jan 21 12:54:40 2012 -0800

Force keyint-min 1 with Blu-ray
Fixes an issue with referencing across I-frames that's prohibited in Blu-ray for some godforsaken reason.

iSeries
11th February 2012, 17:47
poisondeathray - no i did not see that! And I just checked an encode I did the other night and yes it does now default to 1. Hmm so all my previous encodes using the default, of which there have been many, may not be 'compliant' after all??

LoRd_MuldeR
11th February 2012, 17:53
Did you look here ?

Interesting :confused:

Though I don't quite understand the reason. With "--min-keyint 2" the encoder must not put two Key-Frames in sequence.

With "--min-keyint 1" this restriction is weakened, i.e. the encoder may now put two Key-Frames in sequence. But of course it doesn't have to.

[EDIT]

Okay, I think I understand now.

If x264 encounters a scene change before "--min-keyint" frames have passed (since the last key-frame), it will put an I-Frame rather than an IDR-Frame.

Forcing "--min-keyint" to "1" ensures that this can never happen. So x264 will always put and IDR-Frame. Seems like BluRay doesn't like Non-IDR I-Frames for whatever reason.

BTW: By looking at the commit log, it seems that "--min-keyint 1" is forced when "--bluray-compat" is set. So if you used that, you are safe.

iSeries
11th February 2012, 18:01
Safe now when using --bluray-compat, but not with x264 versions prior to the change! Bah.

LoRd_MuldeR
11th February 2012, 18:03
Safe now when using --bluray-compat, but not with x264 versions prior to the change! Bah.

Though it doesn't mean that the situation, that is now prevented by "--min-keyint 1", actually occurred in any of your encodes.

You just can't be sure it didn't happen... :rolleyes:

iSeries
11th February 2012, 18:07
Well, none have failed to play. That can only be a good sign, right? :)

What would happen if it DID happen in an encode?

poisondeathray
11th February 2012, 18:09
"playing" and strict compliance for authoring are 2 different things

many players can play non compliant streams

LoRd_MuldeR
11th February 2012, 18:10
Well, none have failed to play. That can only be a good sign, right? :)

I don't know. Maybe the "workaround" on x264's side is not because the BluRay specs officially requires it, but because some "buggy" players fail on it.

In that case playback may still work fine on your player, but fail on others. Depends on whether you care about that. A professional studio certainly would care ;)

What would happen if it DID happen in an encode?

Maybe nothing. Maybe you'd get corrupted output (for a short moment).

iSeries
11th February 2012, 18:16
I'd say most players are actually a lot more relaxed than the actual blu ray 'spec'. Thankfully! I have 2 players, one Sony and one LG. Both have played all my encodes without issue.

Naturally my only concern is that they play for me. I just hope that in the future I don't end up buying a player that wont play them! Although, the player wouldn't know in advance so I would just assume that if it did happen it would just be a split second playback glitch?

As these are backups of my original discs I could just re-do the entire lot. But...that's a whole lot of time...and I'm almost crying at the thought of it lol

laserfan
11th February 2012, 20:34
As these are backups of my original discs I could just re-do the entire lot.
If you've not seen any problems by now, new player or not you are unlikely to see any in the future. Unless of course any of them have Cinavia. ;)

Lorax2161
11th February 2012, 20:53
To follow up on poisondeathray's reference to the commit, this was in the x264 Development Newsletter: Vol 27:

Blu-ray compliance fix: Bluray doesn't allow referencing across I-frames, that is, it treats I-frames like IDR -- so just don't force --keyint-min 1.

I doubt this caused any issues with real playback hardware, but the spec mandates it for some insane reason. Thanks to Pegasys for the bug report.

benwaggoner
11th February 2012, 22:18
The BluRay standard enforces a key-frame interval that is equal to the frame-rate. So for 24 fps content, a key-frame needs to be enforced every 24 frames. Thus "--keyint 24".
...except if you're using Level 4.0 with a peak of 15000 Kbps or less, in which case you can have --keyint be every two seconds.

Which can provide a nice quality boost for low bitrate BD-compatible encodings, like trying to put a 1080p movie on a DVD-9. I've been getting surprisingly fine resuts with x264 with an ABR of 6-8 Mbps.

Dark Shikari
12th February 2012, 00:17
It was another obscure rule in the Blu-ray spec that likely didn't affect any players (hence why nobody noticed it...).

Not even the Blu-ray verifiers complained.

Wizecat
16th February 2012, 03:59
"playing" and strict compliance for authoring are 2 different things

many players can play non compliant streams

All of my 1280x720 encodes using min 24 max 240 have played on my panasonic BD60 so far without issues besides the seeking delay. But the other options have to be limited. Like max b frames = 3, b pyramid = strict, ref frames to 4 or 5, etc.

benwaggoner
21st February 2012, 19:39
I suspect that this is one of those spec things that isn't really required in practice, but there's no downside in sticking to the spec (not being able to have two IDRs in a row isn't going to hurt compressed quality!), so might as well just do the nominally right thing.

iSeries
21st February 2012, 21:28
I agree, the written spec is one thing, what players will play is another. They seem to be much more relaxed than the specs (although I understand a few manufacturers are stricter than others). Eg I recently did a couple of tests and found that 1080p25 and 480p24 (both not 'compliant') both played perfectly in my 2 LG players (different generations) and my Sony player.

However sticking to the spec is essential for me, my current players might play them, but future players might be far stricter and render my backups useless, who knows! So I've decided to re-do all my backups. A time consuming process for sure, but greater peace of mind for me knowing my precious blu rays are all safely, and compliantly, backed up!