Log in

View Full Version : I've Researched this to Death.. MinKey 23 or 24? x264 Blu-Rays


StormMeows
11th July 2021, 04:53
Hi guys,

I have been researching everything to do with encoding so I can ensure I have the most transparent encodes possible. For this value, the minkey.. I have seen it go 50/50. Some will just keep this at the default value "auto" where if you encode a 23.976 Blu-Ray, it will make the value 23 as the min. I have also seen cases where encoders set the min to 24 since Blu-rays are 24 FPS (mostly). So if I am doing a 24FPS encode, should I put the min at 24 or keep the default 23?

Thanks in advance! I really appreciate it! Stay safe out there!

Atak_Snajpera
11th July 2021, 15:11
It doesn't really matter. I just round to even number. Done!

StormMeows
11th July 2021, 18:06
It doesn't really matter. I just round to even number. Done!

Hey, thanks for the reply. This must be why I have seen it about 50% at 23/24 . If it mattered more, I think I would see more people do it 100% of the time. Can you expand on how important this encode setting is for quality? Since it is setting the minimum distance between I-frames, I figured this would be very important. Thank you again!

Atak_Snajpera
11th July 2021, 18:46
Max key frame distance is more important than min. For good compression efficiency use 10s (240)

StormMeows
11th July 2021, 19:19
Max key frame distance is more important than min. For good compression efficiency use 10s (240)

Thank you. So for 1080p blu-ray movies shot in 23.976 FPS, you would say to use 24 min and 240 max? The main thing this helps with is compressibility and doesn't affect the quality of the encode? Thanks

benwaggoner
12th July 2021, 16:59
Thank you. So for 1080p blu-ray movies shot in 23.976 FPS, you would say to use 24 min and 240 max? The main thing this helps with is compressibility and doesn't affect the quality of the encode? Thanks
Are you trying to encode for an actual Blu-ray? In that case, keyint can't be more than 1 second, or 2 seconds if --vbv-maxrate is 15000 or less.

hello_hello
12th July 2021, 17:01
I'm pretty sure the x264 defaults are 250 max and 25 min (aside from encoding for bluray compatibility as benwaggoner mentioned). I never change them.

Keep in mind they're a maximum and minimum. x264 has scene change detection, and by default it puts an I-frame on the first frame of a scene, so the distance between I-frames varies quite a lot. Sometimes a fairly static scene lasts longer than 10 seconds (max keyint of 250 at 25fps), but most of the time there's a scene change before the maximum is reached.

I think the main idea behind a minimum keyint is to prevent the encoder putting a bunch of I-frames close together when there's a lot of difference between successive frames and it looks like scene changes to the encoder. A shot where there's a strobing light... that sort of thing. Most of the time the min keyint isn't a factor. A minimum of one second (min 24 at 24fps) or a min of 0.958 sec (min 23 at 24fps) wouldn't make any difference to the quality.

StormMeows
12th July 2021, 17:58
Are you trying to encode for an actual Blu-ray? In that case, keyint can't be more than 1 second, or 2 seconds if --vbv-maxrate is 15000 or less. Hey, yeah I'm taking my blu-ray backups (main movie) and encoding them to x264 8-bit to save space. I have read that I can either leave the keymin at 23 (default) or change it to 24 (since Blu-rays are mainly 23.976 or 24 FPS). I just didn't know which one was the "right way" to go. Also, the default keyint is 250 so I didn't know if I should change that to 240 instead (10xframerate).

Also, since you mentioned VBV maxrate, I typically set this to --vbv-bufsize 78125 --vbv-maxrate 62500 for blu-rays (DXVA standard) and I use profile 4.1 High. I thought that the bufsize and maxrate are already defined by 4.1 High though so maybe I don't need to manually set this for playback on most devices? Keep in mind that I am not going for blu-ray spec, since these backups will be played on an Nvidia Shield so DXVA standard is more important from what I have seen.

Thanks



I'm pretty sure the x264 defaults are 250 max and 25 min (aside from encoding for bluray compatibility as benwaggoner mentioned). I never change them.

