how to select constant bitrate

HandBrake for Mac support
Forum rules
An Activity Log is required for support requests. Please read How-to get an activity log? for details on how and why this should be provided.
Post Reply
TechnoPhil
Posts: 39
Joined: Wed Nov 02, 2011 9:21 am

how to select constant bitrate

Post by TechnoPhil »

Hi there,
i am not able to select "constant bitrate" on HandBrake!
I do not mean "Constant quality" that creates a variable bitrate!

Can HandBrake encode with constant bitrate?

Thank you! :P
TedJ
Veteran User
Posts: 5388
Joined: Wed Feb 20, 2008 11:25 pm

Re: how to select constant bitrate

Post by TedJ »

Average bitrate, you mean?
TechnoPhil
Posts: 39
Joined: Wed Nov 02, 2011 9:21 am

Re: how to select constant bitrate

Post by TechnoPhil »

No,
i mean constant bit rate.

For example: -b 10000k means everage bitrate for the encoded video, but some scenes will have lower bitrate, othe higher.

Is it possible to choise a fixed bitrate for all ?

Fixed constant bitrate gives a higher quality, average bitrate gives very good quality with less space!
TedJ
Veteran User
Posts: 5388
Joined: Wed Feb 20, 2008 11:25 pm

Re: how to select constant bitrate

Post by TedJ »

I can't say I've ever seen a true CBR video encoder as they would be terribly inefficient.

The reason why you'll see bitrate variations from one scene to another in an ABR encode is that the image complexity and therefore the required bitrate to reach a given quality metric varies markedly from scene to scene. Under those circumstances it makes little sense to allocate exactly the same bitrate to both scenes; it's far better to work from a bit reservoir allocating bitrate as needed while aiming for a target bitrate across the entire encode.
TechnoPhil
Posts: 39
Joined: Wed Nov 02, 2011 9:21 am

Re: how to select constant bitrate

Post by TechnoPhil »

Ok, so a CBR encoding is not useful as a VBR encoding, that's why HandBrake does not use it. Am i correct?
This is the script i am using for the test (handbrake-tff-h264-vbr):

for i in *.mov; do newname=`basename $i .mov`.mp4; HandBrakeCLI -e x264 -b 10000 -r 29.97 --pfr -E faac -B 256 -R 48 -f mp4 -4 -X 1280 -x :tff --loose-anamorphic -m -i $i -o $newname; done

I noticed that also with using ffmpeg is not possible to take a CBR encoding, but only a VBR encoding (ffmpeg-tff-mpeg2-vbr):

for i in *.mov; do newname=`basename $i .mov`.mp4; ffmpeg -i $i -s 1280x720 -b 10000k -aspect 16:9 -r 25 -vcodec mpeg2video -flags +ildct+ilme -top 1 -ac 2 -ar 48000 -ab 256k -threads 4 $newname; done

Thanks you for you answer! :wink:
Deleted User 11865

Re: how to select constant bitrate

Post by Deleted User 11865 »

x264's CBR mode is enabled by setting vbv-maxrate=<bitrate> in the advanced panel (or via the CLI's --encopts option),
where <bitrate> is the same as the selected average bitrate.

You'll also need to set vbv-bufsize, otherwise the maxrate will be ignored
(when in doubt, you may set it to the same value as the maxrate).
TechnoPhil
Posts: 39
Joined: Wed Nov 02, 2011 9:21 am

Re: how to select constant bitrate

Post by TechnoPhil »

Rodeo wrote:x264's CBR mode is enabled by setting vbv-maxrate=<bitrate> in the advanced panel (or via the CLI's --encopts option),
where <bitrate> is the same as the selected average bitrate.

You'll also need to set vbv-bufsize, otherwise the maxrate will be ignored
(when in doubt, you may set it to the same value as the maxrate).
Thanks you for the answer,
i tried:

for i in *.mov; do newname=`basename $i .mov`.mp4; HandBrakeCLI -e x264 vbv-maxrate=10000 vbv-bufsize=10000 -r 29.97 --pfr -E faac -B 256 -R 48 -f mp4 -4 -X 1280 -x :tff --loose-anamorphic -m -i $i -o $newname; done

Am i correct with the syntax? But "mediainfo" tell me:

Overall bit rate mode : Variable
Overall bit rate : 1 303 Kbps

