What does RF: in constant quality stand for?

General questions or discussion about HandBrake, Video and/or audio transcoding, trends etc.
Julien321
Posts: 27
Joined: Sat Feb 06, 2010 12:52 pm

What does RF: in constant quality stand for?

Post by Julien321 »

Under Video, Constant quality what does RF: and the number 0 to 51 stand for? Also what is Modulus under Pic Settings? On the Advanced page a nice info bubble pops up but no where else.
mduell
Veteran User
Posts: 8187
Joined: Sat Apr 21, 2007 8:54 pm

Re: What does RF: in constant quality stand for?

Post by mduell »

Rate Factor; it's sort of like an average quant to target. 19 - 25 are normal/reasonable values.

Modulus is what you want the dimensions to be divisible by.
Julien321
Posts: 27
Joined: Sat Feb 06, 2010 12:52 pm

Re: What does RF: in constant quality stand for?

Post by Julien321 »

mduell wrote:Rate Factor; it's sort of like an average quant to target. 19 - 25 are normal/reasonable values.

Modulus is what you want the dimensions to be divisible by.
So the higher the RF the more analyst is done on the source before conversion? If a higher RF like 50 is used it would just take longer to encode but would have higher quality playback or does it also result in a higher average bitrate/file size? If the latter what would be the max for an iPad to get the highest quality (unconcerned with file size or encode time) or is it determined by source complexity and therefore case by case?

Also what dimensions are Modulus divided by? Is it the H/V pixel size or aspect ratio? If so what is the formula for deciding which is the best setting for a setting like 1024x768, 1024x576 or 1024x436?

I'm trying to determine the highest quality (regardless of file size or encode time) for an iPad.

Thanks
Deleted User 11865

Re: What does RF: in constant quality stand for?

Post by Deleted User 11865 »

51 is crap, 25 is OK, 19 is excellent, above is a waste.

The RF has an influence on speed but it's minimal. A lower RF will produce a larger file.

1024 x 436 cannot be achieved with modulus 16 (just do the math).
tlindgren
Bright Spark User
Posts: 260
Joined: Sun May 03, 2009 2:14 pm

Re: What does RF: in constant quality stand for?

Post by tlindgren »

