Specifying bitrate limit in Handbrake (homemade media optimiser)

Hey guys! I’ve researched it but can’t find (or understand) a definitive answer… I’d like to transcode my files using handbrake to optimise my files myself for streaming (while maintaining quality, which media optimiser doesn’t do). How would I set up handbrake to maintain a, say, 3Mbps bitrate and have decent quality? If I go for constant bitrate, then action filled moments will lack bitrate… but if I go variable, I’ll go above the max requested bitrate in peak sequences, no?

Thanks a lot

Sounds like you already know how to do it but don’t like the results. Welcome to our world. :slight_smile:

That’s the problem with forcing a specific bandwidth. When you take a BluRay and use a great encoding quality and a slow preset the encoder will only use the bandwidth it needs. It could be 6Mb or 12mb depending on the scene and speed.

When you put an “artificial” limit on what bandwidth it can use then you will have the problem you are seeing. eg 6Mb of info squeezing into 3Mb of bandwidth. Somethings got to give and it’s call quality. :slight_smile:

Now with that said the results you get pushing it to 3Mb with Handbrake or an ffmpeg with a slow preset and high quality setting will still be much better than the result you’ll get with Media Optimizer or real-time encoding with Plex. Actually the lower the bitrate the more pronounced the difference is.

Carlo

@cayars said:
Sounds like you already know how to do it but don’t like the results. Welcome to our world. :slight_smile:

That’s the problem with forcing a specific bandwidth. When you take a BluRay and use a great encoding quality and a slow preset the encoder will only use the bandwidth it needs. It could be 6Mb or 12mb depending on the scene and speed.

When you put an “artificial” limit on what bandwidth it can use then you will have the problem you are seeing. eg 6Mb of info squeezing into 3Mb of bandwidth. Somethings got to give and it’s call quality. :slight_smile:

Now with that said the results you get pushing it to 3Mb with Handbrake or an ffmpeg with a slow preset and high quality setting will still be much better than the result you’ll get with Media Optimizer or real-time encoding with Plex. Actually the lower the bitrate the more pronounced the difference is.

Carlo

Yeah I think I understand the benefits and drawbacks, I’m just not sure what to do I. A Plex context.

So, just to confirm, being the noob I am, what you’re saying is that to achieve what I’m after I’d have to use constant quality/bitrate, right? With the drawbacks it comes with…

Before going down this road. Do me a favor and give us a more specifics as to what you are tying to do.

Do you have a CPU that supports QuickSync? Do you feel at home with the command line?

In addition to what @cayars already said:

If you are working with a fixed bandwidth setting, the key to squeeze the maximum quality out of the available bandwidth is to:

  • use the ‘high’ encoder profile
  • use the highest ‘Encoder Level’ your device supports
  • enable 2-Pass Encoding
  • Use an ‘Encoder Preset’ as slow as possible

    All of this has the goal to invest a high amount of computing power, to maximize the quality achievable with the given bitrate.

You need also to educate yourself a bit about what “consumes” bitrate.

  • a grainy picture needs way more bitrate than a smooth one
  • slow motions need less bitrate than hectic movements
  • high amount of details needs more bitrate than flat planes of color, hence an animated comic needs way less bitrate than a detailed and razor sharp landscape

Use the denoizing filters of handbrake to make the movie more compression friendly. The downside is: this uses additional computing power.
The ‘NLmeans’ denoising filters are superior in quality to the old ‘hqdn3d’, but require much more computing time.
To find the optimal settings for each movie requires quite a bit of experimenting and collecting experience.

@cayars said:
Before going down this road. Do me a favor and give us a more specifics as to what you are tying to do.

Do you have a CPU that supports QuickSync? Do you feel at home with the command line?

Basically, my PMS runs on a Mac Mini 2011 with an i5-2520m and 8ghz RAM, OSX Yosemite.

My goal is to pre-transcode files to share as I’m limited for upload speed by my ISP (10Mbps), therefore ask my remote client to to limit themselves to 4Mbps.

