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 > Video Encoding > MPEG-4 AVC / H.264

Reply
 
Thread Tools Search this Thread Display Modes
Old 7th February 2011, 18:30   #1  |  Link
Klagar
Registered User
 
Klagar's Avatar
 
Join Date: Sep 2010
Posts: 46
[FFmpeg] qmin, qmax, subq and bitrate ?

Hi all !

I've run some tests and am trying to strike a balance between qmin, qmax, subq and bitrate parameters in FFmpeg.
At first, I designed my custom command lines based on the preset files (I had at first to make sure the presets were indeed optimal for what we were doing specifically, so I had to juggle a little with the many parameters).

What I see is that presets usually (for higher quality sets) have very high qmin and qmax (10 and 51 respectively). I had the habit of using values of 1 and 31 respectively.

Then, the subq is also rather high (8 or 9 when I usually use 6).

However, I usually use a pretty high bitrate to compensate for the quality loss I'd have somewhere else.

My question is : is there some trick to help determine what is better, between : a low qmin, a high subq, or a high bitrate ?
Are they, in essence, all the same thing and I'm losing my time trying to exchange one for the other ?
(Other than subq 7-8 which, I understand, unlock some BFrames-related features ; I don't take that into consideration very much at the moment)...
And why did the people who designed the preset, choose this particular setting ?

It seemed ok to use qmin 10 and qmax 51, but some self-proclaimed pros told me we were better off with qmin 1, no qmax specified and a lower bitrate. I'd like to have your advice on this.

Thank you very much !!!
Regards.
Klagar is offline   Reply With Quote
Old 7th February 2011, 19:09   #2  |  Link
sneaker_ger
Registered User
 
Join Date: Dec 2002
Posts: 5,565
No, they are not the "same thing".

1.) lower bitrate = lower quality for the same settings, so I don't really get that part of your question. Of course more bitrate means better quality. This is true for all lossy compressions.
2.) q(p)min=10 was x264's default setting until recently. Now it is q(p)min=0. The x264 devs use this setting for all presets, so just set it to 0 and let x264 do its job.
3.) The maximum possible value for q(p)max is 51, which is again used in all presets. Stick to it. *

qmin and qmax only restrict x264 in it's decision making, so do not change them if you don't know whether you can make better decisions than x264 itself or not.

4.) subq = 7 is x264's standard setting. 8 is slow, 9 even slower and 10 very slow. They are all fine, use the one that's fast enough for you.

( * very recently x264 added a "vbv emergency mode" which is triggered by setting qpmax to a value higher than 51, but your ffmpeg build probably does not support it yet, as it is too new. If you do not use vbv it does not concern you anyways.)
sneaker_ger is offline   Reply With Quote
Old 9th February 2011, 17:15   #3  |  Link
Klagar
Registered User
 
Klagar's Avatar
 
Join Date: Sep 2010
Posts: 46
Thanks sneaker_ger !

Quote:
The x264 devs use this setting for all presets, so just set it to 0 and let x264 do its job.
In presets files that come with the most recent autobuilds, even in slow and slower presets, qmin is always at 10. That's why I was wondering. Now if you tell me it *should* be left at 0 (or 1, depending) then that's what I will do.
qmax I don't specify in any case.

As for subq, I used to stick with a value of 6 most of the time (that seems to be the standard everywhere I look), and that was part of my question : would I be better off using a higher subq and a slightly lower bitrate, or the opposite ? Are the results going to be comparable ? If not, what would change significantly ? As far as I can tell, both the bitrate and subq are designed to influence the general quality, albeit on a different scale. But they must do each a different job, otherwise there wouldn't be two quality switches instead of one, would there ?

Thanks a lot.
Regards.
Klagar is offline   Reply With Quote
Old 9th February 2011, 17:42   #4  |  Link
sneaker_ger
Registered User
 
Join Date: Dec 2002
Posts: 5,565
Quote:
Originally Posted by Klagar View Post
In presets files that come with the most recent autobuilds, even in slow and slower presets, qmin is always at 10. That's why I was wondering. Now if you tell me it *should* be left at 0 (or 1, depending) then that's what I will do.
The "official" x264 presets use qpmin=0 now, probably no one has bothered changing it in the ffmpeg presets yet. So yes, use qpmin=0.

