What does “CRF” mean?

Posted on September 28, 2014. Filed under: Definitions | Tags: |

CRF stands for Constant Rate Factor, x264′s best single-pass encoding method.

Quick Summary: What is the Constant Rate Factor?

The Constant Rate Factor (CRF) is the default quality setting for the x264 encoder. You can set the values between 0 and 51, where lower values would result in better quality (at the expense of higher file sizes). Sane values are between 18 and 28. The default for x264 is 23, so you can use this as a starting point.

With ffmpeg, it would look like this:
ffmpeg -i input.mp4 -c:v libx264 -crf 23 output.mp4

If you’re unsure about what CRF to use, begin with 23 and change it according to your subjective impression of the output. Is the quality good enough? No? Then set a lower CRF. Is the file size too high? Choose a higher CRF. A change of ±6 should result in about half/double the file size, although your results might vary.

0 (losless) <- better <- 18 <- 23 -> worse -> 28 -> 51 (worst)

CRF in a nutshell

The way constant quality encoding is usually done, it keeps up a constant quality by compressing every frame of the same type the same amount. In tech speak, that’s maintaining a constant QP (quantization parameter). The quantization parameter defines how much information to “throw away” from a given block of pixels.

Constant Rate Factor, on the other hand, will compress different frames by different amounts. It does this by taking motion into account.

The eye perceives more detail in still objects than when they’re in motion. Because of this, a video compressor can apply more compression (drop more detail) when things are moving, and apply less compression (retain more detail) when things are still. Subjectively, the video will seem to have higher quality.

How to use it

If you’re using x264, CRF is used by default for constant quality.

But isn’t that other way, constant QP, really better quality in the end?

No. It just wastes space by compressing less in areas you really won’t notice. This isn’t even like MP3s cutting off highs and lows in music that are audible on CDs. There is not a purist’s argument to made here.

If you were a computer, you would look at a CRF encoding and say it was lower quality than the CQP copy. And it would be. But if you’re a human being, subjectively, the CRF copy will look better. It least compresses the parts you see the most, and most compresses the parts you see the least.

Many people always use CRF for single-pass encodes and argue there is no reason to ever use CQP.

Slightly more technical explanation

A constant QP encode at Q=18 will stay at Q=18 regardless of the frame. Constant Rate Factor will increase the Q to, say, 20, for high motion frames (compressing them more) and lower it down to 16 for low motion. That means that while the average quality as objectively gauged by PSNR goes slightly down, the *perceptible* image quality goes up.

When you use a constant rate factor, it varies the QP slightly. When a scene has a lot of action and motion, it will raise the QP (compressing more). This is because your eye will be distracted by everything going on, and won’t have the image on screen for enough time to see the heavier compression. When a frame doesn’t have a lot of motion, it will lower the QP, compressing it less. This is because your eye will have more time to look at the image, so you want it to be as much like the source as possible.

CRF is about improving subjective quality — what the human eye sees — at the expense of objective quality — what a PSNR calculation sees. There is no way for anyone to tell you what your eye will notice on any given film.

If quality goes down in motion, does that mean it gets all blocky like my digital TV?

CRF is not the cause of the blocking you might see on digital cable/sat broadcasts. That derives from too low of a bitrate.

Different bitrates correspond to different compression rate factors with different sources. So 1500kbps will be enough to get an RF of 15 with one source, but only an RF of 20 with another, dirtier source. When you use CRF or CQP you’re saying “use whatever bitrate is necessary to preserve this much detail.” It’s not a 1-to-1 thing.

Those TV broadcasts get blocky because the complex things they’re displaying require more bits than the broadcaster has chosen to give them. They say “preserve as much detail as you can while never going above this high a bitrate no matter how complicated things get.”

But still… isn’t lower quality bad?

When you use CRF, it raises the QP (compressing more, losing more detail) for complex parts, yes. But it doesn’t raise it drastically, and it makes sure those complex parts still maintain a set quality level. Just a level a little lower than the simple parts. The bitrate for those parts might still be higher than for the simple parts, because the bitrate needed at a given moment to reach a given rate factor fluctuates. You can go to a lower RF for the simple parts while still keeping a bitrate similar to what you need for the complex parts at a higher RF.

If you use a CRF of 25, sure, you’re going to see blocking on high-motion because the bitrate is simply too low. It’s going to be using a QP of, like, 27 for the complex parts, which is way too heavy a quantizer. And it’ll only use, say, 23 for the simple parts, which isn’t quite low enough to drastically increase quality. But if you use reasonable CRF values, in the range of, say, 23-17, this won’t occur.

Text taken from “CRF Guide” written by Jonathon Rubin.[1]. Improvements made by Werner Robitza.[2]

Footnotes

1. Constant Rate Factor – ReScene wiki
2. CRF Guide – Werner Robitza


Read Full Post | Make a Comment ( None so far )

Recently on Scene Lingo - Definitions from the "Scene" !…

What Does “FREEWEB” Mean?

Posted on November 18, 2013. Filed under: Definitions | Tags: , , |

