PDA

View Full Version : VBR and ABR


Lele-brz
21st September 2007, 17:21
Hi,
I wanted to make some test using H264 encoding with VBR.
Is there some free encoder that can encode with VBR?
Can x264 support it?

Another question what's the difference between ABR and VBR?

Thanks in advance for any help
bye

foxyshadis
21st September 2007, 17:58
These are terms that have multiple definitions, so there's no way to answer your question (except to say that x264 includes all the common rate-control options). The most common definitions are:

CBR: Rate is constant over a very short window, usually less than a second, sometimes as little as one frame. 1-pass.
ABR: Rate is constrained between a minimum and maximum level, and often is kept close to the nominal bitrate to handle surprise complexity. Sometimes it's just CBR with a very long window. 1-pass.
VBR: Rate can fluctuate between zero and infinite, practically, as long as it converges at the end. Aimed at keeping a steady quality level (quality fluctuates a lot in the other two). Usually 2-pass.

However, VBR also very commonly means no specified bitrate at all, rather a quality level that can come out to be any size. In that case ABR can mean what VBR does above.

These terms aren't used at all in x264 because of that ambiguity.

ggf31416
21st September 2007, 18:22
ABR means Average Bitrate. The bitrate can fluctuate depending on the complexity of the source but the encoder attempts to obtain a target bitrate. ABR can be 1-pass, 2-pass or 3-pass. In a 2-pass encode the 1st pass analyses the source, so the 2nd pass can distribute the bitrate more efficiently and obtain a bitrate very close to the target. 3-pass allows slightly better bitrate control but it's seldom used.

VBR means Variable Bitrate. The bitrate flutuates in orden to obtain a constant quality. There is not target bitrate, so it's only 1-pass. If a VBR mode has a target bitrate/filesize then it's not actually VBR, it's ABR. In x264 you can choose between CQ and CRF. CRF (Constant Rate Factor) is recommended.

Lele-brz
30th September 2007, 20:32
Thanks for answering,
so I was wondering if there's a way to have a VBR (since ABR seems to be the default when using --bitrate) and specify an average bitrate on the entire video, let's say around 600 kbps.
Since when using VBR in x264 there's no way to specify bitrate, or am I wrong?

thanks again
Bye

Dark Shikari
30th September 2007, 20:38
Thanks for answering,
so I was wondering if there's a way to have a VBR (since ABR seems to be the default when using --bitrate) and specify an average bitrate on the entire video, let's say around 600 kbps.
Since when using VBR in x264 there's no way to specify bitrate, or am I wrong?

thanks again
ByeWhat do you mean? That's like saying "I want to have a flying vehicle made of aluminum with jet engines, but I want a car." You're asking for exactly what ABR does, but in the guise of VBR, which doesn't do that. The entire point of VBR is that you don't specify bitrate.

ggf31416
30th September 2007, 20:45
Thanks for answering,
so I was wondering if there's a way to have a VBR and specify an average bitrate on the entire video, let's say around 600 kbps.


What you are describing is a 2 passes ABR

Lele-brz
1st October 2007, 09:39
yes, but if I do that when I check the bitrate (using Avinaptic graph) I don't see big peaks correspondig to high motion scenes.

Here my two pass:

pass1:
--bitrate 600 --no-cabac --progress --no-psnr --subme 1 --analyse none --me dia --ref 1

pass2:
--bitrate 600 --no-cabac --analyse p8x8,b8x8,i4x4,p4x4 --subme 6 --progress --no-psnr

What I would like is to have much bitrate on high motion scenes and less bitrate on static not complex scene.

thanks for any help in advance

Bye

Dark Shikari
1st October 2007, 09:58
yes, but if I do that when I check the bitrate (using Avinaptic graph) I don't see big peaks correspondig to high motion scenes.

Here my two pass:

pass1:
--bitrate 600 --no-cabac --progress --no-psnr --subme 1 --analyse none --me dia --ref 1

pass2:
--bitrate 600 --no-cabac --analyse p8x8,b8x8,i4x4,p4x4 --subme 6 --progress --no-psnr

What I would like is to have much bitrate on high motion scenes and less bitrate on static not complex scene.

thanks for any help in advance

Bye
That's because you never actually declared your commands to be pass 1 and pass 2 :p

You need --pass 1 for the first pass and --pass 2 for the second.

burfadel
1st October 2007, 10:12
yes, but if I do that when I check the bitrate (using Avinaptic graph) I don't see big peaks correspondig to high motion scenes.

Here my two pass:

pass1:
--bitrate 600 --no-cabac --progress --no-psnr --subme 1 --analyse none --me dia --ref 1

pass2:
--bitrate 600 --no-cabac --analyse p8x8,b8x8,i4x4,p4x4 --subme 6 --progress --no-psnr

What I would like is to have much bitrate on high motion scenes and less bitrate on static not complex scene.

