Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > General > Newbies

Reply
 
Thread Tools Search this Thread Display Modes
Old 10th October 2014, 21:43   #1  |  Link
VideoFanatic
Registered User
 
Join Date: Sep 2011
Posts: 241
H.264 Profiles and Levels discussion

Hi, I was wondering how your program chooses the correct Profile when setting it to Auto? Does it always choose the correct profile?

Also is there a way I can choose the exact level such as High 3.2 instead of just setting "High" and then the program chooses which level to set?

Here's the clip I'm converting to 576i

Impact 2014 Sep 24 Source Clip. 544 x 576i MPEG2 clip copied directly from my satellite box
. I'm using a script to resize to 720 x 576i.

There are the settings I use: CRF 17, VeryFast, Tuning None

--tff --sar 64:45 --bluray-compat --slices 1 --vbv-bufsize 15000 --vbv-maxrate 15000 --keyint 250
VideoFanatic is offline   Reply With Quote
Old 10th October 2014, 22:28   #2  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,196
Quote:
Originally Posted by holygamer View Post
Hi, I was wondering how your program chooses the correct Profile when setting it to Auto? Does it always choose the correct profile?
It doesn't! If you select "Auto", then the "--profile" option isn't used at all, which means no specific profile is being enforced, which means x264 will set the proper Profile automatically.


Quote:
Originally Posted by holygamer View Post
Also is there a way I can choose the exact level such as High 3.2 instead of just setting "High" and then the program chooses which level to set?
You seem to have a rather strange understanding of what Profiles and Levels do. And I think we had that discussion before

Profiles
are restrictions of what features of H.264 you are allowed to use. By default, if "--profile" is not used, x264 will pick the Profile that covers all features you are using in your stream (but not a higher one, since that would be pointless). Consequently, you can enforce a lower Profile than what would be used by default, which will simply turn off those features that are not allowed in the enforced Profile. Enforcing a higher Profile than what would be used by default doesn't make any sense though! What feature should x264 turn on to make your file require the higher Profile? Should it pick a random one? Instead, if you want your stream to be "High" Profile, then simply use at least one "High" Profile feature and that's it!

Levels are quite similar to Profiles, in the sense that they also are restrictions. Though Levels restrict other things, such as the maximum resolution, the maximum frame rate, the maximum number of reference frames, and so on. x264 will set the Level that is suitable for your stream (and not a higher one, since that would be pointless). And what Level your stream needs is defined by your input file! You can use "--level" to overwrite the Level. However, if you enforce a Level that is lower than what x264 would have set by default, x264 cannot do much about this, except for showing a warning message that your stream does not actually comply to the Level you have set. And enforcing a Level that is higher than what x264 would have set by default only restricts the compatibility of your stream for zero benefit! To make a long story short: Setting "--profile" can make sense in specific cases, but setting "--level" manually is almost always a bad idea. Simply let x264 do its job...
__________________
There was of course no way of knowing whether you were being watched at any given moment.
How often, or on what system, the Thought Police plugged in on any individual wire was guesswork.



Last edited by LoRd_MuldeR; 10th October 2014 at 22:48.
LoRd_MuldeR is offline   Reply With Quote
Old 10th October 2014, 23:17   #3  |  Link
VideoFanatic
Registered User
 
Join Date: Sep 2011
Posts: 241
I understand all that but I'm trying to make a compliant Bluray. For example I'm trying to convert a 1080i PAL HDTV h264 video to 720p 50fps. If you look at the profiles table here: http://forum.doom9.org/showthread.php?t=154533 (under 1.2.1 Primary Video Rules) it shows 720p must have a 4.0 Level. Yet I chose the auto setting and it came out as High Level 3.2.
I was using these settings:

--bluray-compat --vbv-maxrate 15000 --vbv-bufsize 15000 --keyint 250 --slices 1 --sar 1:1

So I'm just wondering why it doesn't come out as 4.0 because from what I've seen in the table, it should come out as 4.0?
VideoFanatic is offline   Reply With Quote
Old 10th October 2014, 23:35   #4  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,196
First of all, when it comes to Levels, a decoder/player that supports Level X actually supports Levels up to X. Feeding the player with a stream that has a lower Level than the player's max. supported Level should never be an issue.

Or in other words: A video stream that complies to Level X also complies to any Level higher than X, tough it may not comply to Levels below X.

