Here, I’m taking a look at various RF settings in Handbrake, both in terms of visuals and filesize.
I started with encodes from the “24” DVD (Season 6, Episode 1). If you have the same DVD and are looking to reproduce this test, the following settings were used:
- x264 Preset: very slow
- x264 Tune: none
- x264 Profile: high
- x264 Level: 4.1
- Strict Anamorphic
- Defaults for everything else (Handbrake 0.9.9 on OSX)
I tested the following RF values (listed in Handbrake under “Constant Quality”:
0, 10, 18, 20, 22, 24, 26, 28, 30, 32
VISUAL COMPARISON
I’ll start with a few screenshots at different RF values. There’s a video below too, but it comes with a bit of a caveat so might not show everything well for you. Pictures should work for nearly everyone. Note that the first one (RF0) is for reference (lossless).
Worth noting that x264’s psychovisual enhancements (trellis, etc) do a pretty good job of keeping detail where you’d notice it (the face), at the expense of the stuff you normally wouldn’t notice while watching (like those background areas). Of course, this only goes so far – once the RF value is high enough, there’s no saving Jack’s facial features from the effects of compression!
For those interested, I’ve also got another page on this site that lets you compare x264 vs x265 vs VP8 vs VP9 (at various RF and bitrate settings).
A static image isn’t always great, so here’s the 35-second video I made showcasing the difference between these RF settings in “24”. Note that you must click the appropriate buttons to watch this at full-screen 1080p if you want to see the differences somewhat clearly: https://www.youtube.com/watch?v=YicJVl1J2oE.
Note that YouTube re-compresses videos – I kept it at full-quality as long as I could, but I suspect YouTube won’t be fine with serving up a 360MB video that only lasts 35 seconds, so we’re at the mercy of their encoder.
FILE SIZE COMPARISON:
Now that you hopefully have an idea as to how each of the videos look, let’s see what each weighed in at for the full 43m8s episode. Note that these sizes ONLY apply to this episode of this source :
RF:0 – 6127.2MB (yes, 6.1GB)
RF:10 – 1925.2MB (yes, 1.9GB)
RF:18 – 355.6MB
RF:20 – 254.6MB
RF:22 – 197.3MB
RF:24 – 160.4MB
RF:26 – 136.1MB
RF:28 – 119.6MB
RF:30 – 107.5MB
RF:32 – 98.3MB
THE TAKEAWAY
A few things you probably observed when comparing to RF:0 (the lossless version):
- RF10 looks almost identical to RF0 in the images, but still results in a massive file size – quite possibly similar to the size of your source. At that point, you’re probably better off keeping your original source rather than trying to recode it.
- RF18-20 are incredibly close in the images, and it’s pretty hard to tell the difference when it comes to watching the video. The reductions in file size here tend to be substantial though, almost 100MB smaller (28% savings) by going from RF18 to RF20.
- RF22-24 is about the point where visual differences are starting to become noticeable, but typically not to the point where they’d stand out when you’re actually watching. You save under 40MB (19%) by dropping from RF22 to RF24 here.
- RF26-32 is where noticeable degradation comes about. It’s a matter of how much you can tolerate at this point. You really start to lose a lot of quality for each bit of filesize you try saving. Dropping the RF value by 2 saves under 20MB (9-12%), and the video is noticeably worse.
All that said, be sure to draw your own conclusions. And if you’re new to encoding with Handbrake, hopefully this has helped you to get a better understanding of the Constant Quality setting and the effects of various RF values.
Will changing the value of H.264 Profile and H.264 Level have any noticeable difference in the video quality?
It usually* shouldn't affect the quality you see (assuming you're using RF values). File sizes may change though, particularly if you're mixing it with slower settings - lower profiles/levels will often result in bigger files, whereas higher profiles/levels will often result in smaller files.
*NOTE: There are exceptions. For example, quality might plummet if you choose a level that's too low for your source at the RF value you've chosen. An easy way to see an extreme example of this is to encode a 30 second DVD clip at RF18 (which would normally look good), but use something like main profile level 1.0. You'll see massive blocking, because the bitrate is constricted by the level/profile. Even though you chose RF18, the low level didn't allow it to use enough of a bitrate.
This sort of thing usually isn't an issue if you're dabbling with DVD encodes at reasonable RF values, and trying to choose between say... Level 3.x and Level 4.x. It's a larger issue if you try to start encoding BluRays at low RF values (high quality) and trying to use a profile of less than 4.x. Regardless, going with the highest profile your device(s) support is usually the safe way to go.
I know that's probably not the definitive yes/no answer you might have been looking for, but I hope that helps.
Is "RF" the same as "--quality" (or -q) in HandbrakeCLI, do you know?
It's hard to give a definitive answer here. I've got another writeup at https://mattgadient.com/handbrake-rf-slower-speeds-craziness/ which shows some of the inconsistent behaviour across the x264 presets. On top of that, I believe there might be (don't remember for sure...) a difference in which psychovisual enhancements are enabled as you move to slower settings. Also, as you move to lower x264 profiles/levels, it's possible to end up bitrate constrained at lower RF values which can throw a wrench into things if you move to faster presets that tend to use higher bitrates.
All that being said, each source behaves a little differently (as you'll see in the other writeup), so while it might be possible to test each speed on a source and determine that "X" speed gives the best quality at an "X" RF value for "X" source (assuming your eyes are keen enough to spot the small differences - mine certainly aren't), that determination wouldn't always hold true for other sources.
Extremely Helpful
https://trac.handbrake.fr/wiki/ConstantQuality https://trac.handbrake.fr/wiki/x264VideoSettings
If I choose RF - 0, it gives me the file which is bigger than my bluray .. lol
Can somebody suggest please?
I just want the black bars gone. thats all
Removing them is often a good idea - ignoring the minor size and technical benefits for the moment (you can often squeeze an extra reference frame in, for example), it removes the potential for extra pillar-boxing, letter-boxing, or postage stamping when played across various screen aspect ratios and devices.
Sorry for my poor english.
no-fast-pskip:no-dct-decimate
Just stick that in the "Additional Options" box. Only one of those is actually needed, but for the life of me, I can never remember which.
If that isn't enough to take care of it, then throwing an immense amount of bitrate at the encode by changing the RF value (as you mentioned) is the only way I know of to do it.
Good luck!
If all you want is to remove the black bars with no size increments in the resulting file, you can try doing some video crop using MKVToolNix.
Simply go to the "Edit Headers" section, and you can set how much "crop" do you want to apply to the file.
That will crop the black bars in the video file without touching the file size.
Make sure you do a copy of the file before trying this option.
Hope this help.
Did you happen to take note of times (even rough will do) it took to run at different RF settings ?
The RF:0 result effectively doubles as a "before" screenshot (lossless), and you can consider all the others to be "after" screenshots.
Video duration/length was mentioned in the write-up (43m8s). As to the original file size, the episode was slightly under 2GB. That said, don't focus too much on those particulars: as I mentioned in the write-up, the results are only applicable for this source. The trends you see above tend to apply across sources. Specifics on the other hand are an entirely different story... loosely correlated at best.
kind regards
Victor
Taking your images to compare them via photoshop was very interesting as well.
Like: Make to layers RF18 and RF 20 and keep on as normal and divide that through the other. It shows pretty well how much bits have changed where.
Looks like this.
Quite enlightening.
https://uploads.disquscdn.com/images/3b431942187cac63dc631643cac7a20f1841542f887f9a7a1b08adc826983741.png
I think the idea is to shrink the original file and still have the best possible quality. At what point does the average person start to notice? I think a value of RF of 18 should be standard for everything and of course level 4.1 H.264 high and constant frame rate - Why would one want to choose variable frame rate, isn't the source frame rate constant anyways?(at least for tv shows or movies)
When it comes to DVD, you'll run into a lot of stuff that was shot in 24 fps and telecined to 30fps (NTSC regions). This is trickier to handle with a CFR (constant frame rate)... if the deteleciner works perfectly you could set a constant of 24fps. But often the deteleciner won't catch everything so you'll have some parts that remain at 30 fps... by setting a CFR of 24fps you'll end up with some dropped frames. Of course if you set the CFR to 30fps, you'll end up with duplicated frames instead (and perhaps a larger file).
To a lesser extent, variable can also save you from shooting yourself in the foot by setting the wrong frame rate. Not just dealing with telecined content, but interlaced too. If your input video is 1080i60, it's 60 fields (consisting of half frames) per second. So do you use 30fps or 60fps after it's deinterlaced? If using the "bob" deinterlacer probably 60fps. But if using blending/interpolation (default filter) then... maybe 30 or maybe 60? Was the original shot in 30fps and interlaced to 60fps for ATSC distribution? Or was it actually shot at 60fps and half the lines in each field simply dropped?
There are a number of other possibilities too, but VFR is nice because it'll catch everything and generally make a sensible decision, especially if you don't know the details behind how your original source video was constructed.
Not that you can't use CFR if you prefer. But unless you know your original video is very straightforward (shot + distributed in the same frame rate, no telecining, no interlacing, no injected content at different frame rates, is itself CFR through-and-through), CFR carries a few risks along the way. Since VFR used on a constant source should just hold a constant frame rate anyway (with a VFR flag), there aren't huge downsides to using it in most cases. Big exception would be if you need the output to be constant (using HB as a format converter and video editing afterwards, creating Video DVD, site/service/program that requires constant, etc) - then absolutely you have no choice but to use constant.
https://handbrake.fr/docs/en/latest/workflow/adjust-quality.html
thanks for those great videos on Youtube for Handbrake. As a quite new "fan" of Handbrake I have a question about the compression rates which can be achieved. As a beginner I tried to make a copy of one of my "True Blood" BluRays. Episode No. 1 when copied with MakeMKV is about 11GB big with all the DTS Soundfiles,
I tried various settings but the file size after compressing not seem to get any smaller than 2,6 GB, which is don´t get me wrong great. I wanted to try to make copies for my external harddrive to use with KODI and thought about a filesize around 1GB. Do you have any thoughts on that? Thanks ;-)
If using RF values, raising them should reduce the final output size: however it's hard to know what the final output size for any specific RF would be on different sources so you'd have to experiment with values. Since you already have a good idea as to size you want though, you could feasibly use bitrate instead of RF: find a bitrate calculator online and you can experiment with numbers here (a quick search for "video bitrate calculator" currently brought up https://www.dr-lex.be/info-stuff/videocalc.html as the first result, which looks suitable enough). Using bitrate instead of RF really makes sense when you've got a target filesize in mind. Generally do a 2-pass encode here - a fast first pass is fine unless you absolutely have to hit an exact output size.
Keep in mind that at some point the audio bitrate can become a limiting factor (you'd want to include this in the bitrate calculator).
Once you've got that sorted, if you start to see massive quality drops you may end up having to consider resizing the resolution of the ~1GB copy to something like 720p (or even 480p if you're really bitrate-starving the video).
Good luck!
I'm ripping a set of short 1940s b/w films, all 15-minutes in duration, from two DVDRs.
In all my HandBrake rips hitherto, I normally use the "Average Bitrate" option, set to 2500 kbps. (I know that in some cases this may create a higher bitrate than is necessary, but I like to keep the quality as high as possible. And for that reason, I always do two-pass too.)
However with these old b/w films I suspected that these might be prime cases for a sensible lower bitrate without appreciably losing quality, so I decided to try HandBrake's "RF" Constant Quality setting - which also has the advantage of only doing a single-pass. I set everything to RF 22, but was surprised to see that the range of video bitrates for the short films emerging from one disc was 1288 to 1863, and on the other disc an even greater range of 1071 to 2901. I hadn't expected such wide ranges. The films were made broadly speaking at the same time (1940s and 1950s), and by the same people. Is it right that the variation should be so wide?
Is there any way to 'preview' what the kbps will be when using the RF setting? I was trying to make this simpler by using the RF setting, but it looks as if it might have been better if I had just done what I usually do - rip everything two-pass with "Average Bitrate" set to 2500kbps.
Personally I don't mind the encode time so much, and I always use the "Very Slow" preset. Efficient filesize is nice, but quality is really my priority.
I don't really understand what the RF setting does, or how it works. I'd be happy to use it, and let the bitrates fall where they may, if I felt that I knew what the optimum setting was for any given encode. But it always feels a bit random to me, and I don't like that.
How does RF work differently to "Average Bitrate"? Here's a question I'd love to understand: if I rip a film using "RF", and I then re-rip the film setting the "Average Bitrate" to exactly the figure produced by the RF encode, will the two encodes be directly comparable?
Thanks!
As to the varied range you saw, this isn't uncommon. Even in a TV series it's possible to get large variation between episodes using RF. Sometimes they used different cameras (and a noisier camera will end up using more bitrate to store that noise). Other times you'll get more motion/fast-paced action or quick scene cuts in 1 video than another (which again requires more bitrate).
The notion with RF is that if you use the same setting across videos, visually the quality between them should be pretty similar. Or at least in the same ballpark. Assuming your videos looked pretty consistent while watching despite the varied output bitrates, chances are everything behaved as expected.
You could of course simply continue with your 2500kbps average bitrate encodes (though Turbo 1st Pass is sufficient if you don't need the end bitrate to be exact). If you're happy with the results across-the-board and disk space isn't an issue, there's not necessarily any reason to change. "As long as you are happy with the result" is usually the one and only qualifier unless you're encoding something for wider distribution (indie films, family videos, etc).
As for the RF/ABR back-to-back test you mentioned at the end, they'd probably be quite close. But my suspicion is that encoding every frame/scene at a specific RF is done on the backend quite differently than taking a bitrate budget and trying to dole it out between heavy/light scenes. So I wouldn't be surprised if you saw wider variation around the simple scenes and/or complex scenes. But I don't know for sure, or to what extent. I suppose you could severely bitrate starve a couple test encodes to make any effect extremely obvious, and get a better idea that way.
I took one of the "RF" encodes as a benchmark sample, and I then made a second encode of it from the same source, but this time using the "Average Bitrate" option, entering exactly the figure that had been produced by the "RF" encode. All other settings were identical. The encodes ended up a similar filesize, but not identical. (The original RF encode had produced a video bitrate of 1535 kbps and a filesize of 213 MB; the second encode, where I set the Average Bitrate manually to 1535 kbps, had a filesize of 210 MB.) So it does indeed seem that something else is happening during the encoding process.
Am I happy with the results? Well, I can see the differences when I pause and compare identical frames. But perhaps that's not a meaningful approach to take when viewing is the goal (as opposed to extracting screenshots). I don't understand what RF does, or how to make meaningful comparisons between one RF encode and another. (In addition, to add further uncertainty, I encode on my computer but watch on my TV in another room, so all visual checks at the encoding stage are done on a different screen to the target 'viewing' screen.)
I'd just like to understand more about how the processes work - what's actually happening when I choose RF instead of AB - so that I can be confident that I'm producing sensible decent quality encodes, which are not under-ripped but also not bloated. Maintaining quality is more important to me than producing the tiniest possible filesizes. I don't really mind about the encoding time - as long as I'm confident that the settings are optimum and the result will therefore be pretty much as good as it could be. So I'm happy to compromise there, and use the "Very Slow" setting to try to keep the filesizes down while allowing good quality. I am only talking about DVD rips, not blurays. Is there a standard 'range' for video bitrate that one should aim for when doing DVD encodes?
What puzzles me about RF is what the scale actually means. How is it calibrated? It's just a string of 52 points on a scale (including zero) (or 208 points if using the decimalised option scale), with no definitions given at all. It feels too random to me. What do the numbers mean exactly?? How do they relate to each other?
Thanks again!
For some of the deeper details you'd likely have to head to one of the major encoding forums where a few people tend to know all the ins and outs, find an x264 dev willing to field an explanation, or browse through the source code to see exactly what's taking place. If you go the source-code route, obviously check the version of x264 you're using as encoders sometimes make substantial changes (for example, x265 rebalanced their RF scale once upon a time).
If you haven't yet, you may want to make use of the encoder comparisons I have at https://mattgadient.com/x264-vs-x265-vs-vp8-vs-vp9-examples/ and https://mattgadient.com/results-encoding-8-bit-video-at-81012-bit-in-handbrake-x264x265/ (while they're still up anyway... next time the server dies I don't know if I'll dig through my backups to restore that tool). In addition to comparing RF18/20/22 you can toy with various presets (the first link also has 480p/1080p). It might give a little more insight as what RF value your comfort level sits around.
With that said, you'll really want to do a few test encodes of whatever source you're using - encoders have also changed since this stuff was written (some more than others). Even a couple 2 minute samples at the 2 RF values you're considering is usually worthwhile as a quick sanity check in terms of settings.