Handbrake: How to retain sharpness when down-sampling video during an encode?

22,299

You've provided no details of your Handbrake version or options, nor the codecs and bitrates of your sources or transcode results, but I'm going to take a stab at it. What you refer to as a loss of 'sharpness' is the result of three generations of lossy video encoding. In short, things got blurry because you decimated the quality of the original source.

First, let's manage expectations. Going from 1280x720 to 852x480 is a >50% reduction in number of pixels, but it will most likely not result in a 50% smaller file AND one which meets your quality standards. Maybe if you were encoding the two files from the same original source, but you shouldn't be surprised that a higher resolution/bitrate file can yield a better picture (projected into any sized window) than a reduced bitrate/scaled/recompressed version.

My guess is your video went from a high quality 720p/1080p source (high bitrate h264 or VC-1, likely BluRay) to your file (720p mid-range bitrate h264) to this attempted transcode (480p lower bitrate h264). This file has already been through put through a lossy compression algorithm twice and you're surprised when a the third round of compression combined with a bitrate reduction and scaling made the file less sharp? That's just common sense.

If you have access to the original source ripping from there will definitely get you the smallest file that meets your quality standards. Removing just one lossy generation will yield significantly sharper results. If a much smaller file is really important (say cause you bought a 16GB iPad and want to maximize the quantity of videos rather than quality of each) feel free to arbitrarily set an average video bitrate and waste time with 2-pass encoding trying to get the file close to your target size.

But if you're actually concerned about quality you should set the x264 settings to 'Constant Quality' and render a 30 second clip multiple times using various CRF values (Constant Rate Factor - an arbitrary unit) to empirically find which CRF value meets your needs. Although HandBrake gives you a huge slider from 0 to 51 for CRF, sane values are in the 19-24 range (default is 20). After selecting your source you can change the toggle from Chapters to seconds and choose any 20-30 second range you'd like to compare. Rename the destination file (e.g. "test-crf20.m4v" or whatever) click 'Add to Queue', adjust CRF a little rename and repeat. Batch render half a dozen and compare each of them to the resized VLC window. Pick the smallest file which doesn't look degraded and try encoding the entire video with that CRF and see if you get the file size savings your looking for with a video that's still 'sharp-enough'.

Share:
22,299

Related videos on Youtube

Rookie
Author by

Rookie

Updated on September 18, 2022

Comments

  • Rookie
    Rookie almost 2 years

    I have a bunch of 1280x720 resolution videos, but I really don't need to have that high resolution, so I thought of re-encoding and resizing them to 852x480 to save some space, but I noticed Handbrake encoding results into a little blurrier video than it looks on my VLC video player when i simply just resize the window.

    So, I am looking for a way to resize a video exactly like VLC does it, because that actually gives better quality than normal resize algorithm or resize + sharpen algorithms, which I couldn't even find in Handbrake. However, is there any way to sharpen a video using Handbrake?

    • harrymc
      harrymc about 12 years
      Which video format and codec are you using? What are the sizes of source and target after resizing?
    • Rookie
      Rookie about 12 years
      h264 i guess. not sure what you mean by format, but the newest handbrake makes .m4v files. 1280x720 to 852x480.
    • harrymc
      harrymc about 12 years
      By sizes I meant file sizes in bytes. Could you also post somewhere a small example video (before conversion).
    • Rookie
      Rookie about 12 years
      @harrymc, no that would be illegal. the blurryness isnt about encoding, its simply about how its resized: it looks exactly like you apply blur effect on it. i also noticed the colors are different!? how that can be?
    • Jonathan Marzullo
      Jonathan Marzullo over 9 years
      You would need have to make custom advanced options or advanced options tab , and set deblock=-1,-1 or deblock=-3,-3 . lowering the deblock will help sharpen the video. Whereas higher deblock values will smooth out the video. Deblock is not a sharpen filter but will help in sharpening the video when negative values are used. You would just have to do your own tests. See forum.handbrake.fr/viewtopic.php?f=6&t=19426
  • Rookie
    Rookie about 12 years
    I think you are right, I just need to encode it with higher quality settings.
  • nonot1
    nonot1 about 12 years
    @notpeter Thanks for the reply. However, if you notice, the original question is specifically asking about sharpness after a downsample. The simple methods of sizing down will induce an blur that must be corrected with sharpening stage. This is the reason Photoshop has a "Bicubic Sharper" re-size option. See the "building windows" mouse-over at: cambridgeincolour.com/tutorials/image-resize-for-web.htm
  • Greg
    Greg about 12 years
    @notnot1 Yes, but the reduced sharpness was likely not due to Handbrake's scaling algorithm (Lanczos) it's because the video was downsampled twice (1080p->720p->480p) and been through three levels lossy compression (VC1->h264->h264) probably with too low a bitrate at some point. Lanczos is better at maintaining sharpness than the Bicubic you mentioned. Don't believe me? Google the 'SD x264 TV Releasing Standards 2012' and note the first rule "Sources requiring resize are to be cropped and resized using sharp resizers such as Lanczos/Lanczos4, Spline36, or Blackman. Bicubic is banned."
  • Henrik
    Henrik about 11 years
    I came here from a Google search for this question. I have experience with various resampling algorithms, and I can tell that the one used in Handbrake is soft. It makes sense in most cases, as fluid motion does not need to be tack sharp. It would be really good have an option to use a different resampling algorithm. I seem to recall VirtualDub offering several. CRF comes into play after resize, and should prioritize sharp edges (if they exist).