Since the BluRay standard is a subset of the H.264 standard, i.e. it only supports certain H.264 Profiles and H.264 Levels but there are even more restrictions on top of that, I don't know if supplying a stream that also complies to lower Levels than 4.0 would be acceptable. Anyway, if you look at the Levels Table, you'll notice that Level 3.2 supports 1280x720 video with up to 60 fps and 5 ref frames, so there's simply no need for Level 4.0 if you are dealing with 720p video at 50 fps.

To give a car analogy: You are demanding a speed limit of 120 km/h instead of 100 km/h despite your car's maximum speed is only 80 km/h anyway

See also:
http://www.x264bluray.com/home/720p-encoding
__________________
There was of course no way of knowing whether you were being watched at any given moment.
How often, or on what system, the Thought Police plugged in on any individual wire was guesswork.



Last edited by LoRd_MuldeR; 10th October 2014 at 23:53.
LoRd_MuldeR is offline   Reply With Quote
Old 11th October 2014, 09:48   #5  |  Link
r0lZ
PgcEdit daemon
 
r0lZ's Avatar
 
Join Date: Jul 2003
Posts: 7,393
I'm not sure I understand that profile and level concepts correctly. I did some tests with different presets (CRF 23, profile auto and level not defined), of course always with the same input file, and obviously the profile and levels depend of the input file, that's right, but also of the preset. For example, I got the Baseline profile when I have encoded the video with the Ultrafast preset, and profile high level 5.1 when the same video has been encoded with the Placebo preset, without any other change. Since my TV refuses to display level 5.0 or higher, I NEED to specify --level 4.1 if I use a slow preset.

