View Full Version : ffmpeg returning @main not @high
jriker1
9th June 2021, 01:57
Trying to set my HEVC video in ffmpeg to Main 10@L6.2@High. Keeps coming back as Main 10@L6.2@Main. So main at the end. Any idea why I can't get it to High? Below is the latest command I ran:
ffmpeg.exe -i prores422.mov -c:v libx265 -x265-params level=6.2:hdr-opt=1:repeat-headers=1:colorprim=bt2020:transfer=smpte2084:colormatrix=bt2020nc:master-display=G(13250,34500)B(7500,3000)R(34000,16000)WP(15635,16450)L(40000000,50):max-cll=349,86:vbv-bufsize=15360:vbv-maxrate=15360:bitrate=15360 -preset slow -pix_fmt yuv420p10le -sn -an hevc.mkv
Asmodian
9th June 2021, 04:33
I think it is because High profile is for maxrates above 240000 kbps when using level 6.2, and you are limiting it to 15360 kbps.
Since that is the only difference it is pointless to mark it as High when it is not.
rwill
9th June 2021, 05:42
Have you tried "-x265-params no-high-tier=0" ?
jriker1
9th June 2021, 16:10
Thanks for the replies. In all my research it was my understanding, at least in the Premiere Pro world (for whatever good that app is with HDR), that you need to select Main 10 and Tier High for proper HDR material creation no?
I tried adding no-high-tier=0 but it still created @Main content.
I tried setting the below values to:
vbv-bufsize=65360:vbv-maxrate=65360:bitrate=65360
Still @Main
Then tried:
vbv-bufsize=95360:vbv-maxrate=95360:bitrate=95360
Same deal.
EDIT: If I change level to 5.1 then it switches to High. However not if I drop the bitrate back down to 15360. Note I am trying to do a 15MB/s encode which in Premiere I just set to "15". In FFMpeg setting to 15000 or whatever just seems to result in 13MB/s. There has to be a way to set this to High and kill the logic in FFMpeg that is thinking it's smarter than me and knows what I want.
benwaggoner
9th June 2021, 18:55
You can certainly encode decent HDR with the Adobe products without using High Tier. I generally prefer to raise the level instead. High Tier isn't as commonly supported in hardware as higher levels.
Note that support for HW HEVC HDR encoding was added recently. HW is less efficient, so may well require higher bitrate. The built-in SW HEVC encoder is licensed from Main Concept, I believe, and is quite a bit slower (much less multithreading), lower quality than x265, and not nearly as configurable. I only use it for HEVC encoding for quick checks on tone mapping or other video processing where I can trade off higher bitrates for faster encoding.
But for 4K, Level 5.1 goes up to 40 Mbps, which is generally enough for most content.
rwill
9th June 2021, 19:15
I looked at the relevant x265 source part and it looks like there is no way to force High Tier unless the Bitrate needs High Tier @ Level or BluRay compatibility is set. So no, one cannot force High Tier using x265 just because one feels like it. Bummer.
Tier does not matter anyway unless some application standard ( like BluRay ) requires it to be set regardless of bitstream needs. You can do your HDR10 with Main Tier as well.
jriker1
9th June 2021, 19:30
OK thanks for the help. Here is where I'm at now.
ffmpeg.exe -i prores422.mov -c:v libx265 -x265-params level=51:hdr10=1:hdr-opt=1:high-tier=1:repeat-headers=1:colorprim=bt2020:transfer=smpte2084:colormatrix=bt2020nc:master-display=G(13250,34500)B(7500,3000)R(34000,16000)WP(15635,16450)L(40000000,50):max-cll=349,86:vbv-bufsize=30000:vbv-maxrate=15000:bitrate=15000:chromaloc=2 -preset slow -pix_fmt yuv420p10le -sn -an hevc.hevc
For some reason the above comes out to 13.8MB/s rather than 15.
Also I have historically encoded my video in constant bitrate. Not sure the above is fully accomplishing this but I came from a place where you would define a physical constant bitrate or in creating DVDs I could visually control the bitrate and see visually where any footage isn't getting a high enough bitrate so VBR was fine. However as I transitioned years ago to WMV HD for my personal library and now HEVC "seeing" that info isn't really an option so shy away from VBR. Hard to trust the app will do the right thing. That said, if I wanted to have a 15MB/s constant bitrate video how do I get the above to actually do that? Also if its recommended to do VBR for my library content using a Shield TV, how would I modify the above for 2 pass encoding? Assuming I guess would be an "average" 15MB/s bitrate?
benwaggoner
9th June 2021, 19:45
OK thanks for the help. Here is where I'm at now.
ffmpeg.exe -i prores422.mov -c:v libx265 -x265-params level=51:hdr10=1:hdr-opt=1:high-tier=1:repeat-headers=1:colorprim=bt2020:transfer=smpte2084:colormatrix=bt2020nc:master-display=G(13250,34500)B(7500,3000)R(34000,16000)WP(15635,16450)L(40000000,50):max-cll=349,86:vbv-bufsize=30000:vbv-maxrate=15000:bitrate=15000:chromaloc=2 -preset slow -pix_fmt yuv420p10le -sn -an hevc.hevc
For some reason the above comes out to 13.8MB/s rather than 15.
If you've got some blank or very easy to encode sections, x265 might not have found a way to use all 15 Mbps. Look at the --log-level 1 .csv and you should be able to pick up on which sections have an ABR drop.
Also I have historically encoded my video in constant bitrate. Not sure the above is fully accomplishing this but I came from a place where you would define a physical constant bitrate or in creating DVDs I could visually control the bitrate and see visually where any footage isn't getting a high enough bitrate so VBR was fine. However as I transitioned years ago to WMV HD for my personal library and now HEVC "seeing" that info isn't really an option so shy away from VBR. Hard to trust the app will do the right thing. That said, if I wanted to have a 15MB/s constant bitrate video how do I get the above to actually do that? Also if its recommended to do VBR for my library content using a Shield TV, how would I modify the above for 2 pass encoding? Assuming I guess would be an "average" 15MB/s bitrate?
For library use, VBR is almost always better. An encoder keeps bitrate constant by varying quality, and quality constant by varying bitrate. You can do 2-pass VBR if you want a guaranteed ABR. But if you want the smallest file that hits your quality target, CRF is your friend. Its results are the same as a 2-pass if a CRF value was selected that would give the specified ABR. But as some content is easier and others harder to encode, using CRF lets the easy titles be smaller and the harder titles be bigger while still keeping total library size as small as needed.
15 Mbps is quite low for Level 5.1 content, which allows up to 40 Mbps. I'd try something like:
level=51:hdr10=1:hdr-opt=1:high-tier=1:repeat-headers=1:colorprim=bt2020:transfer=smpte2084:colormatrix=bt2020nc:master-display=G(13250,34500)B(7500,3000)R(34000,16000)WP(15635,16450)L(40000000,50):max-cll=349,86:vbv-bufsize=40000:vbv-maxrate=40000:crf=18:chromaloc=2 -preset slower
jriker1
9th June 2021, 19:52
Thanks Ben. I have a fairly large LG TV and am just starting on 4k content but on my PC screen the video looks good at 15MB/s. Not sure if visually things would be noticeable and I'm just not seeing it because I have nothing to compare against. I also run all my content thru NeatVideo so strip out a lot of noise which I guess in theory allows for a lower bitrate overall. Gonna try your settings though.
Edit: Those changes came back with a constant bitrate and some other values of English, 4 235 kb/s, 3840*1750 (2.2:1), at 23.976 (24000/1001) FPS, HEVC (Main 10@L5.1@Main), HDR10
rwill
9th June 2021, 19:59
I have doubts that ffmpeg will do the right thing when the source is 422 prores, -pix_fmt is set to 420p10le and x265 gets chromaloc=2.
jriker1
9th June 2021, 20:01
Would be nice if I could create the final output in Premiere Pro and then just add the HDR info thru ffmpeg to the file without re-encoding. Since I don't think that is possible, I export with ProRes in Premiere and then convert with ffmpeg adding the HDR info back in since Premiere won't do it.
benwaggoner
9th June 2021, 20:44
Would be nice if I could create the final output in Premiere Pro and then just add the HDR info thru ffmpeg to the file without re-encoding. Since I don't think that is possible, I export with ProRes in Premiere and then convert with ffmpeg adding the HDR info back in since Premiere won't do it.
Adobe Media Encoder 2021 now supports specifying MaxCLL and MaxFALL, so you can export straight from a Premiere timeline to a file matching your specs.
https://1drv.ms/u/s!AlvIQZWsyeO-k9l0A550X7UZ06AgKQ?e=T27JfD
jriker1
9th June 2021, 20:46
Adobe Media Encoder 2021 now supports specifying MaxCLL and MaxFALL, so you can export straight from a Premiere timeline to a file matching your specs.
https://1drv.ms/u/s!AlvIQZWsyeO-k9l0A550X7UZ06AgKQ?e=T27JfD
Yep, but nothing is there when it's done. In there I can't define the color info, but the light levels, luminance don't show even if you enter them when exporting. At least mediainfo doesn't show it and ffprobe shows nothing either.
jriker1
9th June 2021, 23:12
Maybe I need a Google search on CRF. So I try encoding a small block at CRF 18. File is real small. My attempt at constant bitrate with 15000 is about 149 megs and CRF18 is 43 megs. In MediaInfo I get:
Bit rate : 4235173
Bit rate : 4 235 kb/s
Nothing about constant or variable. When I watch the segment in VLC the beginning with little data is as low as 70 kb/s. When there is more data and the actual video starts into the movie it's more in the 2000 - 6000 kb/s range. Is this expected for 4k content? I did not set any limits just the crf value to test.
With my original settings of 15000 max and 15000 bitrate the video goes as low as 11k and as high for the segment I checked of 23k. Apparently not super constant so not 100% sure what my original settings do unless it's still an average. Funny that I have a max of 15000 but still hits 23000.
benwaggoner
10th June 2021, 22:36
Maybe I need a Google search on CRF. So I try encoding a small block at CRF 18. File is real small. My attempt at constant bitrate with 15000 is about 149 megs and CRF18 is 43 megs. In MediaInfo I get:
Bit rate : 4235173
Bit rate : 4 235 kb/s
Nothing about constant or variable. When I watch the segment in VLC the beginning with little data is as low as 70 kb/s. When there is more data and the actual video starts into the movie it's more in the 2000 - 6000 kb/s range. Is this expected for 4k content? I did not set any limits just the crf value to test.
MediaInfo reports just the average and sometimes peak bitrate. It doesn't give any sense of the variability beyond that. VLC is showing you the moment-to-moment bitrate.
With my original settings of 15000 max and 15000 bitrate the video goes as low as 11k and as high for the segment I checked of 23k. Apparently not super constant so not 100% sure what my original settings do unless it's still an average. Funny that I have a max of 15000 but still hits 23000.
Over what time window are you looking at bitrate? There's a huge difference between looking at individual frames, a 1 second window, or a longer window. For RC reasons, I like to average over vbv-bufsize/vbv-maxrate. So, with a 40 Mbps bufsize and a 15 Mbps maxrate, 2.67 seconds. That reflects how much time VVC has to average out to hit the ABR, which goes up as the ratio increases.
benwaggoner
10th June 2021, 22:38
Yep, but nothing is there when it's done. In there I can't define the color info, but the light levels, luminance don't show even if you enter them when exporting. At least mediainfo doesn't show it and ffprobe shows nothing either.
Well, that's not good! And somewhat surprising...
Do you have it configured something like this (https://1drv.ms/u/s!AlvIQZWsyeO-k9l0A550X7UZ06AgKQ?e=Z6HvVX)?
jriker1
11th June 2021, 17:31
Well, that's not good! And somewhat surprising...
Do you have it configured something like this (https://1drv.ms/u/s!AlvIQZWsyeO-k9l0A550X7UZ06AgKQ?e=Z6HvVX)?
Yep, plus have it set to High Tier and Max bitdepth or whatever it is. Doing some encoding right now with FFMpeg so didn't want to launch premiere at the moment but have those two Max checkboxes checked.
So, with a 40 Mbps bufsize and a 15 Mbps maxrate, 2.67 seconds. That reflects how much time VVC has to average out to hit the ABR,
Ahhh, I assumed maxrate meant it would never exceed that bitrate EVER but looks like I misunderestood. Plus thought buffersize was more related to how much content the player was being asked to buffer before playing.
benwaggoner
11th June 2021, 19:29
Yep, plus have it set to High Tier and Max bitdepth or whatever it is. Doing some encoding right now with FFMpeg so didn't want to launch premiere at the moment but have those two Max checkboxes checked.
Good on Max. But note that High Tier just will make the file potentially less compatible unless you're actually using bitrates beyond what Main Tier can do at a given Profile @ Level. Which is 40 Mbps with Main10 Main Tier Level 5.1, and it seems you're doing well below that.
Ahhh, I assumed maxrate meant it would never exceed that bitrate EVER but looks like I misunderestood. Plus thought buffersize was more related to how much content the player was being asked to buffer before playing.
It's the classic "leaky bucket" model. Maxrate defines the maximum bitrate, averaged over bufsize bits. With bufsize=40 and maxrate=15, the encoder has a 2.6 second window to achieve maxrate. But the actual average bitrate of any one second in that scenario can be 40 Mbps, but bitrate would have to be <15 Mbps before and after that second to keep within the 15/40.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.