Julien321 wrote:So the higher the RF the more analyst is done on the source before conversion?
No, the RF gives the approximate quality it will aim for, to the first approximation the amount of analysis during encoding is determined by the advanced parameters and the output resolution of the video (the increased bitrate caused by a low RF can cause some increase in analysis, it's a secondary effect though).
Julien321 wrote:If a higher RF like 50 is used it would just take longer to encode but would have higher quality playback or does it also result in a higher average bitrate/file size?
RF 50 is low quality, not high, and way outside the "usable" range quoted earlier (19-25). Using a low RF (say 19) will give higher bit-rates/file size than the same source with a higher RF (say 20-25). Note that the resulting bitrate in RF mode is highly dependent on source quality, the better source the smaller the file will likely be at a given size (less noise that it needs to encode).

Normally people here seems to recommend ~20 for DVD resolution source (19-21), while most think it can be increased somewhat on HD media, say 21-23. But if the hardware support high bitrates I've seen RF up to 16-17 used, but I doubt those guys actually compared it with say a RF 18 encode.
Julien321 wrote:If the latter what would be the max for an iPad to get the highest quality (unconcerned with file size or encode time) or is it determined by source complexity and therefore case by case?
The correct way to handle limited decoding capabilities (IE anything hardware) is to make sure you respect their hard limitations and then limit the bit-rate with the two VBV parameters, these describe the max sustained bitrate (kbps) and how much it can be exceeded (as number of bits in a buffer). Keeping the average bitrate below the max sustained then allows the encoder to temporarily exceed the max bitrate to encode action scenes in cases where it's safe (until the VBV buffer is "full"), usually this results in significantly improved quality compared to a constant bitrate encode at max sustained bitrate!

Strictly speaking it should be possible to compute these VBV parameters from the h.264 level and profile the hardware claims to support, but it's rarely that simple. In addition Apple always (?) understates the capabilities of their hardware, often pretty badly, and iTunes often has different set of constrains for allowing synchronization too. So for Apple hardware you either end up with a very conservative (official) figure or someone can try to find out what's really safe. This can be a a long and complicated process, it's been done on the iPod and Apple TV presets but not for something as new as the iPad.
Julien321 wrote:Also what dimensions are Modulus divided by? Is it the H/V pixel size or aspect ratio? If so what is the formula for deciding which is the best setting for a setting like 1024x768, 1024x576 or 1024x436?
Modulus is an optional restriction on H/W pixel count, on the theory that the video encoder is more efficient when fed videos where the H/W count can be divided evenly by this number (usually 16). Some older codecs instead refused to accept videos where all dimensions couldn't be divided by some specific factor (usually 2, 4, 8 or 16).

The x264 developers has claimed this isn't really that important for it any longer, they recommend not using modulus at all (so strict anamorphic or none with modulus 1).
Julien321
Posts: 27
Joined: Sat Feb 06, 2010 12:52 pm

Re: What does RF: in constant quality stand for?

Post by Julien321 »

tlindgren wrote:... But if the hardware support high bitrates I've seen RF up to 16-17 used, but I doubt those guys actually compared it with say a RF 18 encode....

...Modulus is an optional restriction on H/W pixel count, on the theory that the video encoder is more efficient when fed videos where the H/W count can be divided evenly by this number (usually 16). Some older codecs instead refused to accept videos where all dimensions couldn't be divided by some specific factor (usually 2, 4, 8 or 16).

The x264 developers has claimed this isn't really that important for it any longer, they recommend not using modulus at all (so strict anamorphic or none with modulus 1).
Thanks for the 101,
So for now an RF of about 17 to 19 would probably be best quality for the iPad? I could try some test encodes at 15 or lower just to see if the iPad could play them?

Also still not quite understanding Modulus. I use (as most) H.264 and you say Modulus is not needed. I also have Anamorphic: None (since my understanding of Anamorphic* is for DVD's non square pixels that are NA to BD files) and Keep Aspect Ratio checked. When doing this I have a choice on Modulus of 16,8,4 and 2 (no 1 or none). Would 2 be the best choice and 16 the worst? Also am I incorrect in my assumptions for my settings (not using Anamorphic) or am I miss understanding the use of Anamorphic in HB?

* Proper anamorphic is used by encoding (compressing or squeezing vertically) and decoding anamorphic lenses in the film industry (AKA Panavision process).
dynaflash
Veteran User
Posts: 3820
Joined: Thu Nov 02, 2006 8:19 pm

Re: What does RF: in constant quality stand for?

Post by dynaflash »

tlindgren wrote:
Julien321 wrote:So the higher the RF the more analyst is done on the source before conversion?
No, the RF gives the approximate quality it will aim for, to the first approximation the amount of analysis during encoding is determined by the advanced parameters and the output resolution of the video (the increased bitrate caused by a low RF can cause some increase in analysis, it's a secondary effect though).
Julien321 wrote:If a higher RF like 50 is used it would just take longer to encode but would have higher quality playback or does it also result in a higher average bitrate/file size?
RF 50 is low quality, not high, and way outside the "usable" range quoted earlier (19-25). Using a low RF (say 19) will give higher bit-rates/file size than the same source with a higher RF (say 20-25). Note that the resulting bitrate in RF mode is highly dependent on source quality, the better source the smaller the file will likely be at a given size (less noise that it needs to encode).

Normally people here seems to recommend ~20 for DVD resolution source (19-21), while most think it can be increased somewhat on HD media, say 21-23. But if the hardware support high bitrates I've seen RF up to 16-17 used, but I doubt those guys actually compared it with say a RF 18 encode.
Julien321 wrote:If the latter what would be the max for an iPad to get the highest quality (unconcerned with file size or encode time) or is it determined by source complexity and therefore case by case?
The correct way to handle limited decoding capabilities (IE anything hardware) is to make sure you respect their hard limitations and then limit the bit-rate with the two VBV parameters, these describe the max sustained bitrate (kbps) and how much it can be exceeded (as number of bits in a buffer). Keeping the average bitrate below the max sustained then allows the encoder to temporarily exceed the max bitrate to encode action scenes in cases where it's safe (until the VBV buffer is "full"), usually this results in significantly improved quality compared to a constant bitrate encode at max sustained bitrate!

Strictly speaking it should be possible to compute these VBV parameters from the h.264 level and profile the hardware claims to support, but it's rarely that simple. In addition Apple always (?) understates the capabilities of their hardware, often pretty badly, and iTunes often has different set of constrains for allowing synchronization too. So for Apple hardware you either end up with a very conservative (official) figure or someone can try to find out what's really safe. This can be a a long and complicated process, it's been done on the iPod and Apple TV presets but not for something as new as the iPad.
Nice summary of crf based constant quality encoding! Your notes on Apples notoriously conservative specs for their hardware devices (ipod/iphone appletv) devices is well worth noting. Only by individual empirical testing can this be properly proven.

Yes, the iPad is so new that even jbrjake has afaik not really tried to test its full breaking point.

That said, my rule of thumb for *any* dvd source is that an RF of 19.25 (give or take .25) is visually transparent to source. Tested extensively on an atv and 50" panny. The built in presets rf of 20 is so close you *really have to look hard* to see the diff.

Always remember that RF (rate factor) is measured like golf scores ... lower rf values actually represent higher visual quality.
tlindgren
Bright Spark User
Posts: 260
Joined: Sun May 03, 2009 2:14 pm

Re: What does RF: in constant quality stand for?

Post by tlindgren »

Julien321 wrote:So for now an RF of about 17 to 19 would probably be best quality for the iPad? I could try some test encodes at 15 or lower just to see if the iPad could play them?
I wouldn't recommend going below 19 on DVD sources and 20 on 720p or higher.
Julien321 wrote:Also still not quite understanding Modulus. I use (as most) H.264 and you say Modulus is not needed. I also have Anamorphic: None (since my understanding of Anamorphic* is for DVD's non square pixels that are NA to BD files) and Keep Aspect Ratio checked. When doing this I have a choice on Modulus of 16,8,4 and 2 (no 1 or none). Would 2 be the best choice and 16 the worst? Also am I incorrect in my assumptions for my settings (not using Anamorphic) or am I miss understanding the use of Anamorphic in HB?
Anamorphic just means that the output pixel isn't (necessarily) square.
This is used for two things in HandBrake, one is when the original source has a non-square pixel, the other is to get the aspect ratio correct if the Modulus means it has to rescale the output.

Let's take a common example, a Blu-ray movie starting which is encoded in 1920x1080 and with a 1:1 pixel aspect ration. This is my understanding of what's supposed to happen with a Modulus of 16:
  • Anamorphic None: Rescaled to 1920x1088 or 1920x1072 (closest that is evenly dividable by the Modulus, 16), pixel ratio 1:1. The rescaling combined with the 1:1 pixel aspect ration means the output aspect ratio is actually slightly incorrect.
  • Anamorphic Strict: No modulus, encoded at 1920x1080, pixel ratio 1:1. Output has the correct aspect ratio, but compression might be slightly lower.
  • Anamorphic Loose: Rescaled as Anamorphic None but the pixel aspect ratio adjusted so the final output has the correct (original) aspect ratio.
Or at least that's what I think the numbers are supposed to be, the Windows GUI seems to be, ahem, slightly inconsistent in how it applies Modulus and aspect ratios so the result depends heavily on exactly in which order the source is loaded and settings are applied, this sometimes gives surprising resolutions (close but not quite right) instead of the ones I computed, but you can override it if necessary. Not sure if the other GUI's have this issue, my impression from comments from other they're better at this. I may take a look at this later to see if I can figure out what is going on.

Basically, there's a different set of drawback for each setting, if you goal is to encode for Blu-ray you must end up with a resolution on the approved list and a pixel aspect ratio of 1:1 so None is the correct option there (there's also a bunch of other very special options that needs to be set manually). For other purposes either Strict or Loose usually makes more sense if you output device can handle it (and very few can't).

Anamorphic Loose used to be the recommended mode but the pendulum seems to be swinging towards Anamorphic Strict instead, partly due to recommendations from x264 developers (removed comment from source recommending mod-16 resolutions and IIRC said the difference was very small and he'd removed the comment because it had been over-interpreted).

From your description it sounds like you want either Anamorphic Strict or Anamorphic None with Modulus 2 (same result as Strict assuming square input pixels and vertical dimension evenly dividable by 2 which is probably guaranteed). So Strict handles non-square input pixels better assuming your output device can handle Anamorphic output (else you should be using None with Modulus 2).
Deleted User 11865

Re: What does RF: in constant quality stand for?

Post by Deleted User 11865 »

tlindgren wrote:The x264 developers has claimed this isn't really that important for it any longer, they recommend not using modulus at all (so strict anamorphic or none with modulus 1).
AFAIK x264 cannot do mod1, only mod2 and above. So "no modulus" would really be 2.
creamyhorror
Enlightened
Posts: 134
Joined: Mon Jan 04, 2010 2:00 pm

Re: What does RF: in constant quality stand for?

Post by creamyhorror »

Use Anamorphic Strict if your device or player can take it - it results in the best quality of the three. Generally any decent computer player should be fine with it, and standalone players like the WD TV as well. Don't know about Apple devices.
dynaflash
Veteran User
Posts: 3820
Joined: Thu Nov 02, 2006 8:19 pm

Re: What does RF: in constant quality stand for?

Post by dynaflash »

creamyhorror wrote:Use Anamorphic Strict if your device or player can take it - it results in the best quality of the three. Generally any decent computer player should be fine with it, and standalone players like the WD TV as well. Don't know about Apple devices.
AppleTV is fine with strict. Afaik so are the current iPod/iPhones as well.
mkelley
Bright Spark User
Posts: 389
Joined: Fri Dec 25, 2009 2:00 am

Re: What does RF: in constant quality stand for?

Post by mkelley »

Wait a minute -- I was following this thread just fine but now this has me confused.

Are the HB developers saying that it's better to use Strict instead of Loose now? Because the High Profile (my standard preset) uses Loose. I assume my device (the WD Live, which plays most any kind of MKV video) will be fine with that, but now I'm wondering if all my encodes (all blu-ray encodes using the High Profile) should be redone at Strict. Or at the very least should I alter my standard preset to Strict from now on?
User avatar
JohnAStebbins
HandBrake Team
Posts: 5712
Joined: Sat Feb 09, 2008 7:21 pm

Re: What does RF: in constant quality stand for?

Post by JohnAStebbins »

Strict will be ever so slightly better quality and should be compatible with most devices. But some devices require mod 16 dimensions that are provided by loose. The quality difference is minuscule. It's not worth the trouble to reencode. If your playback devices support it, you might as well switch to strict.
mkelley
Bright Spark User
Posts: 389
Joined: Fri Dec 25, 2009 2:00 am

Re: What does RF: in constant quality stand for?

Post by mkelley »

Okay, thanks for the info.
moviebuff
Posts: 19
Joined: Mon Jan 25, 2010 1:43 am

Re: What does RF: in constant quality stand for?

Post by moviebuff »

Does anyone use the Normal preset? Ive been using it with 20 rf on dvd and 22 rf on bluray but on normal not high .
AndrewSwift
Posts: 7
Joined: Thu Jan 13, 2011 12:14 pm

Re: What does RF: in constant quality stand for?

Post by AndrewSwift »

I'd like to throw a discordant stone into this pond.

I came across this forum looking for the way to make perfect DVD rips with Handbrake in order to junk my DVD's with no regrets.

After reading the page, I went back and looked at my existing settings. I had RF at 5 (which worked really well). After reading this page, I changed it to 19, and the quality was noticeably worse. The iPad plays back files converted at RF 5 without issue, and so does VLC on the Mac. AirTunes hiccuped at first but seemed to go on okay afterwards.

The filesize for a 22-minute episode of Futurama went from 150 MB (RF 19) to 820 MB (RF 5). For me, it was worth it in order to have a DVD-quality result.

For the rest, here are my settings:

Constant Quality, RF 5
Anamorphic: None
Output resolution: same as input resolution (720x480 in this case). It's true that the aspect ration is very slightly off, but the image is clean and I didn't notice the difference once I pressed play.
Modulus: 16 (not sure what difference this makes, but it's quicker to click up to 720 with a higher modulus).
Cropping: 0 pixels

Filters

Detelecine: default
Decombe: default
Denoise: off
Deblock: off

So far, these give the best results -- playback looks indistinguishable from the original DVD.

If anyone has any feedback I'd love to hear about ways to improve the quality even further.
dorito
Posts: 43
Joined: Fri Apr 11, 2008 4:36 pm

Re: What does RF: in constant quality stand for?

Post by dorito »

I'm all for high quality rips but 5 rf is waaaaaay over the top
thompson
Bright Spark User
Posts: 356
Joined: Sat Dec 12, 2009 8:04 pm

Re: What does RF: in constant quality stand for?

Post by thompson »

AndrewSwift wrote:I came across this forum looking for the way to make perfect DVD rips with Handbrake in order to junk my DVD's with no regrets.
Hard drive space is cheap, why not just rip the DVD without transcoding, using something like MactheRipper, Ripit, etc. [Edit: or any of their Windows equivalents] Then you always have the unaltered data and you can transcode to whichever format happens to strike your fancy on any given day.

My guess is that the straight rip from the disc will come out to be about the same size as a file encoded at RF5 anyways, or at least not appreciably larger.
jamiemlaw
Veteran User
Posts: 536
Joined: Thu Sep 17, 2009 4:52 pm

Re: What does RF: in constant quality stand for?

Post by jamiemlaw »

Futurama is clean cell animation; using RF 5 on live action or film will give you files three times that size, which is stupid.

I think you got lucky.
mduell
Veteran User
Posts: 8187
Joined: Sat Apr 21, 2007 8:54 pm

Re: What does RF: in constant quality stand for?

Post by mduell »

AndrewSwift are you using ffmpeg or x264?

Can you post the encoding log so we don't have to play 20 questions?
AndrewSwift
Posts: 7
Joined: Thu Jan 13, 2011 12:14 pm

Re: What does RF: in constant quality stand for?

Post by AndrewSwift »

In order:

@thompson: I am not sure I understand your comment. The "DVD"'s I have are just video_ts folders that I've already copied onto hard drives. I am looking for a more convenient way to store them, that's all. Can those programs keep the MPEG data in the VOB files untouched but cut/combine the film at the right points to make a watchable MPEG? Also, I am looking for a format that the iPad can read so that I don't have to transcode every time I watch a film. If the quality is as good as the original DVD, I can ditch the video_ts folders.

@jamiemlaw: Futurama worked well as a test because it has blue wavy rays in the background at the beginning of each episode that are extremely difficult to encode. There was noticeable visual noise in this background at RF 19. I have not yet tested values between 5 and 19, but RF 5 is probably higher than necessary. However, the point was to have a perfect, DVD-quality rip. I really don't care about file size. It may be true that I got lucky, I won't know until I have more experience (see below).

@mduell: x264. See below for the log. If you want other parts I'll be happy to post them.

Since I wrote my last post, I tried to encode a Rolling Stones documentary (60 minutes) at RF 5. The resulting file was 5GB, which is acceptable to me, but it appears to be unplayable. I don't yet know why, so it maybe that RF5 is only workable for animation, or only for shorter films. I will post more info as I learn more.

I have also tested the iPad and High Profile defaults in Handbrake with my Futurama episode, and the quality was noticeably worse than my rip at RF5.

I will also re-encode some Futurama episodes at RF values between 5 and 19 to see if there is a way to get perfect rips with smaller files.

Thanks, all of you.

[15:47:59] job configuration:
[15:47:59] * source
[15:47:59] + /Volumes/Archive 101117/_Futurama Season 3/Season 3.1
[15:47:59] + title 1, chapter(s) 1 to 6
[15:47:59] * destination
[15:47:59] + /Volumes/Downloads 101117/Film/Futurama season 1-6 (complete) + extras/Season 3.1.1.m4v
[15:47:59] + container: MPEG-4 (.mp4 and .m4v)
[15:47:59] + chapter markers
[15:47:59] * video track
[15:47:59] + decoder: mpeg2
[15:47:59] + bitrate 9800 kbps
[15:47:59] + frame rate: same as source (around 23.976 fps)
[15:47:59] + dimensions: 720 * 480 -> 720 * 480, crop 0/0/0/0, mod 16
[15:47:59] + filters
[15:47:59] + Detelecine (pullup) (default settings)
[15:47:59] + Decomb (default settings)
[15:47:59] + encoder: x264
[15:47:59] + options: ref=2:bframes=2:subq=6:mixed-refs=0:weightb=0:8x8dct=0:trellis=0
[15:47:59] + quality: 5.00 (RF)
[15:47:59] * audio track 0
[15:47:59] + decoder: English (AC3) (Dolby Surround) (track 1, id 80bd)
[15:47:59] + bitrate: 192 kbps, samplerate: 48000 Hz
[15:47:59] + mixdown: Dolby Surround
[15:47:59] + encoder: ca_aac
[15:47:59] + bitrate: 160 kbps, samplerate: 48000 Hz
Last edited by AndrewSwift on Fri Jan 14, 2011 5:35 pm, edited 1 time in total.
mduell
Veteran User
Posts: 8187
Joined: Sat Apr 21, 2007 8:54 pm

Re: What does RF: in constant quality stand for?

Post by mduell »

The file is unplayable because you went over 4GB without checking "64-bit MP4" or large file support or whatever it's called these days.

RF5 is just pants on head retarded for x264.
thompson
Bright Spark User
Posts: 356
Joined: Sat Dec 12, 2009 8:04 pm

Re: What does RF: in constant quality stand for?

Post by thompson »

AndrewSwift wrote:@thompson: I am not sure I understand your comment. The "DVD"'s I have are just video_ts folders that I've already copied onto hard drives. I am looking for a more convenient way to store them, that's all. Can those programs keep the MPEG data in the VOB files untouched but cut/combine the film at the right points to make a watchable MPEG? Also, I am looking for a format that the iPad can read so that I don't have to transcode every time I watch a film. If the quality is as good as the original DVD, I can ditch the video_ts folders.
My point is that if you keep the original files, the ones you have on your hard drive now, you don't have to worry about this quest for the perfect flawless encode. Keep the ones you have. Then create a transcoded copy, I'd just use the AppleTV 2 preset as it's compatible with the iPad but will yield slightly better quality. Now you have an easily watchable copy, and a bit-perfect copy.

You would have almost perfect transcoded files for watching on portable devices / your future Apple TV / whatever, but if you're at your computer you can just fire up VLC and play it off of the video_ts folder.
jamiemlaw
Veteran User
Posts: 536
Joined: Thu Sep 17, 2009 4:52 pm

Re: What does RF: in constant quality stand for?

Post by jamiemlaw »

Or you can use MakeMKV to put your videos into MKV containers. For SD sources, you can even watch these on the iPad if you get VLC for it.
AndrewSwift
Posts: 7
Joined: Thu Jan 13, 2011 12:14 pm

Re: What does RF: in constant quality stand for?

Post by AndrewSwift »

@mduell, thanks. I will check "large file size". I had forgotten what it was for. I will respond to the second part of your comment when I have made more tests -- I created a set of Futurama episodes at 17, 15, 13, 11, 9 and 7, but I haven't had time to compare them yet. I assume that you are right and that RF 5 is totally unnecessary.

@thompson, I only want to keep one copy. It's true that hard drive space is cheap, but for simplicity's sake I don't want to have two copies of all my movies. AppleTV 2 is a good preset, and with a lower RF (to be determined) it will probably suit me perfectly.

@jamiemlaw, thanks, that is exactly what I was originally looking for. I'm not totally worried about iPad compatibility (though it would be nice) because my movie collection is (hopefully) forever and the iPad is just this year's model, to be replaced in a maximum of 18 months.

FYI, VLC was removed from the App Store because its developer was concerned about conflicts with the App Store requirements and the open-source nature of VLC.
Post Reply