What does “1080MBAFF” mean?

Posted on October 18, 2013. Filed under: Definitions | Tags: , , , |

What does “APDTV” mean?

Posted on August 23, 2013. Filed under: Definitions | Tags: |

What does “SE” mean?

Posted on August 9, 2013. Filed under: Definitions | Tags: , |

What does “DD” mean?

Posted on July 27, 2013. Filed under: Definitions |

Same people, different groups

Posted on July 9, 2013. Filed under: Explanations | Tags: |

What does “SBD” mean?

Posted on April 27, 2013. Filed under: Definitions | Tags: |

What does “DVTV” mean?

Posted on March 3, 2013. Filed under: Definitions | Tags: |

What does “LD” and “MD” mean?

Posted on January 28, 2013. Filed under: Definitions | Tags: , , |

What does “DDC” mean?

Posted on January 22, 2013. Filed under: Definitions | Tags: |

What does “JAV” mean?

Posted on January 17, 2013. Filed under: Definitions | Tags: , |

What does “MULTIFORMAT SCD” mean?

Posted on October 22, 2012. Filed under: Definitions | Tags: , |

What does “FD” mean?

Posted on September 11, 2012. Filed under: Definitions | Tags: |

What does “HSBS” mean?

Posted on September 10, 2012. Filed under: Definitions | Tags: , |

What does “PDTV” mean?

Posted on August 20, 2012. Filed under: Definitions | Tags: , , |

What does “AHDTV” mean?

Posted on July 24, 2012. Filed under: Definitions | Tags: , |

What does “DIRFIX” mean?

Posted on June 17, 2012. Filed under: Definitions | Tags: |

What does “CONVERT” mean?

Posted on June 9, 2012. Filed under: Definitions | Tags: |

How to play RAR files without unpacking them?

Posted on April 22, 2012. Filed under: Explanations | Tags: , , |

What does “PPV” mean?

Posted on November 13, 2009. Filed under: Definitions | Tags: |

What does “DirCut” mean?

Posted on August 25, 2009. Filed under: Definitions | Tags: |

What does “Directors.Cut” mean?

Posted on August 25, 2009. Filed under: Definitions | Tags: |

What does “DL” mean?

Posted on March 24, 2009. Filed under: Definitions | Tags: |

What does “Festival” mean?

Posted on March 3, 2009. Filed under: Definitions | Tags: |

Don’t Repack it, ReScene it!

Posted on February 10, 2009. Filed under: Explanations | Tags: , |

What does “SUBBED” mean?

Posted on September 3, 2008. Filed under: Definitions | Tags: |

The RAR Argument

Posted on August 16, 2008. Filed under: Explanations |

What does “Pre” mean?

Posted on August 12, 2008. Filed under: Definitions | Tags: |

What does “TRACKFIX” mean?

Posted on August 2, 2008. Filed under: Definitions | Tags: |

What does “RETAIL” mean?

Posted on August 2, 2008. Filed under: Definitions | Tags: |

What does “WEB” mean?

Posted on August 2, 2008. Filed under: Definitions | Tags: |

What does “SAT” mean?

Posted on August 2, 2008. Filed under: Definitions | Tags: |

What does “LINE” mean?

Posted on August 2, 2008. Filed under: Definitions | Tags: |

What does “FM” mean?

Posted on August 2, 2008. Filed under: Definitions | Tags: |

What does “CABLE” mean?

Posted on August 2, 2008. Filed under: Definitions | Tags: |

What does “VINYL” mean?

Posted on August 2, 2008. Filed under: Definitions | Tags: |

What does “DVDA” mean?

Posted on August 2, 2008. Filed under: Definitions | Tags: |

What does “CDA” mean?

Posted on August 2, 2008. Filed under: Definitions | Tags: |

What does “CDS” mean?

Posted on August 2, 2008. Filed under: Definitions | Tags: |

What does “R5″ mean?

Posted on July 29, 2008. Filed under: Definitions | Tags: |

What does “AC3″ mean?

Posted on July 23, 2008. Filed under: Definitions | Tags: |

What does “DTS” mean?

Posted on July 23, 2008. Filed under: Definitions | Tags: |

What is an “mkv” file, and how do i play it?

Posted on July 18, 2008. Filed under: Definitions, Explanations | Tags: |

What’s the difference between “720p” and “1080p”?

Posted on July 18, 2008. Filed under: Explanations |

What does “BluRay” mean?

Posted on July 17, 2008. Filed under: Definitions | Tags: |

What’s an “NFO” and how do I open it?

Posted on July 17, 2008. Filed under: Explanations | Tags: |

What does “DC” mean?

Posted on July 17, 2008. Filed under: Definitions | Tags: |

What does “BD5″ and “BD9″ mean?

Posted on July 17, 2008. Filed under: Definitions | Tags: , |

How is a 1280×544 film considered to be 720p?

Posted on July 17, 2008. Filed under: Explanations |

Liked it here?
Why not try sites on the blogroll...

Follow

Get every new post delivered to your Inbox.