Log in

View Full Version : simple bitrate question


junglemike
11th September 2006, 10:41
Let's say that i encode some video with single pass/constant quality with x264. Let's suppose resulting file is X mb.
Thank I take same source, and encode it with dual-pass, and specify X as final size.
Considering that all rest x264 settings are the same, can i expect better quality in 2nd case? and why?

GodofaGap
11th September 2006, 10:56
Perhaps a real tiny bit.

In two pass the IDR frame (keyframe) quants can be decided on the complexity of the following frames (the frames that actually matter), instead of the preceding ones, which should result in a little bit better quality. However, the problem with two pass is that to aim for a certain quality you have no idea what bitrate to use and it is obviously slower.

chros
17th September 2006, 08:51
However, the problem with two pass is that to aim for a certain quality you have no idea what bitrate to use and it is obviously slower.
But if you DID the 1 pass constant quality pass, you have.

@This question popped up in me too, so thanks for questioning.

GodofaGap
17th September 2006, 09:10
Ok, but then you have twice the encoding time for a very small quality gain.

Seb.26
19th September 2006, 17:13
Looks interesting ...

IMO, the first pass is really short in 2 pass encoding ... but ...
... I have 2 questions : :D

> In the 1pass/constant Q, what about encoding time ?
( equal to 2nd pass in 2pass mode, or bigger ? ... smaller ??? )

> What value for Q to obtain a great quality ?
( I usualy encode DVD in anamoprhic, just cropp and Convo3D(HQ) with 1500KBps in 2 pass )

Thanks for answering ...

Sharktooth
19th September 2006, 17:18
1) 1st pass in constant Q needs about the same time to 2nd pass in 2 pass mode.

2) It all depends on you. Q18 is almost equivalent to xvid Q2. Quants from 18 to 22 looks good for my eyes but if you use a CRT, higher quants will look good as well.

Seb.26
20th September 2006, 09:07
Hi ! :)

1) 1st pass in constant Q needs about the same time to 2nd pass in 2 pass mode.
Ok, so encoding time won't be really differents ( 1st pass is short )

2) It all depends on you. Q18 is almost equivalent to xvid Q2. Quants from 18 to 22 looks good for my eyes but if you use a CRT, higher quants will look good as well.
I watch then on a 50" screen ... I will try Q18 ;)
( what about the lowest Q usable in real life ? )

> Have you an idea about the global bitrate with Q18 for a full anamorphic film (720*432) ?! ... more or less than 1500KBps
... In any case, the best is I try this myself :D ...

Another point (:o) : I only encode anamoprhic video ( DVD without resizing : only crop top & bottom ) ... I've seen "sample ratio" in codec ...
> Will this really add quality to the result ? ...
> And will it increase/decrease encoding time ? ... a lot ?

:thanks: a lot for the usefull information ...

Seb.

GodofaGap
20th September 2006, 09:49
Ok, so encoding time won't be really differents ( 1st pass is short )
Well no. You can't use fast first pass this way. The size you get from it would probably be a bit larger than with a normal encode, so you would be overshooting. If you really don't care about filesize a crf value of 18 should be enough to overcome the problems I have mentioned. Firstly, because the problem is not that large to begin with and secondly, because at crf 18 each IDR frame will probably get a low enough quant anyway.

If you are using crf, you should not expect to look your encode that much better just because you added a second pass to it. The tradeoff quality gain/time is very, very bad.

Will this really add quality to the result ? ...
> And will it increase/decrease encoding time ? ... a lot ?
SAR is just flag that tells a decoder/player how to resize the video so the AR is correct. It does not add quality, it does not change encoding time. Of course since you are keeping more resolution than you would if you had downsized the video, it should look better with crf (but also be bigger in size).

Seb.26
20th September 2006, 11:57
Well no. You can't use fast first pass this way. The size you get from it would probably be a bit larger than with a normal encode, so you would be overshooting. If you really don't care about filesize a crf value of 18 should be enough to overcome the problems I have mentioned. Firstly, because the problem is not that large to begin with and secondly, because at crf 18 each IDR frame will probably get a low enough quant anyway.

If you are using crf, you should not expect to look your encode that much better just because you added a second pass to it. The tradeoff quality gain/time is very, very bad.
I will read this again to try to understand ... :o :o ... sorry
[Edit] 'crf' is similare to 'Q factor', isn't it ?
[Edit2] I probably badly wrote what I think ... by <<( 1st pass is short )>> I want to say that the time encoding difference between "1pass/constant Q" and "2 pass" is small because 1st pass is short in 2 pass ...


SAR is just flag that tells a decoder/player how to resize the video so the AR is correct. It does not add quality, it does not change encoding time. Of course since you are keeping more resolution than you would if you had downsized the video, it should look better with crf (but also be bigger in size).
... in my mind, I think that it can help the encoder to know that picture haven't a 1:1 SAR ... but if it's just for the output stream AR ...
Ok, so I don't need this ( today I put this aspect ration when muxing with MKV merge ) ...

:thanks:

GodofaGap
20th September 2006, 12:13
'crf' is similare to 'Q factor', isn't it ?
Similar yes.

I probably badly wrote what I think ... by <<( 1st pass is short )>> I want to say that the time encoding difference between "1pass/constant Q" and "2 pass" is small because 1st pass is short in 2 pass ...
Ok, but then you have the problem again not knowing what bitrate to aim for. :)

Seb.26
20th September 2006, 12:25
Similar yes.
<< mi scusi >> ... just back from holliday in italia ... :D