thanks for any help in advance

Bye

Those settings are far from ideal... they're too the point where you may be better off using Xvid! Disabling CABAC is a very bad idea, there's little use setting subme to 6, disabling cabac etc etc. What use are you using the encoded file for? if you're using such low settings for decode speed, unless there's a specific reason to use h.264 then xvid would be better. Are you encoding using that to be compatible with the incorrect Quicktime implementation of h.264 (it isn't a proper implementation)?

Dark Shikari
1st October 2007, 10:18
Those settings are far from ideal... they're too the point where you may be better off using Xvid! Disabling CABAC is a very bad idea, there's little use setting subme to 6, disabling cabac etc etc. What use are you using the encoded file for? if you're using such low settings for decode speed, unless there's a specific reason to use h.264 then xvid would be better. Are you encoding using that to be compatible with the incorrect Quicktime implementation of h.264 (it isn't a proper implementation)?Eh, those settings are still quite a bit better than Xvid at that bitrate, IMO.

If he's disabling CABAC I assume its for an iPod or such.

Lele-brz
1st October 2007, 10:44
thanks for the answers,
well I use --pass1 and --pass2 and also the stat and output file, I removed them for clarity.

Basically this are the settings used by StaxRip for a baseline profile. I wanted to have a quicker time for encoding and also I'm using the resulting mp4 (h264+aac) for a kind of streaming.
So I wanted low header size (the metadata needed to start playing the video).

Now I'd like to use VBR for testing if it can give me better results on high motion video, but I don't know how to use this with x264.

thanks

imcold
1st October 2007, 16:05
What I would like is to have much bitrate on high motion scenes and less bitrate on static not complex scene. The ratecontrol is doing the contrary: lowers quality (higher qp) at high motion/compex scenes, because you can't spot the slight quality decrease there, and highers (lower qp) quality in low motion/less complex scenes, where you can spot decreased quality easily. Other way it would lower the subjective quality of video. Fixed QP would do almost what you want though: high bitrate in complex scenes, low bitrate at static.

Lele-brz
1st October 2007, 16:11
thanks for that,
but how can I be sure that the bitrate doesn't exceed a fixed maximum bitrate in x264?
thanks

Dark Shikari
1st October 2007, 16:14
thanks for that,
but how can I be sure that the bitrate doesn't exceed a fixed maximum bitrate in x264?
thanks
--vbv-maxrate

Lele-brz
2nd October 2007, 15:08
thanks again,
so what would I have to change in my parameters to have a VBR that can fluctuates between 300 and 800 kbps, keeping the entire average at 600 kbs?
Maybe 3 passes?

thanks for any tips on that in advance?

Dark Shikari
2nd October 2007, 16:06
thanks again,
so what would I have to change in my parameters to have a VBR that can fluctuates between 300 and 800 kbps, keeping the entire average at 600 kbs?
Maybe 3 passes?

thanks for any tips on that in advance?
--bitrate sets the average, --vbv-maxrate sets the max, however there is no min. 3 passes is generally completely unnecessary.

Sagittaire
2nd October 2007, 16:29
--bitrate sets the average, --vbv-maxrate sets the max, however there is no min. 3 passes is generally completely unnecessary.

max bitrate must be always use with buffer. If you you want strict local max bitrate you must set the buffer at 0.

Lele-brz
2nd October 2007, 16:57
thanks,
you mean

vbv-bufsize 0 ?

no suggested settings on qpmin and qpmax

thanks again

Lele-brz
3rd October 2007, 13:35
Hi,
I tried adding --vbv-maxrate 500 to my two pass encoding but analyzing the result with avinaptic graphs on bitarate I have the same result.
Is there some other parameter to enable VBR?
thanks

foxyshadis
3rd October 2007, 19:59
What do you mean? VBV doesn't have anything to do with enabling VBR, it creates constrained VBR. How about you tell us exactly what you want the codec to do, instead of a vague term like VBR, and we'll let you know.

If you want to use VBV you have to decide how long of a spike you can tolerate, and what kind of buffering is used at the client. Typical for streaming is half a second to a few seconds; to get the vbv-bufsize you can multiply the time by the bitrate. This is useful when you don't have a hard buffer limit.

And you know avinaptic's main bitrate graph is not useful for checking bitrate at any point, you must use the drf graph (with the period set to the same as your vbv length, in frames)?

sagittaire, what is the precise definition of "strict local max bitrate"? No frame can be larger than bitrate/framerate?

akupenguin
3rd October 2007, 20:06
x264's vbv algorithm just doesn't work on the scale of a single frame. bufsize=0 means vbv is disabled, and if it's nonzero the min value is 3 frames.
If anyone wants to implement constant size frames, forget about using B-frames or small GOP.

Lele-brz
4th October 2007, 09:18
Hi, thanks foxyshadis for answering.
Basically I'd need to test a different encoding than the one I'm using taking advantage of the Variable Bitrate.
What I'd like to have is an encoding where on fast motion I have a higher bitrate and on steady scenes a lower bitrate.
This is hopefully for increasing the perceived quality wihtout raising the average bitrate of the entire video.
So I was wondering what kind of parameter I have to set on x264 to have a total average of 600 kbps with peaks up to 1000 kbps.

Is there some free tool to analyze the distribution of the bitrate along the encoded video?

thanks for your help

Dark Shikari
4th October 2007, 09:21
Hi, thanks foxyshadis for answering.
Basically I'd need to test a different encoding than the one I'm using taking advantage of the Variable Bitrate.
What I'd like to have is an encoding where on fast motion I have a higher bitrate and on steady scenes a lower bitrate.
This is hopefully for increasing the perceived quality wihtout raising the average bitrate of the entire video.
2-pass bitrate, CRF, and QP modes will all do what you describe... this is the default behavior of x264, and is extremely difficult to avoid occurring.

Lele-brz
4th October 2007, 09:45
thanks, sorry to bother again, so what parameters should I set on my 2 pass encoding?

And is there a utility to show the bitrate of the encoded video, using Avinaptic it seems it's a constant bitrate.

thanks again

Dark Shikari
4th October 2007, 09:47
thanks, sorry to bother again, so what parameters should I set on my 2 pass encoding?

And is there a utility to show the bitrate of the encoded video, using Avinaptic it seems it's a constant bitrate.

thanks againYou need to specify --pass 1 --bitrate number on the first pass and --pass 2 --bitrate number on the second... seriously its not that hard.

Lele-brz
4th October 2007, 10:04
ok, here my exact command lines, so you mean I already do what I need? The thing is that if I check the bitrate graph with Avinaptic the bitrate seems constant always close to 530.
thanks again


--pass 1 --bitrate 530 --stats "test.stats" --threads 2 --progress --no-psnr --subme 1 --analyse none --me dia --ref 1 --output NUL "video.avs"

--pass 2 --bitrate 530 --stats "test.stats" --threads 2 --analyse p8x8,b8x8,i4x4,p4x4 --subme 6 --progress --no-psnr --output "video.h264" "video.avs"

Dark Shikari
4th October 2007, 10:08
ok, here my exact command lines, so you mean I already do what I need? The thing is that if I check the bitrate graph with Avinaptic the bitrate seems constant always close to 530.
thanks again


--pass 1 --bitrate 530 --stats "test.stats" --threads 2 --progress --no-psnr --subme 1 --analyse none --me dia --ref 1 --output NUL "video.avs"

--pass 2 --bitrate 530 --stats "test.stats" --threads 2 --analyse p8x8,b8x8,i4x4,p4x4 --subme 6 --progress --no-psnr --output "video.h264" "video.avs"
That's because x264 is smarter than you and generally knows better than you do where to distribute bits for maximum quality. If it thinks a high-motion scene doesn't actually need more bits, it won't give it more.

If you are still curious, you can upload the .h264 file to a file hosting site like Mediafire and I'll check it out with Elecard Streameye.

bkman
4th October 2007, 11:18
thanks, sorry to bother again, so what parameters should I set on my 2 pass encoding?

And is there a utility to show the bitrate of the encoded video, using Avinaptic it seems it's a constant bitrate.

thanks again

Use the newest version of Avinaptic and check the frame-size graph after doing DRF analysis.

Lele-brz
4th October 2007, 12:07
ok, you can find my h264 here:
http://www.mediafire.com/?9dfyjxle4xq

It's generated from an mpeg2 with bitrate around 4 Mbps

thanks for any tips on that

bkman
4th October 2007, 13:13
http://i23.tinypic.com/52l8qx.png

Does that look like CBR to you..? :rolleyes:

Lele-brz
4th October 2007, 14:55
:thanks:
so I was already having the result I want, the thing is that I trusted the bitrate graph by Avinaptic, I don't know what on th Y-axis on the second graph you sent, so I don't know what's 35273.
I don't think it's the bitrate since my encoding used 530kbps.

Is there some other free tool ro check the bitrate distribution on a video track?

thanks again for your help

bkman
4th October 2007, 15:31
:thanks:
so I was already having the result I want, the thing is that I trusted the bitrate graph by Avinaptic, I don't know what on th Y-axis on the second graph you sent, so I don't know what's 35273.
I don't think it's the bitrate since my encoding used 530kbps.

The y-axis is the size of each encoded frame in bytes. Multiplied by 8, each frame makes up 1/framerate of the bit distribution of each second.

The reason the Avinaptic bitrate graph looked like CBR was because it was a cumulative average rather than a local one. You should read the details before jumping to conclusions.

And as I said, since fsinapsi was kind enough to implement it, you can now use the new version of Avinaptic to examine the bitrate distribution by way of the frame-size graph. That is where my screenshot came from.