Log in

View Full Version : H264 2-Pass Encoding: VBR or CBR?


cesm23
20th September 2008, 18:43
Hi.

I've been using x264 vfw, an encoder that can be used in VirtualDub.
It took a while before i knew what i was doing but i finally managed
to learn how to work with it...

My question is about the 2-pass encoding.
I have these options in Multipass mode:

1. 1st Pass
2. 1st Pass Fast
3. 2nd Pass

I've been encoding anime straight from the original VOB files and i've been using
the 1st Pass (Slow mode) and the Second Pass. I had to enter a target bitrate. I chose 1500.

Almost every video has the same duration, but the scenes are completely different.
Yet, all of the videos end up with the same size (about 230Mb), so i wonder if the
2-Pass mode is CBR or VBR, since i first thought that sizes would vary because
some episodes have more movement than others...

I know that the video will have no blocks (even on smaller bitrates) but if it is CBR
i'm worried that scenes with more movement may loose detail because of that.


Thank you.

akupenguin
20th September 2008, 19:16
Simple arithmetic: bitrate*duration=size. The episodes are all the same size because that's what you asked for when you selected a bitrate.
2pass is VBR. But if you want total episode size to vary according to complexity, you should be using 1pass CRF, which is also VBR but without the size constraint.

Ranguvar
20th September 2008, 19:17
2-pass is VBR. Yes, you end up with an average bitrate of 1500, but the encoder is free to choose what bitrate to give which scenes.

As for x264 VfW, I highly recommend you switch to the CLI x264 (there are many nice GUIs: RipBot264, AviDemux (similar to VDub), StaxRip, AutoMKV, HandBrake, MeGUI, XviD4PSP (don't let the name fool you), etc.). VfW and H.264 don't mix well at all. Search this forum to find evidence. :)

kemuri-_9
20th September 2008, 19:41
@akupenguin, there are some options that can have x264 perform in CBR mode iirc,
is it just aq-mode=0, bitrate RC, and qcomp=0, or was there more requirements?

cesm23
20th September 2008, 19:48
Hi again.

Thanks for the replies.

I'm interested in that option "1pass CRF" but i don't know how it works and if it is worst than the option i'm using now. Any Advice please? What settings do you recommend for Anime Encoding with a size between 200 and 220 Mb?


Thanks for all the help.

akupenguin
20th September 2008, 20:00
aq-mode=0
Unnecessary (or so Dark Shikari assures me; I haven't personally tried CBR recently).
bitrate RC
Unnecessary, you can use CRF with VBV. Sure the result is capped bitrate rather than constant, but ABR+VBV doesn't strictly prohibit bitrate undershoot either.
qcomp=0, or was there more requirements?
VBV is supposed to work without this, though qcomp=0 does reduce the strain on VBV at a cost of reduced quality.

Ranguvar
20th September 2008, 20:27
Hi again.

Thanks for the replies.

I'm interested in that option "1pass CRF" but i don't know how it works and if it is worst than the option i'm using now. Any Advice please? What settings do you recommend for Anime Encoding with a size between 200 and 220 Mb?


Thanks for all the help.

If you're targeting a specific size, don't use CRF. 2-pass is for specific size, CRF is for specific quality :) Generally, --crf 18 results in transparent (visually identical) encodes almost always, but the low 20's are a good place to start. Experiment.

But generally, anime responds well to lots of b-frames, b-adapt 2, and many refs. If lines are getting smudged/blurred, decrease the beta deblocking (--deblock x:y, where y is beta and x is alpha). Increasing alpha deblocking may help avoid blockiness without hurting quality much, since anime is full of solid-color and gradient areas.

If you really want to push the envelope, look in the Current Patches thread for OreAQ....

Dark Shikari
20th September 2008, 20:30
@akupenguin, there are some options that can have x264 perform in CBR mode iirc,
is it just aq-mode=0, bitrate RC, and qcomp=0, or was there more requirements?No, none of those are necessary. AQ-mode 1 used to be helpful, but its no longer necessary (and therefore no longer exists).

cesm23
20th September 2008, 20:33
If you're targeting a specific size, don't use CRF. 2-pass is for specific size, CRF is for specific quality Generally, --crf 18 results in transparent (visually identical) encodes almost always, but the low 20's are a good place to start. Experiment.

But generally, anime responds well to lots of b-frames, b-adapt 2, and many refs. If lines are getting smudged/blurred, decrease the beta deblocking (--deblock x:y, where y is beta and x is alpha). Increasing alpha deblocking may help avoid blockiness without hurting quality much, since anime is full of solid-color and gradient areas.

If you really want to push the envelope, look in the Current Patches thread for OreAQ....

Hi again.

Thanks for the explanation. I think I get it now...but you didn't tell me one thing...which one is better? CRF 1-Pass or VBR 2-Pass? Which one do you use?

Thanks again and sorry for bothering you with all this Rookie Questions...

Dark Shikari
20th September 2008, 20:47
Hi again.

Thanks for the explanation. I think I get it now...but you didn't tell me one thing...which one is better? CRF 1-Pass or VBR 2-Pass? Which one do you use?

Thanks again and sorry for bothering you with all this Rookie Questions...Neither is "better"; what you should use depends on what you want.

If you want a specific filesize for every video, use 2pass. If you don't care about a specific filesize, use CRF.

Sagekilla
20th September 2008, 20:56
One way of thinking of it is 2-pass is CRF with size restrictions.. They're nearly identical visually but 2-pass you can aim for a specific size. CRF, you don't really care what size you're aiming for but you'll get a specific quality.

To simplify:

CRF --> Filesize unknown, quality known
2-pass --> Filesize known, quality unknown.

cesm23
20th September 2008, 21:16
Hi again and again thanks, you've all been a huge help.

I don't like to wait so much time to have a good video quality...because now, with filters it takes 3 hours each pass...it's really annoying really...

So my last question is...can you advise me a good setting for me to use on the 1-Pass Ratefactor? I mean, can you tell me a number that, in your poit of view is good for both Quality and Size?

Thanks again.

Sagekilla
20th September 2008, 21:53
As was stated before, --crf 18 provides fairly transparent results to the original source. Try encoding a sample with crf values from 18 - 25. Compare and find the highest CRF value you can live with. Personally, when I work with SD material I use --crf 18 and --crf 19 or 20 for HD material (mostly because HD tends to be such a cleaner source than DVDs and artifacting is less noticeable at HD).

Also, you're very lucky to have 3 hour encodes. Mine take in excess of 40.

cesm23
20th September 2008, 22:23
Thank you all very much for everything.

Esurnir
21st September 2008, 00:34
For the filters my advice would be to do a first pass losslessly, you just load your .avs with filters, then save the file using huffyuv as the codec. After that just make an avisynth script with only "AviSource("blabla.avi")" in it and it'll accelerate your encoding a lot if you do two pass, if you do 1 pass CRF, I don't think this step is necessary.

Ranguvar
21st September 2008, 18:59
That can provide a speed boost if you're using very intensive AVS filters, but he didn't mention using AviSynth at all...