Ok, but then you have the problem again not knowing what bitrate to aim for. :)
yes, it's right, but I hope that with some tests, I can find the crf that result in 1500KBps bitrate I actually use ... and the size isn't really a problem today ... I usually burn 3 movies on a DVD-R ...

GodofaGap
20th September 2006, 12:32
If you want 1500 kbps don't go looking for a crf value, because you won't find one. Just do a 2 pass with 1500 kbps.

Seb.26
21st September 2006, 10:33
If you want 1500 kbps don't go looking for a crf value, because you won't find one. Just do a 2 pass with 1500 kbps.
It's exactly what I do actually ;) ...
... but ...
Result file size isn't really my first goal ... the main goal is the output quality ... So if I can find a crf value that offer great quality with result bitrate around 1500KBps ... it's perfect ...

I will test this when I can found some minutes ...
... thanks 2 all for informations :)

Seb.

Sharktooth
21st September 2006, 13:06
Well different sources will have different bitrates at a fixed CRF value...

Seb.26
21st September 2006, 16:13
Well different sources will have different bitrates at a fixed CRF value...
Hum ... look like crf isn't easy to use ... :confused:
... Maybe a better way is to limit the max quantizer allowed and encode in 2pass with 1500Kbps bitrate ... not ?

Does quantizer value equal to crf value ? ...
-> For exemple :

1) I encode a part of my movie with crf 30

2) I encode same part of movie in 2pass with the max quantizer at a value of 30

Does the less beautiful frame of the 2pass encoding ( with max quantizer ) will same than the crf one ?

Is yes, I will be able to find my "max allowed quantizer" value to put in the encoder ... and continue to encode in 2 pass ...
( but I think if yes, the quantizer value will also change from one source to another ... :scared: ;) )

:D

Sharktooth
21st September 2006, 21:02
CRF or CQ will behave almost in the same manner.
The allocated bits depends on how much the source is compressible.
The constant rate factor was hardcoded to be as near as possible as the constant quantizer value.
You can in no way predict the filesize of the whole encoding using CRF or CQ. You can guess it (hence the bitrate) with an approximated extrapolation (compression test), but it's not 100% accurate (look here: http://forum.doom9.org/showthread.php?t=115970)

StephenChow
24th September 2006, 06:55
Hello,

I really don't know about --crf xx parameter (where xx is a number)
The higher number the better quality and file size is higher or lower number is better for video quality.

XviD Q2 was mentioned, what does it mean?
Is that an video quality certification or level? XviD Q2?

Thank you,

GodofaGap
24th September 2006, 07:58
For crf the lower the number the better the quality. Values around 18 to 22 (you can only use integers BTW) should look good.

XviD Q2 means XviD at a constant quantizer of 2, which is basically an encoding setting. (use search/google for more info)

Sharktooth
24th September 2006, 14:27
Xvid at constant quantizer of 2 is considered by most a "transparent" encoding quality (that means you wont notice almost any difference from the original during playback).
x264 with --crf 18 option is an equivalent of xvid Q2 option.

StephenChow
24th September 2006, 14:44
--crf 18 and --crf 30 parameters both produce the same MP4 filesize.
I don't see any different in quality between --crf 18 and --crf 30:confused:
I usually backup my DVDs with x264 and save them all to my Harddisk, so my MP4 files don't have to fit on CD or exact filesize.
So, is --crf 18 is an appropriate parameter in my situation?

Thank you,

Sharktooth
24th September 2006, 14:53
Well, it's quite impossible they produce the same filesize... and the same quality...
Can you post your complete x264 command line?

chros
24th September 2006, 17:57
--crf 18 and --crf 30 parameters both produce the same MP4 filesize.
I don't see any different in quality between --crf 18 and --crf 30:confused:
As Sharktooth said: it's impossible.

In MeGUI select a profile for the x264 encode (eg. HQ Slower), then in the Main tab select "Const. Quality" for the "mode", than you can write a value here: "18" . Then you can check the command line (and you should see --crf 18) at the Log tab of megui.

I have created a test encode (a trailer): when I use --crf 14 instead of 18 then the final filesize will doubled ! (eg. 24MB -> 48MB)

StephenChow
24th September 2006, 18:09
Hi Sharktooth, chros

I modified the textbox, perhaps I pressed OK instead of Update button, I forgot.
I think in MeGUI's video profile, Cancel==OK, Update is really OK
Yes, it's impossible.
--crf 22 generates smaller MP4 file than 18
--crf 18 gave me a very good result
However, I noticed there are some little block noises:confused:, but they're really hard to realize. I don't know where they come from? Deblocking in-loop -2;-1 or maybe from the source?
My sources are from retail DVD-9, the quality of these DVD-9 are good but not perfect, because I see some dirty dot:confused: video bitrate is VRB6000+ or even CBR9000Kb/s, if they are photos, I can make it clean by Photoshop with a appropriate plugin, but they're movies.
Which deblocking should I use? -2;-1 / 0;0 or -2;-2? to make MP4 as sharpness as the source?

Yes, chros, in my circumstance, --crf 18 creates MP4 files which are 2 times larger than files created by --crf 22

Thank you

Sharktooth
25th September 2006, 13:37
the lower the deblocking values the higher the sharpness (and chances of get blocks on the video).
0:0 is the default and returns the best PSNR but the image is a little blurry. -1:-1 is usually good, as well as -2:-1.
Remember also the deblocking is adaptive and you DONT have to change it in function of the quantizer (or CRF, or bitrate) value.