Video Production Stack Exchange is a question and answer site for engineers, producers, editors, and enthusiasts spanning the fields of video, and media creation. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top


I am trying to compress lossless bluray tracks to a more storage friendly size without a huge loss in quality.

What I've been doing thus far:

Exploring compression options with ffmpeg. Mainly around h264 with the -crf argument.


Linux and open source tools. Please don't suggest anything Apple/Microsoft specific.


Most of the options I see around compression involved bit rates or fixed output sizes. I am looking for a video codec that has more of a "quality threshold". I don't mind if more complex portions of the track require more bytes to deliver the same level of visual quality. Does anything like this exist?


I am having good luck with the -qscale argument and libxvid. If I don't get any other suggestions, I'll just go with that.

share|improve this question
What's wrong with crf in x264? – Mulvya Apr 10 '12 at 15:43
Documentation states that crf sacrifices runtime speed for quality. Since I could potentially run these videos on lesser machines, I didn't want to place too much burden on them. – Jacks_Depression Apr 12 '12 at 14:45
You can't get both quality and computational efficiency. There's a tradeoff. – Mulvya Apr 12 '12 at 16:23
Have you looked at Lagarith or HuffYUV? I generally use these for storing footage. They are both lossless however the compression can actually be quite good, granted I'm not sure how they compare to h264. I'm also not sure about Linux support. – glenneroo Apr 19 '12 at 15:54
Your bluray source is highly unlikely to be lossless. Easy way to check: ffplay -vf showinfo. If it has any B frames, it's not lossless h.264. – Peter Cordes Jan 15 '15 at 11:50

You're on the right track with -crf and x264 (the H.264 encoder), and it should provide the "quality threshold" that you're looking for. CRF is recommended if you want a certain output quality and output file size is of less importance. Conversely, performing a two-pass encode with -b:v is recommend if you are targeting a specific output file size and quality is of less importance.

1. Get FFmpeg

Get ffmpeg and x264. Your distro may provide a package, but it may not support libx264 or it may be very old. It's a good idea to compile these if you're going to be doing a good amount of encoding since development is very active. See FFmpeg Compilation Guides for complete FFmpeg and x264 compile instructions for Ubuntu and CentOS. Alternatively you can simply use FFmpeg static Linux builds (but compiling is more interesting). Links to these are available on the FFmpeg Download page.

If you're using Ubuntu and just want to use the distro package then see HOWTO: Easily enable MP3, MPEG4, AAC, and other restricted encoders in FFmpeg. This guide is now unmaintained, but it is still up to date.

2. Choose a CRF value

The range is 0-51 where 0 is lossless, 23 is default, and 51 is worst possible. A lower value is a higher quality. A subjectively sane range is 18-28. Consider 18 to be visually lossless: it should look the same as the input but it isn't technically lossless. Increasing the CRF value +6 is roughly half the bitrate while -6 is roughly twice the bitrate. Note: These CRF values apply to 8-bit x264. 10-bit x264 CRF values are different, IIRC.

General usage is to choose the highest quality that still provides an acceptable quality. That is if the output looks good then try a higher value and if it looks bad then choose a lower value.

3. Choose a preset

A preset is a collection of options that will provide a certain encoding speed:compression ratio. A slower preset will provide better compression (compression is quality per filesize). General usage is to use the slowest preset that you have patience for. Current presets in descending order of speed are: ultrafast, superfast, veryfast, faster, fast, medium, slow, slower, veryslow, placebo. Ignore placebo as it is a joke and a waste of time (it helps at most ~1%). If it's encoding too slowly then use a faster preset.

4. Encode

Use these settings for the rest of your videos. They should all end up with the same quality.


ffmpeg -i input -c:v libx264 -preset slow -crf 22 -c:a copy output.mkv


Encode a section instead of the whole video with the -ss (offset time from beginning; in seconds or hh:mm:ss) and -t (duration in seconds or hh:mm:ss) options to quickly get a general idea of what the output will look like.

share|improve this answer
-ssim 1 -psnr on your ffmpeg cmdline will measure some video quality metrics (which don't always match human-perceived visual quality). Can be useful to get an idea of how much your video is getting mangled. – Peter Cordes Jan 15 '15 at 11:52

Maybe this is going to be helpfull K-Lite Codec Pack When you install there is pack of codecs so you can choose what best fits you. This is the list of codecs: • DirectShow video decoding filters: - ffdshow [version 1.2.4475] - LAV Video [version 0.51.3] (- Decoding of: H264, VC1 (progressive only), MPEG2, MPEG4-ASP, MS-MPEG4, MJPEG, VP8, RV40, WMV1/2/3) - On2 VP7 [version] - DScaler5 MPEG-2 decoder [version IVTC mod]

share|improve this answer
I don't see how this answers the question. – LordNeckbeard Jul 26 '12 at 18:05
download K-Lite Codec Pack, find options in coder/decoder and that's it. There is the option of choosing quality and the size of commpresed video. The answer is here, but I shorten in particular reason. Good answering by you though – Mors Violenta Jul 26 '12 at 19:44
Your answer would be more helpful if you suggested which of the codecs would suit the questioner's needs. – stib Jan 19 '15 at 13:03

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.