My Mac Mini being also used for Plex Media Player and sitting g under my TV, I’d lie to pre-transcode my files under 4Mpbs to

  1. Offer Direct play to my remote users

  2. Avoid having the fans spinning at high speed while transcoding for them while I’m watching something.

I believe the CPU supports quicksync, but osx doesn’t as far as I know… Would use bootcamp and switch if it was really worth it (ie. Plex supported it).

I am not very familiar with the OSX command line, but was familiar with DOS back in the day so I have a general idea of what is going on there and could use it.

This is why I asked. If you only have 10Mb bandwidth on your side and your allowing your clients a 4Mb rate then you are only going to be able to support 2 simultaneous clients. Since this is the case I’m not sure I’d go down the pre-transcoding deal. Your CPU should be able to handle this for 2 streams.

The quality won’t be quite as good from the real-time transcoder but you won’t have to give up the extra storage all these 4Mb rips are going to need and you will save HUGE amounts of time in transcoding.

How many people are you sharing with? How often do you have 2 clients transcoding at the same time?

@OttoKerner nailed the HB setup for you above. You really won’t get better advise in such a concise manner as he just gave you/all of us.

Do yourself a favor and give his setting a test. Try it on something you would consider a “normal” movie and then try it on something with fast actions sequences. I typically like to use a Transformer movie (when the cars turn into robots or vice versa). Just to play create a “TestLib” and add these two movies to it.

Now grab your typically client and play your normal version but make it transcode to 4Mb so you can see what these scenes/movies look like when your Mac CPU is doing the real-time transcoding. Then play the same movie direct play from your TestLib and compare.

You’ll then be in a much better shape to make the call what to do. Every system is different so there is no one solution that works for everyone.

Carlo

@cayars said:
This is why I asked. If you only have 10Mb bandwidth on your side and your allowing your clients a 4Mb rate then you are only going to be able to support 2 simultaneous clients. Since this is the case I’m not sure I’d go down the pre-transcoding deal. Your CPU should be able to handle this for 2 streams.

The quality won’t be quite as good from the real-time transcoder but you won’t have to give up the extra storage all these 4Mb rips are going to need and you will save HUGE amounts of time in transcoding.

How many people are you sharing with? How often do you have 2 clients transcoding at the same time?

@OttoKerner nailed the HB setup for you above. You really won’t get better advise in such a concise manner as he just gave you/all of us.

Do yourself a favor and give his setting a test. Try it on something you would consider a “normal” movie and then try it on something with fast actions sequences. I typically like to use a Transformer movie (when the cars turn into robots or vice versa). Just to play create a “TestLib” and add these two movies to it.

Now grab your typically client and play your normal version but make it transcode to 4Mb so you can see what these scenes/movies look like when your Mac CPU is doing the real-time transcoding. Then play the same movie direct play from your TestLib and compare.

You’ll then be in a much better shape to make the call what to do. Every system is different so there is no one solution that works for everyone.

Carlo

Thanks, that makes sense. Still wish I could reduce/control fan noises at the worse moments… Then again, that might be reason enough to pull the trigger on a 2nd shield tv and move my server downstairs.

I’m sharing with 3 users right now, wish I could do more, but I’m limited by my upload speed and the lack of a max upload speed setting in PMS… But that’s for another thread :wink:

I’ll try the settings posted by @OttoKerner, but again I’m left wondering with my first question… He selected “average bitrate” and chose 2500… Let’s say I put it at 3500 and my clients to are set for 4Mbps, will that work? Or do I run the risk or having buffering periods because the bitrate spikes (I assume average bitrate means sometimes it will go higher… But how much?)

Thanks a lot guys!

Nice catch. I myself didn’t look at that. Here is where I’d disagree with OttoKerner. I would definitely go for Constant vs Variable. Variable will shift bits around to support the overall average you set. That means for some of the file will be over your setting and some will be under your setting. If you are trying to target a specific bitrate this doesn’t work well. Variable on the other hand is great for creating a file a head of time with a fixed size.