Keep in mind they're a maximum and minimum. x264 has scene change detection, and by default it puts an I-frame on the first frame of a scene, so the distance between I-frames varies quite a lot. Sometimes a fairly static scene lasts longer than 10 seconds (max keyint of 250 at 25fps), but most of the time there's a scene change before the maximum is reached.

I think the main idea behind a minimum keyint is to prevent the encoder putting a bunch of I-frames close together when there's a lot of difference between successive frames and it looks like scene changes to the encoder. A shot where there's a strobing light... that sort of thing. Most of the time the min keyint isn't a factor. A minimum of one second (min 24 at 24fps) or a min of 0.958 sec (min 23 at 24fps) wouldn't make any difference to the quality.

Hey for Blu-rays the minkey is 23 for 23.976FPS movies (at least in Staxrip x264 8-bit). The maximum (keyint) is set to 250. I have seen encoders just set the mininum for 23.976 at 24 (round up) or 240 for the max (10xframerate). That's good that there wouldn't be a difference in quality. Are these settings mainly just for how the file plays back? Should I leave it set to auto (23/250) or manually change to (24/240)?

Thanks guys!

benwaggoner
12th July 2021, 18:24
Hey, yeah I'm taking my blu-ray backups (main movie) and encoding them to x264 8-bit to save space. I have read that I can either leave the keymin at 23 (default) or change it to 24 (since Blu-rays are mainly 23.976 or 24 FPS). I just didn't know which one was the "right way" to go. Also, the default keyint is 250 so I didn't know if I should change that to 240 instead (10xframerate).
A lower keymin may increase encoding efficiency some, by better aligning to natural shot changes. The original BD certainly would have GOPs shorter than 24 frames sometimes. I'd probably pick something like --min-keyint 8.

Also, since you mentioned VBV maxrate, I typically set this to --vbv-bufsize 78125 --vbv-maxrate 62500 for blu-rays (DXVA standard) and I use profile 4.1 High. I thought that the bufsize and maxrate are already defined by 4.1 High though so maybe I don't need to manually set this for playback on most devices? Keep in mind that I am not going for blu-ray spec, since these backups will be played on an Nvidia Shield so DXVA standard is more important from what I have seen.
If you're shrinking bitrates down, those values are way overkill, but probably don't hurt anything as bitrate wouldn't ever hit those levels anyway. It is a good practice to set them by default. Unlike x265, x264 doesn't automatically apply profile @ level constraints.

Hey for Blu-rays the minkey is 23 for 23.976FPS movies (at least in Staxrip x264 8-bit).
For encoding 24p Blu-rays, it's the --keyint that is 24, and --min-keyint would be well below that. I think down to 2 is supported, IIRC.

The maximum (keyint) is set to 250. I have seen encoders just set the mininum for 23.976 at 24 (round up) or 240 for the max (10xframerate). That's good that there wouldn't be a difference in quality. Are these settings mainly just for how the file plays back? Should I leave it set to auto (23/250) or manually change to (24/240)?
The downside to having a high keyint is that worst-case random access gets slower. If you don't mind how long it takes to skip to a particular frame in random access, it doesn't matter. If that does bother you, I'd try --keint 120 to see if that helps enough.

Very long keyint values have diminishing returns. The 240 frame limit would only be hit for a single shot lasting 10 seconds. You won't get any practical difference between 240 and 250.

StormMeows
12th July 2021, 18:27
A lower keymin may increase encoding efficiency some, by better aligning to natural shot changes. The original BD certainly would have GOPs shorter than 24 frames sometimes. I'd probably pick something like --min-keyint 8.


If you're shrinking bitrates down, those values are way overkill, but probably don't hurt anything as bitrate wouldn't ever hit those levels anyway. It is a good practice to set them by default. Unlike x265, x264 doesn't automatically apply profile @ level constraints.


For encoding 24p Blu-rays, it's the --keyint that is 24, and --min-keyint would be well below that. I think down to 2 is supported, IIRC.


The downside to having a high keyint is that worst-case random access gets slower. If you don't mind how long it takes to skip to a particular frame in random access, it doesn't matter. If that does bother you, I'd try --keint 120 to see if that helps enough.