Therefore, if I can agree that the characteristics of the input file are important to determine the profile and level used by default by x264, I notice that the preset is at least as important, and I must disagree when you say that "setting --level manually is almost always a bad idea". IMO, setting level to 4.1 (or max 4.2) is essential if you need a good compatibility with most hardware players, and you want to encode with a slow preset. (I wonder if it make sense to use a very slow preset like Placebo and in the same time limit the encoder with --profile high --level 4.1, but it's another question.)
__________________
r0lZ
PgcEdit homepage (hosted by VideoHelp)
BD3D2MK3D A tool to convert 3D blu-rays to SBS, T&B or FS MKV

Last edited by r0lZ; 11th October 2014 at 09:56.
r0lZ is offline   Reply With Quote
Old 11th October 2014, 13:48   #6  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,196
Again, the Profile defines which features of H.264 you are allowed to use. See this table for details or look into the H.264 specs (Annex A.2). Which Profile your stream comes out shouldn't depend on the input file at all. Instead it depends on what H.264 features you enable (or not enable). Of course features that influence the required Profile can be enabled/disabled either directly, by the corresponding switch, or indirectly, by the "--preset" switch.

Consequently, your stream will come out at the lowest possible Profile that covers all the features you were using. It cannot come out at an even lower Profile, because that's obviously not allowed by the specs. And it also doesn't come out at an even higher Profile, because that would be totally pointless - your stream doesn't need the even higher Profile, so why should an even higher Profile be indicated? It would only limit the compatibility of the stream - for exactly zero benefit!

It's simply the wrong idea to "want" a certain Profile. Instead, the target Profile is given by your intended playback device! If, for example, you playback device only supports "Main" Profile, you need to restrict your settings to "Main" Profile features. And, if your playback device supports "High" Profile, you can use "High" Profile features. Last but not least, if you are allowed to use "High" Profile features and if you actually do enable at least one "High" Profile feature, your stream will come out as "High" Profile automatically. The "--profile" switch is not intended to force a higher Profile; it is intended to enforce at most the specified Profile. Therefore, "--profile X" will turn off all features not allowed in Profile X. And that's it.


The Level restricts other things, like the max. resolution, the max. frame rate, the max. number of reference frames, the max. bitrate and so on. So what Level your stream requires partly depends on the input file (resolution, frame rate, etc) and also partly on your encoder settings (number of reference frames, bitrate, etc). By default, if you do not use the "--level" switch, x264 will set the lowest possible Level that your stream complies to. And that's the right thing to do!

The reason why I said that using "--level" is almost always a bad idea is because x264 will already set the "correct" Level, if you do not use that switch. Let's assume x264 would set Level X by default. Why would you want to enforce a lower Level than X, i.e. a Level that your stream actually doesn't comply to? It would result in a corrupted stream, because the stream actually requires Level X, but it has been tagged as some Level lower than X. Similarly, why would you want to set a Level higher than X? Your stream complies to Level X, so tagging it as some Level higher than X is pointless. You would restrict the compatibility of your stream for zero benefit! The only reason to use "--level" is when x264 somehow got the Level wrong.
__________________
There was of course no way of knowing whether you were being watched at any given moment.
How often, or on what system, the Thought Police plugged in on any individual wire was guesswork.



Last edited by LoRd_MuldeR; 11th October 2014 at 14:16.
LoRd_MuldeR is offline   Reply With Quote
Old 11th October 2014, 14:19   #7  |  Link
detmek
Registered User
 
Join Date: Aug 2009
Posts: 475
Well, I know one use for --level. If you encode FHD video with preset placebo it will end up as level 5.1. But, if you use --level 4.1 --preset placebo video will end up as level 4.1 because --level 4.1 will reduce number of reference frames from 16 to 4.
detmek is offline   Reply With Quote
Old 11th October 2014, 14:34   #8  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,196
Quote:
Originally Posted by detmek View Post
Well, I know one use for --level. If you encode FHD video with preset placebo it will end up as level 5.1. But, if you use --level 4.1 --preset placebo video will end up as level 4.1 because --level 4.1 will reduce number of reference frames from 16 to 4.
No, that's wrong. If your stream would normally come out as Level 5.1, but you enforce Level 4.1 by adding "--level 4.1" (while keeping all other settings the same), you stream's Level requirements do not change at all. Only difference is that your stream will now incorrectly be tagged as Level 4.1, while it actually doesn't comply to that Level - it still requires Level 5.1.

Using the "--level" switch does not reduce the number of reference frames. Instead, x264 will print out a warning, telling you that the selected number of reference frames violates the selected Level:
Code:
> x264_8bit_x64.exe --crf 18.0 --preset slower --ref 16

ffms [info]: 1920x1080p 0:1 @ 24000/1001 fps (vfr)
x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 Cache64 SlowShuffle
x264 [info]: profile High, level 5.1
Code:
> x264_8bit_x64.exe --crf 18.0 --preset slower --ref 16 --level 4.2

ffms [info]: 1920x1080p 0:1 @ 24000/1001 fps (vfr)
x264 [warning]: DPB size (16 frames, 130560 mbs) > level limit (4 frames, 34816 mbs)
x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 Cache64 SlowShuffle
x264 [info]: profile High, level 4.2
If you want fewer reference frames, simply use the "--ref" switch! And, if this actually reduced your stream's Level requirements, x264 will set the new (lower) Level automatically!
__________________
There was of course no way of knowing whether you were being watched at any given moment.
How often, or on what system, the Thought Police plugged in on any individual wire was guesswork.



Last edited by LoRd_MuldeR; 11th October 2014 at 14:39.
LoRd_MuldeR is offline   Reply With Quote
Old 11th October 2014, 14:34   #9  |  Link
r0lZ
PgcEdit daemon
 
r0lZ's Avatar
 
Join Date: Jul 2003
Posts: 7,393
There is no need to explain that again. Re-read what I have written. I understand perfectly that the --profile and --level options are the UPPER LIMITS. And I don't "want" high@L4.1. I haven't said that. I just want to limit x264 so that it creates a stream that my TV can play (and for the precise example of my TV, the limit is high@L4.2).

What I mean is that if you use a very slow PRESET (without limiting x264 to a certain profile or level), then the profile and/or level may be higher than what you expect, and therefore it might be NECESSARY to use the --profile and --level options. In the past, I used your GUI without specifying the level, but one time I did an encode and my TV has rejected it. That was because it was a very short clip, and for that reason, I've used for the first time a very slow preset. After verification, I came to the conclusion that the profile and level really used by x264 depend of the preset. That's what I have explained above, and it's a verified fact. Since then, I have added --level 4.1 in the user options, and my TV has never rejected any encoding any more. I understand perfectly that my TV can accepts lower presets or levels, and that x264 can produce them, even if I have specified high@L4.1.

What I mean is that it is incorrect to consider the level option as not important. In many case, it is an absolute necessity to specify it. I don't want to create videos that my TV rejects, and therefore I need to specify the --level option (at least when I use a slow preset). Again, it's a fact. (Of course, I could also not specify --level, but specify a lot of other options, that together have globally the same effect than using --level 4.1, but that's not the point.)

It's why I don't understand why the level option is not present in your GUI, and you have to type it explicitly. It's a very important setting that should be set to 4.1 by default IMO, because (almost) all recent players can decode that level, but currently very few hardware players accept level 5.0 or higher. IMO, NOT specifying the level IS the bad idea, because you may end up with files that are rejected by many players.
__________________
r0lZ
PgcEdit homepage (hosted by VideoHelp)
BD3D2MK3D A tool to convert 3D blu-rays to SBS, T&B or FS MKV

Last edited by r0lZ; 11th October 2014 at 14:45.
r0lZ is offline   Reply With Quote
Old 11th October 2014, 14:49   #10  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,196
Quote:
Originally Posted by r0lZ View Post
What I mean is that if you use a very slow PRESET (without limiting x264 to a certain profile or level), then the profile and/or level may be higher than what you expect, and therefore it might be NECESSARY to use the --profile and --level options.
What do I expect? I expect that, if I neither use "--profile" nor "--level", then x264 will set the "correct" Profile and Level for me. That is: the lowest possible Profile that my stream complies to as well as the lowest possible Level that my stream complies - given the current input file and the current encoder settings. Consequently, manually enforcing an even higher Profile or an even higher Level would make no sense. Enforcing a lower Profile can make sense, e.g. if I need to stick within "Main" Profile, because my playback device can only do "Main" Profile but not "High" Profile. Enforcing a lower Level, on the other hand, is almost always a very bad idea, as explained and demonstrated in the previous post.

Quote:
Originally Posted by holygamer View Post
Can I request a small feature please. At the moment when you modify a profile it gives you the option to select a profile to overwrite. But I can't always remember the name of the profile I was editing and want to overwrite because it has a long name.
You can't modify Profiles, because they are predefined by the H.264 standard. All H.264 Profiles that x264 recognizes should be selectable from the "Profile" combobox.
__________________
There was of course no way of knowing whether you were being watched at any given moment.
How often, or on what system, the Thought Police plugged in on any individual wire was guesswork.



Last edited by LoRd_MuldeR; 11th October 2014 at 14:53.
LoRd_MuldeR is offline   Reply With Quote
Old 11th October 2014, 15:31   #11  |  Link
r0lZ
PgcEdit daemon
 
r0lZ's Avatar
 
Join Date: Jul 2003
Posts: 7,393
Quote:
Originally Posted by LoRd_MuldeR View Post
What do I expect? I expect that, if I neither use "--profile" nor "--level", then x264 will set the "correct" Profile and Level for me.
I agree. But that doesn't mean that you don't need to specify the level when your target hardware is not compatible with the highest levels.

Quote:
Originally Posted by LoRd_MuldeR View Post
That is: the lowest possible Profile that my stream complies to as well as the lowest possible Level that my stream complies - given the current input file and the current encoder settings.
Here, I disagree, or I doesn't understand what you mean. If it's really the lowest profile that is selected, all videos should be encoded in the baseline profile, the lowest one. (It is compatible with the clip I have encoded, since it's the profile that x264 uses by default if I select the ultrafast preset.) IMO, the encoder tries to use the highest profile and level, given the input file and the preset. It's what I have verified: when you give it more time to compute a higher profile or level, it does it (of course, as long as it's compatible with your file).

Quote:
Originally Posted by LoRd_MuldeR View Post
Enforcing a lower Level, on the other hand, is almost always a very bad idea, as explained and demonstrated in the previous post.
Quote:
Originally Posted by LoRd_MuldeR View Post
If your stream would normally come out as Level 5.1, but you enforce Level 4.1 by adding "--level 4.1" (while keeping all other settings the same), you stream's Level requirements do not change at all. Only difference is that your stream will now incorrectly be tagged as Level 4.1, while it actually doesn't comply to that Level - it still requires Level 5.1.
Where have you learned that? In all sites about x264 I have visited, the level option is always presented as the upper limit for the encoder, not just as a way to force a (possibly wrong) information in the header. Also, my TV supports only level 4.2. If I encode without --level 4.2 at preset placebo, x264 uses level 5.1, and writes that info in the header. My TV rejects it. OK, that might be because it has read the info in the header. But how could you explain that when I encode the same clip with exactly the same parameters except that I have added --level 4.1, the same TV plays it perfectly? My TV rejects level 5.1 because it can't play it, but plays perfectly my file. Therefore, my file has been encoded at level 4.1, and the --level option has really been used to limit the encoder during the encoding process. Otherwise, I should at least see some glitches from time to time, but the result is perfect. Don't tell me that my TV can decode level 5.1 but rejects it, just to annoy the peoples.

However, I agree that specifying --ref 16 AND the --level 4.1 at the same time is incompatible and will trigger warnings. Of course, if you limit x264 to a certain level AND you force it to use some characteristics from a higher level, it will not be able to do what you want without violating one of the parameters. And in that case, it may write level 4.1 in the header, even if it's not true. In my tests, I specify ONLY the level, without other incompatible options, and in that case, I'm sure x264 produces really a stream compatible with level 4.1.
__________________
r0lZ
PgcEdit homepage (hosted by VideoHelp)
BD3D2MK3D A tool to convert 3D blu-rays to SBS, T&B or FS MKV

Last edited by r0lZ; 11th October 2014 at 15:34.
r0lZ is offline   Reply With Quote
Old 11th October 2014, 15:48   #12  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,196
Quote:
Originally Posted by r0lZ View Post
Here, I disagree, or I doesn't understand what you mean. If it's really the lowest profile that is selected, all videos should be encoded in the baseline profile, the lowest one.
If you don't use "--profile" explicitly, then x264 will set the lowest possible Profile that your stream complies to - given the current encoder settings. That's what I said

Or in other words: If you use lossless mode, it will set "High 4:4:4" Profile. If you do not use lossless mode, but you have any "High" Profile features enabled, it will set "High" Profile. If you have no "High" Profile features enabled, but some "Main" Profile features are enabled, it will set "Main Profile". Otherwise, if only "Baseline" Profile features are used, it will set "Baseline" Profile.

The "--profile X" option can be used to enforce a lower profile, because it will simply disable all the features that are not allowed in Profile X (if any of those were enabled before).


Quote:
Originally Posted by r0lZ View Post
Where have you learned that? In all sites about x264 I have visited, the level option is always presented as the upper limit for the encoder, not just as a way to force a (possibly wrong) information in the header. Also, my TV supports only level 4.2. If I encode without --level 4.2 at preset placebo, x264 uses level 5.1, and writes that info in the header. My TV rejects it. OK, that might be because it has read the info in the header. But how could you explain that when I encode the same clip with exactly the same parameters except that I have added --level 4.1, the same TV plays it perfectly? My TV rejects level 5.1 because it can't play it, but plays perfectly my file. Therefore, my file has been encoded at level 4.1, and the --level option has really been used to limit the encoder during the encoding process. Otherwise, I should at least see some glitches from time to time, but the result is perfect. Don't tell me that my TV can decode level 5.1 but rejects it, just to annoy the peoples.
As said before, if you use the "--level" switch, it will simply overwrite the Level that x264 would have set normally. And the Level that x264 would have set normally is the lowest possible Level that your stream complies to - given the current input file and the current encoder settings. Consequently, if you set an even lower Level, you stream will be tagged with that lower Level, yes. But that does not make your stream actually comply to that even lower Level! There is nothing in x264 that would "fix" your encoder settings (or your input file) to actually make the stream conform to the Level that you have set via "--level" switch! You can check this in the x264 code, if you want to...

And you can test this easily: Set a large number of reference frames via "--ref" switch and force a Level that doesn't actually allow that many reference frames (due to DPB size limit) via "--level" switch. Will x264 lower the number of reference frames for you, to make your stream actually comply to the enforced Level? No it doesn't! It only prints a warning message that your stream violates the Level! Does it still still set the enforced Level, despite your stream is violating the Level? Yes.

See also example here:
https://forum.doom9.org/showpost.php...postcount=1395
__________________
There was of course no way of knowing whether you were being watched at any given moment.
How often, or on what system, the Thought Police plugged in on any individual wire was guesswork.



Last edited by LoRd_MuldeR; 11th October 2014 at 16:03.
LoRd_MuldeR is offline   Reply With Quote
Old 11th October 2014, 16:25   #13  |  Link
r0lZ
PgcEdit daemon
 
r0lZ's Avatar
 
Join Date: Jul 2003
Posts: 7,393
Consider this example:
I encode my clip without any parameter, except --preset ultrafast. The encoder uses the baseline profile. (I don't think the level is relevant for the baseline profile, but I may be wrong.)
Then, I encode the same clip with --preset placebo. The encoder uses the high profile and level 5.1.
That means that my clip complies to all profiles between baseline and high, and to all levels currently implemented (up to 5.1).
When it has enough time, x264 selects the "best" profile and level automatically. For me, and obviously for x264, "best" is synonym with "highest" and not "lowest". Am I wrong?

Your example with the --ref and --level is perfect to prove that it is possible to specify incompatible options. I have agreed with that in the last paragraph of my previous post.

Now, if you want to encode the clip of the example above and be compatible with my TV WITHOUT SPECIFYING FANCY OPTIONS, you have 3 possibilities.

1. You can use a fast preset, but the result is unpredictable, and it is a pity to waste disc space.

2. You can specify --level 4.1, and everything is perfect, regardless of the preset you use (but as long as you don't specify incompatible options at the same time).

3. You can omit --level, but specify a bunch of other options so that in practice, you obtain also level 4.1. Since many options are somewhat obscure, and you can always make a mistake, my preferred solution is, by far, point 2.

It's why IMO it is a pity to not have that level option in your GUI. Most users do not understand the complex options of x264, and should use only the main options: the mode, quantizer or bitrate and the preset, profile and level. More knowledgeable peoples may prefer to specify a lot of more specific options, but they should be smart enough to disable the profile and level options if they are incompatible.
__________________
r0lZ
PgcEdit homepage (hosted by VideoHelp)
BD3D2MK3D A tool to convert 3D blu-rays to SBS, T&B or FS MKV

Last edited by r0lZ; 11th October 2014 at 16:30.
r0lZ is offline   Reply With Quote
Old 11th October 2014, 16:47   #14  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,196
Quote:
Originally Posted by r0lZ View Post
I encode my clip without any parameter, except --preset ultrafast. The encoder uses the baseline profile. (I don't think the level is relevant for the baseline profile, but I may be wrong.)
Profiles and Levels are orthogonal. The Level is as relevant (or irrelevant) with "Basline" Profile as with any other Profile.

Quote:
Originally Posted by r0lZ View Post
Then, I encode the same clip with --preset placebo. The encoder uses the high profile and level 5.1.
That means that my clip complies to all profiles between baseline and high, and to all levels currently implemented (up to 5.1).
When it has enough time, x264 selects the "best" profile and level automatically. For me, and obviously for x264, "best" is synonym with "highest" and not "lowest". Am I wrong?
Totally wrong!

For the last time: The Profile specifies witch features of H.264 you are allowed to use (or not). And x264 will select the lowest possible Profile that your stream compiles to. Always. No exceptions

So if you enable any "High" Profile features (e.g. "8x8 vs. 4x4 Transform Adaptivity"), as is the case with most of the slower presets (including "Placebo" preset), then your stream requires "High" Profile and that is exactly what x264 will set!

If, on the other hand, you only use "Baseline" Profile features, as is the case with "ultrafast" preset (since it disables pretty much everything that can be disabled), you obviously can get away with "Baseline" Profile. And that will be set.

Quote:
Originally Posted by r0lZ View Post
Now, if you want to encode the clip of the example above and be compatible with my TV WITHOUT SPECIFYING FANCY OPTIONS, you have 3 possibilities.

1. You can use a fast preset, but the result is unpredictable, and it is a pity to waste disc space.

2. You can specify --level 4.1, and everything is perfect, regardless of the preset you use (but as long as you don't specify incompatible options at the same time).

3. You can omit --level, but specify a bunch of other options so that in practice, you obtain also level 4.1. Since many options are somewhat obscure, and you can always make a mistake, my preferred solution is, by far, point 2.
Since x264 will always set the "correct" Profile (and also the proper Level, as long as you don't use"--level") for you, there is usually no need to use either "--profile" or "--level".

Only reason the use "--profile X" is when you explicitly want to apply the restrictions of Profile X to your x264 settings, because you know that the highest Profile supported by your playback device is X.

However, the "--level" option can not be used in that way. It just overwrites the Level that your stream will be tagged with - whether your stream actually conforms to that Level or not
__________________
There was of course no way of knowing whether you were being watched at any given moment.
How often, or on what system, the Thought Police plugged in on any individual wire was guesswork.



Last edited by LoRd_MuldeR; 11th October 2014 at 17:12.
LoRd_MuldeR is offline   Reply With Quote
Old 11th October 2014, 16:51   #15  |  Link
sneaker_ger
Registered User
 
Join Date: Dec 2002
Posts: 5,570
Quote:
Originally Posted by LoRd_MuldeR View Post
Using the "--level" switch does not reduce the number of reference frames.
Quote:
Originally Posted by LoRd_MuldeR View Post
And you can test this easily: Set a large number of reference frames via "--ref" switch and force a Level that doesn't actually allow that many reference frames (due to DPB size limit) via "--level" switch. Will x264 lower the number of reference frames for you, to make your stream actually comply to the enforced Level? No it doesn't!
It will if you do not override it with --ref. That's probably what r0lZ is seeing. But it doesn't enforce vbv so you really can end up breaking the limits. Most people don't notice because they encode with low average bitrates seldomly leading to problematic spikes and because devices don't straight out reject such streams - unlike with streams using too big DPB or too high level flag.

Using --level without --ref is handy because you don't have to calculate yourself, x264 does all the work.

Last edited by sneaker_ger; 11th October 2014 at 16:57.
sneaker_ger is offline   Reply With Quote
Old 11th October 2014, 17:13   #16  |  Link
r0lZ
PgcEdit daemon
 
r0lZ's Avatar
 
Join Date: Jul 2003
Posts: 7,393
Quote:
Originally Posted by LoRd_MuldeR View Post
So if you enable any "High" Profile features (e.g. "8x8 vs. 4x4 Transform Adaptivity"), as is the case with most of the slower presets (including "Placebo" preset), then your stream requires "High" Profile and that is exactly what x264 will set!

If, on the other hand, you only use "Baseline" Profile features, as is the case with "ultrafast" preset (since it disables pretty much everything that can be disabled), you obviously can get away with "Baseline" Profile. And that will be set.
OK, I understand now that the preset enforces some specifications. Until now, I thought that its only purpose was to allow more or less time to the encoder. Of course, with less time, the encoder cannot use the most sophisticated compression algorithms, and use the simplest ones, corresponding for example to baseline for ultrafast.

In my understanding, that means that if it has enough time to compute, say, profile high, it does it. I did not know that it is forced to use it, unless you specify a lower profile.

And same thing for the level. But I understand that I did a mistake.

Quote:
Originally Posted by sneaker_ger View Post
It will if you do not override it with --ref. That's probably what r0lZ is seeing.
Exactly. Thanks for clarifying what I mean. It is sometimes difficult to explain or understand something when English is not your native language.

Quote:
Originally Posted by sneaker_ger View Post
But it doesn't enforce vbv so you really can end up breaking the limits. Most people don't notice because they encode with low average bitrates seldomly leading to problematic spikes and because devices don't straight out reject such streams - unlike with streams using too big DPB or too high level flag.

Using --level without --ref is handy because you don't have to calculate yourself, x264 does all the work.
Nicely expressed. Thanks.
__________________
r0lZ
PgcEdit homepage (hosted by VideoHelp)
BD3D2MK3D A tool to convert 3D blu-rays to SBS, T&B or FS MKV
r0lZ is offline   Reply With Quote
Old 11th October 2014, 17:22   #17  |  Link
VideoFanatic
Registered User
 
Join Date: Sep 2011
Posts: 241
Sometimes I need to set a Profile such as in MeGUI where's there's no Auto option for AVC Profile. You have to choose one. It lets you set auto for the level but not the profile.
VideoFanatic is offline   Reply With Quote
Old 11th October 2014, 17:47   #18  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,196
Quote:
Originally Posted by r0lZ View Post
OK, I understand now that the preset enforces some specifications. Until now, I thought that its only purpose was to allow more or less time to the encoder. Of course, with less time, the encoder cannot use the most sophisticated compression algorithms, and use the simplest ones, corresponding for example to baseline for ultrafast.
Profiles and Levels say absolutely nothing about how much time the encoder uses for something. They also say absolutely nothing about which "algorithms" the encoder uses (or not uses). The standard/specification doesn't care about the internals of the encoder at all! What the standard does say is: If a certain H.264 decoder supports Profile X, then we can rely on the fact that this decoder supports all H.264 features that are allowed in Profile X, but we can not rely on anything beyond Profile X. Consequently, if a H.264 encoder wants create a H.264 stream that is supposed to work with a decoder that is capable of the Profile X, the the encoder must restrict itself to using only features that are allowed in Profile X.

In other words: If we want to create a H.264 stream that works with all "High" Profile decoders out there, then we must configure our encoder to use only "High" Profile features. If we want to create a H.264 stream that works with all "Main" Profile decoders out there, then we must configure our encoder to use only "Main" Profile features. And if we want to create a H.264 stream that works with all "Baseline" Profile decoders out there, then we must configure our encoder to use only "Baseline" Profile features. Note that the "Main" Profile features are a subset of the "High" Profile features. And that the "Baseline" Profile features are a subset of the "Main" Profile features - at least as far as the feature supported by x264 are concerned.

Once again I suggest to look at this table:
http://en.wikipedia.org/wiki/H.264/MPEG-4_AVC#Profiles
__________________
There was of course no way of knowing whether you were being watched at any given moment.
How often, or on what system, the Thought Police plugged in on any individual wire was guesswork.



Last edited by LoRd_MuldeR; 11th October 2014 at 17:53.
LoRd_MuldeR is offline   Reply With Quote
Old 11th October 2014, 18:49   #19  |  Link
detmek
Registered User
 
Join Date: Aug 2009
Posts: 475
Quote:
Originally Posted by LoRd_MuldeR View Post
No, that's wrong. If your stream would normally come out as Level 5.1, but you enforce Level 4.1 by adding "--level 4.1" (while keeping all other settings the same), you stream's Level requirements do not change at all. Only difference is that your stream will now incorrectly be tagged as Level 4.1, while it actually doesn't comply to that Level - it still requires Level 5.1.

Using the "--level" switch does not reduce the number of reference frames. Instead, x264 will print out a warning, telling you that the selected number of reference frames violates the selected Level:
Code:
> x264_8bit_x64.exe --crf 18.0 --preset slower --ref 16

ffms [info]: 1920x1080p 0:1 @ 24000/1001 fps (vfr)
x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 Cache64 SlowShuffle
x264 [info]: profile High, level 5.1
Code:
> x264_8bit_x64.exe --crf 18.0 --preset slower --ref 16 --level 4.2

ffms [info]: 1920x1080p 0:1 @ 24000/1001 fps (vfr)
x264 [warning]: DPB size (16 frames, 130560 mbs) > level limit (4 frames, 34816 mbs)
x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 Cache64 SlowShuffle
x264 [info]: profile High, level 4.2
If you want fewer reference frames, simply use the "--ref" switch! And, if this actually reduced your stream's Level requirements, x264 will set the new (lower) Level automatically!
You are enforcing --ref 16. Try without that.

Edit:

Sneaker_ger already mentioned that, didn't see. Sorry.

Last edited by detmek; 11th October 2014 at 21:21.
detmek is offline   Reply With Quote
Old 12th October 2014, 00:31   #20  |  Link
r0lZ
PgcEdit daemon
 
r0lZ's Avatar
 
Join Date: Jul 2003
Posts: 7,393
Quote:
Originally Posted by LoRd_MuldeR View Post
Profiles and Levels say absolutely nothing about how much time the encoder uses for something.
I know that. I was referring to PRESETS. Presets are named ultrafast, faster, slower, and so on. They have obviously something to do with the encoding speed. It's probably because they are very badly named that I have made the confusion at the origin of this discussion. Given their name, it seems that they control ONLY the encoding speed. In fact, they control the profile and level, and therefore, indirectly, the speed of the encoding. When you understand that, everything becomes clear. IMO, the next time someone asks you that kind of question, you should begin by explaining that.

The rest of your post above is well known and doesn't need to be repeated. You just use "feature" when I use "algorithm". The real difficulty is to understand HOW to configure the encoder to obtain a specific profile and level. As I understand now, it's normally NOT via the profile and level options, but mainly via the preset option, at least when the encoder is x264. It's not really intuitive.

In the wiki article, they explain the profile and level concepts, but there is nothing about the presets. It's normal, since the article is about h264 and not about the syntax of x264, but that doesn't help me. I have perfectly understood the profile and level concepts, and I know now that the preset is something made to simplify the selection of the profile and level. I want to understand now how the presets determine specific profiles and levels (if the input file supports them). Currently, I am forced to use a preset without knowing what will be the profile and level used by the encoder, and therefore I can't be sure that my TV will support it. It's why I have usually specified also the profile and the level. Now, if I don't specify them any more, what profile I must use remains a mystery. I will certainly find the solution on the internet, since now I know what I must search. Thanks for having clarified that point.
__________________
r0lZ
PgcEdit homepage (hosted by VideoHelp)
BD3D2MK3D A tool to convert 3D blu-rays to SBS, T&B or FS MKV

Last edited by r0lZ; 12th October 2014 at 00:41.
r0lZ is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:42.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, vBulletin Solutions Inc.