Constant on the other hand will keep you video at or below a specific bitrate. You also won’t be able to calculate the overall size of the file produced (doesn’t matter).

I’d also only go with a 4.0 profile and not 4.1. A few clients will want to transcode if it’s 4.1 instead of 4.0. You won’t give up anything by using 4.0

Sorry didn’t catch those earlier. I use ffmpeg via scripting now to do my encoding and haven’t touched HB in a while.

Carlo

PS googled a bit to find you this page which covers things pretty clearly: https://mattgadient.com/2013/06/12/a-best-settings-guide-for-handbrake-0-9-9/

@cayars said:
Nice catch. I myself didn’t look at that. Here is where I’d disagree with OttoKerner. I would definitely go for Constant vs Variable. Variable will shift bits around to support the overall average you set. That means for some of the file will be over your setting and some will be under your setting. If you are trying to target a specific bitrate this doesn’t work well. Variable on the other hand is great for creating a file a head of time with a fixed size.

Constant on the other hand will keep you video at or below a specific bitrate. You also won’t be able to calculate the overall size of the file produced (doesn’t matter).

I’d also only go with a 4.0 profile and not 4.1. A few clients will want to transcode if it’s 4.1 instead of 4.0. You won’t give up anything by using 4.0

Sorry didn’t catch those earlier. I use ffmpeg via scripting now to do my encoding and haven’t touched HB in a while.

Carlo

PS googled a bit to find you this page which covers things pretty clearly: A “best settings” guide for Handbrake 0.9.9 and 0.10 | mattgadient.com

I can’t thank you enough! Would you happen to have some sort of a guide or scale I could use to translase RF value into actual bitrate value?

I need to apologize. Jumping back and forth through the threads I gave you the wrong info here in the last message. What I said was true but, in order to specify a specific bitrate you need to use the average bitrate setting as circled.

You can also use the --vbv-bufsize AND --vbv-maxrate setting combination to control the overall max bitrate used per buffer so the client won’t exceed the buffer at hand.

Sorry about that.

@KarlDag said:
I can’t thank you enough! Would you happen to have some sort of a guide or scale I could use to translase RF value into actual bitrate value?

This is not possible. You can’t translate RF to a bitrate value.
The RF value is an “allowed difference”, of how much the encoded picture “may” differ from the original. The higher the value, the more the encoding differs (i.e. more “errors” are allowed > the lower the quality) .
How much bitrate this requires, depends on the source video. See my explanation above, about what consumes bitrate.

@KarlDag said:
I’ll try the settings posted by @OttoKerner, but again I’m left wondering with my first question… He selected “average bitrate” and chose 2500… Let’s say I put it at 3500 and my clients to are set for 4Mbps, will that work?

This setting is purely vor the video stream. Don’t forget to factor in the bitrate of your audio stream(s). If you have a DTS-HD track and you leave it in there (‘passthrough DTS-HD’) it will claim 1.536 mbps additionally.

@OttoKerner said:

@KarlDag said:
I’ll try the settings posted by @OttoKerner, but again I’m left wondering with my first question… He selected “average bitrate” and chose 2500… Let’s say I put it at 3500 and my clients to are set for 4Mbps, will that work?

This setting is purely vor the video stream. Don’t forget to factor in the bitrate of your audio stream(s). If you have a DTS-HD track and you leave it in there (‘passthrough DTS-HD’) it will claim 1.536 mbps additionally.

Yeah of course! Wouldn’t keep lossless audio in a 4Mbps file though lol

@cayars I’m curious, why did you ask about quicksync? Did you get it working in Plex? You use it in your scripts? Thought there were issues with the visual quality of the output when using it?

Sorry, never saw this question until it popped up in the new forum.

I was asking because it would be worth testing for real-time use since the Op didn’t want his fan running. :slight_smile: I wouldn’t use it for offline processing as it’s not as good as CPU encoding (but is usually much, much faster).