Very long keyint values have diminishing returns. The 240 frame limit would only be hit for a single shot lasting 10 seconds. You won't get any practical difference between 240 and 250.

Thank you for the detailed information! I will stick to the default values. I was more concerned with these having an effect on the overall quality. I tested files with the standard settings in Staxrip and they seeked fine :). I really appreciate you putting this bed to rest!

hello_hello
13th July 2021, 16:46
Hey for Blu-rays the minkey is 23 for 23.976FPS movies (at least in Staxrip x264 8-bit). The maximum (keyint) is set to 250. I have seen encoders just set the mininum for 23.976 at 24 (round up) or 240 for the max (10xframerate). That's good that there wouldn't be a difference in quality. Are these settings mainly just for how the file plays back? Should I leave it set to auto (23/250) or manually change to (24/240)?Thanks guys!

It really doesn't matter. It sounds like StaxRip is adjusting the min keyint according to the frame rate (the wiki says the defaults are 250 and 25), but it's not something to fuss about.
http://www.chaneru.com/Roku/HLS/X264_Settings.htm#keyint

Encoding using a slower speed preset can make a difference (I mostly use Slow or Slower myself), and as a rule the film tuning retains a little more detail than the default of no tuning, but it'll generally increase the bitrate for a given CRF value as a result.
http://www.chaneru.com/Roku/HLS/X264_Settings.htm#tune

StormMeows
13th July 2021, 17:25
It really doesn't matter. It sounds like StaxRip is adjusting the min keyint according to the frame rate (the wiki says the defaults are 250 and 25), but it's not something to fuss about.
http://www.chaneru.com/Roku/HLS/X264_Settings.htm#keyint

Encoding using a slower speed preset can make a difference (I mostly use Slow or Slower myself), and as a rule the film tuning retains a little more detail than the default of no tuning, but it'll generally increase the bitrate for a given CRF value as a result.
http://www.chaneru.com/Roku/HLS/X264_Settings.htm#tune

Thank you for the solid information on the keyint. That's correct, Staxrip adjusts the min value and rounds the framerate down to 23. I was just making sure I didn't have to manually change it to 24 for the min and 240 for the keyint (10x framerate). It sounds like the defaults are great.

For the speed presets, I tend to prefer placebo BUT I change the motion vector search to me-umh instead of tesa. Sure I could manually count how many b-frames I need for each movie but having it set to bframes 16 will help with efficiency and won't hurt in the end so I leave it. I also tend to prefer -3:-3 deblocking for most content (except animation).

The biggest problem I am still facing is trying to find differences in my test encodes for qcomp, aq strength, and psy-Rd. I usually change these depending on the movie. I have read all about them but it still hard to see major differences a lot of the time on my test encodes. I will also usually do a lot of sample encodes to see which CRF value yields the closest to transparency for each movie. Any tips appreciated if you do something similar. :) thanks

hello_hello
13th July 2021, 19:58
More often than not I aim for not-transparent, and that's all very subjective, but I waste time on scripts and encode almost everything with the film tuning and CRF18.

This sort of thing (https://files.videohelp.com/u/210984/Screenshots.zip) (a couple of screenshots from a recent effort). In this case denoising the source and downscaling 576p for encoding.
I know some people like film grain, bit I'm not one of them, and it tends not to encode well.

StormMeows
13th July 2021, 21:10
More often than not I aim for not-transparent, and that's all very subjective, but I waste time on scripts and encode almost everything with the film tuning and CRF18.

This sort of thing (https://files.videohelp.com/u/210984/Screenshots.zip) (a couple of screenshots from a recent effort). In this case denoising the source and downscaling 576p for encoding.
I know some people like film grain, bit I'm not one of them, and it tends not to encode well.

I completely understand. I hope I can find someone who encodes similar to my style (aiming for transparency to the source). I appreciate you helping though!

Emulgator
13th July 2021, 22:44
You may want to use zopti.

StormMeows
14th July 2021, 00:51
You may want to use zopti.

Thanks for the recommendation. I'll definitely check it out!