Why? :(
vid.user
Posts: 28
Joined: Tue Dec 18, 2012 9:36 am

Re: how to select constant bitrate

Post by vid.user »

Maybe because you haven't specified the bit rate in that command line!
Deleted User 11865

Re: how to select constant bitrate

Post by Deleted User 11865 »

Because you can't follow instructions? :P
TechnoPhil wrote:
Rodeo wrote:x264's CBR mode is enabled by setting vbv-maxrate=<bitrate> in the advanced panel (or via the CLI's --encopts option),
where <bitrate> is the same as the selected average bitrate.

You'll also need to set vbv-bufsize, otherwise the maxrate will be ignored
(when in doubt, you may set it to the same value as the maxrate).
TechnoPhil
Posts: 39
Joined: Wed Nov 02, 2011 9:21 am

Re: how to select constant bitrate

Post by TechnoPhil »

@ Rodeo

You are right, but be patient, I am only a beginner :D

Now it is working:

for i in *.mov; do newname=`basename $i .mov`.mp4; HandBrakeCLI -e x264 -b 10000 -r 29.97 --pfr -E faac -B 256 -R 48 -f mp4 -4 -X 1280 -x vbv-maxrate=10000 -x vbv-bufsize=10000 -x tff --loose-anamorphic -m -i $i -o $newname; done

But "mediainfo" continues to report this information:

Overall bit rate mode : Variable
Overall bit rate : 10.2 Mbps

Am i correct or mediainfo is sayng the truth? :roll:
Deleted User 11865

Re: how to select constant bitrate

Post by Deleted User 11865 »

You can only specify -x once - multiple options are separated by colons:

-x option1=value1:option2=value2
TechnoPhil
Posts: 39
Joined: Wed Nov 02, 2011 9:21 am

Re: how to select constant bitrate

Post by TechnoPhil »

@ Rodeo

Ok, this is my final script:

for i in *.mov; do newname=`basename $i .mov`.mp4; HandBrakeCLI -e x264 -b 10000 -r 29.97 --pfr -E faac -B 256 -R 48 -f mp4 -4 -X 1280 -x vbv-maxrate=10000:vbv-bufsize=10000:tff --loose-anamorphic -m -i $i -o $newname; done

Mediainfo says:

Bit rate mode : Variable
Bit rate : 9 467 Kbps
Nominal bit rate : 10 000 Kbps

Other problem: i tried to use another codec, mpeg2:

for i in *.mov; do newname=`basename $i .mov`.mp4; HandBrakeCLI -e ffmpeg2 -b 10000 -r 29.97 --pfr -E faac -B 256 -R 48 -f mp4 -4 -X 1280 -x vbv-maxrate=10000:vbv-bufsize=10000:tff --loose-anamorphic -m -i $i -o $newname; done

With this codec i can't obtain an interlaced video "Top Field First" but only progressive. Why?

Forgive me for this questions, but it is a long long time that i am trying to find the solutions by google! :cry:
Deleted User 11865

Re: how to select constant bitrate

Post by Deleted User 11865 »

Different encoder, different options. I have little knowledge of libavcodec options (which are what's used to ffmpeg2/ffmpeg4 encoders).
TechnoPhil
Posts: 39
Joined: Wed Nov 02, 2011 9:21 am

Re: how to select constant bitrate

Post by TechnoPhil »

Rodeo wrote:Different encoder, different options. I have little knowledge of libavcodec options (which are what's used to ffmpeg2/ffmpeg4 encoders).
Ok.. who can help me with ffmpeg2 in your opinion?

Are you shure that using h264 i can create a CBR with the options -b 10000 -x vbv-maxrate=10000:vbv-bufsize=10000 ? Maybe "mediainfo" is wrong...
The file size for CBR and VBR is the same!

Thank you for support! :wink:
TechnoPhil
Posts: 39
Joined: Wed Nov 02, 2011 9:21 am

Re: how to select constant bitrate

Post by TechnoPhil »

@ Rodeo

Am i correct? :?
Deleted User 11865

Re: how to select constant bitrate

Post by Deleted User 11865 »

MediaInfo is not reliable when it comes to detecting variable vs. constant framerate, so it wouldn't surprise me if it had issues with bitrate too.

TBH I don't care.
TechnoPhil
Posts: 39
Joined: Wed Nov 02, 2011 9:21 am

Re: how to select constant bitrate

Post by TechnoPhil »

Ok, that's all!
In any case i prefer VBR!
Waiting for other opinions ...
Thank you! :wink:
Post Reply