Quote:
Originally Posted by Klagar View Post
As for subq, I used to stick with a value of 6 most of the time (that seems to be the standard everywhere I look), and that was part of my question : would I be better off using a higher subq and a slightly lower bitrate, or the opposite ? Are the results going to be comparable ? If not, what would change significantly ? As far as I can tell, both the bitrate and subq are designed to influence the general quality, albeit on a different scale. But they must do each a different job, otherwise there wouldn't be two quality switches instead of one, would there ?
Yes, they control different things. The bitrate controls ..... the bitrate. Higher bitrate = higher quality for the same subq.
subq sets the "subpixel estimation complexity". Higher values = higher quality for the same bitrate

So yes, it is possible to reach the same quality with lower subq + higher bitrate as higher subq + lower bitrate. Normally you'd set subq to a value that is still fast enough for you (higher subq = lower speed) and then decide on the bitrate you need. If you are not aiming for a specific file size but rather constant quality of your encodes, use "-crf" (constant quality) instead of "-b" (bitrate) to save some time.
sneaker_ger is offline   Reply With Quote
Old 9th February 2011, 18:00   #5  |  Link
Klagar
Registered User
 
Klagar's Avatar
 
Join Date: Sep 2010
Posts: 46
Quote:
If you are not aiming for a specific file size but rather constant quality of your encodes, use "-crf" (constant quality) instead of "-b" (bitrate) to save some time.
Cool, that was another question I had in the back of my head...
So -crf is made to replace -b, and not only complement it ? That's what I had figured, but I couldn't make sure...

If I use -crf, is it a good idea (or even necessary) to use -minrate/-maxrate in order to achieve fairly constant quality ?

And what value of -crf would you personnally recommend for 1920x1080 videos ?

Thanks so much !
Klagar is offline   Reply With Quote
Old 9th February 2011, 18:14   #6  |  Link
Klagar
Registered User
 
Klagar's Avatar
 
Join Date: Sep 2010
Posts: 46
I ran some tests, replacing -b by -crf, and the result was a video encoded in 2,000 kbps (which is far not enough for my needs, I'd be more comfortable with, say, 20,000 kbps !) so I assume after all -crf is a complement to -b and not a replacement. However I await confirmation from someone in the know ! ;-)

Thanks as always !
Klagar is offline   Reply With Quote
Old 9th February 2011, 18:20   #7  |  Link
sneaker_ger
Registered User
 
Join Date: Dec 2002
Posts: 5,565
Quote:
Originally Posted by Klagar View Post
Cool, that was another question I had in the back of my head...
So -crf is made to replace -b, and not only complement it ? That's what I had figured, but I couldn't make sure...
Yes, you cannot use both at the same time.

Quote:
Originally Posted by Klagar View Post
If I use -crf, is it a good idea (or even necessary) to use -minrate/-maxrate in order to achieve fairly constant quality ?
It's not necessary to set them in order to achieve constant quality (in fact it will even do the opposite), but you might need to limit the bitrate for other reasons:
1.) x264 does not know any "-minrate" option
2.) You can use -maxrate in conjunction with -bufsize to limit the maximum bitrate locally. You don't need to set these options for playback on a PC, but they may be useful if you are aiming for a standalone device such as a Blu-Ray player or a phone etc.

Quote:
Originally Posted by Klagar View Post
And what value of -crf would you personnally recommend for 1920x1080 videos ?
crf=18 is a good starting point and probably what most people use. Higher crf = lower quality. You get roughly about double/half the bitrate for the substraction/addition of 6.
sneaker_ger is offline   Reply With Quote
Old 9th February 2011, 18:31   #8  |  Link
Klagar
Registered User
 
Klagar's Avatar
 
Join Date: Sep 2010
Posts: 46
Great ! I'll try some of it and see where it leads.
Thanks a lot, this thread may be considered as "resolved" !
Klagar is offline   Reply With Quote
Old 9th February 2011, 21:44   #9  |  Link
Chikuzen
typo lover
 
Chikuzen's Avatar
 
Join Date: May 2009
Posts: 595
Quote:
Originally Posted by sneaker_ger View Post
The "official" x264 presets use qpmin=0 now, probably no one has bothered changing it in the ffmpeg presets yet. So yes, use qpmin=0.
http://lists.mplayerhq.hu/pipermail/...ry/105413.html
http://git.ffmpeg.org/?p=ffmpeg.git;...8068f0e3bb9c2f
__________________
my repositories
Chikuzen is offline   Reply With Quote
Reply

Tags
bitrate, ffmpeg, qmax, qmin, subq

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 00:01.


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