Settings For ffmpeg For Best VP9 Quality for Web Publishing

5,503

Solution 1

Okay, after some experiments I found that guide I mentioned in the question is quite useful. I had success with the instructions from the Constant Quality Recommended Settings section, and what was need to be fine-tuned is the -crf setting.

After quite a lot of tests, I ended up with the -crf 23 setting, with which the result webm file is of very good quality, compared to the original.

The exact ffmpeg commands are:

  1. First pass:

    ffmpeg -i Source.mov -c:v libvpx-vp9 -pass 1 -pix_fmt yuv420p -b:v 0 -crf 15 -threads 2 -speed 4 -tile-columns 6 -frame-parallel 1 -an -y -f webm /dev/null
    
  2. Second pass:

    ffmpeg -i Source.mov -c:v libvpx-vp9 -pass 2 -pix_fmt yuv420p -b:v 0 -crf 15 -threads 2 -speed 2 -tile-columns 6 -frame-parallel 1 -auto-alt-ref 1 -lag-in-frames 25 -c:a libopus -b:a 320k -f webm Out.webm
    

For some reason, a first pass does not use all CPU cores (2 in my case), despite the -threads 2 option, however a second uses them all.

Solution 2

You're doing a 1-pass encode in speed 4, which are fast parameters but far from optimal quality.

The guide seems good, have you tried their 2-pass or constant/constrained quality settings ? Obviously, don't keep their example 1000k bitrate.

Share:
5,503

Related videos on Youtube

Neurotransmitter
Author by

Neurotransmitter

This space intentionally left blank.

Updated on September 18, 2022

Comments

  • Neurotransmitter
    Neurotransmitter almost 2 years

    I have video in Apple ProRes 422 format which I plan to encode to Google's VP9 for publishing on the Web. The source is:

    Stream #0:0(und): Video: prores (apcn / 0x6E637061), yuv422p10le(bt709), 1920x1080, 114644 kb/s, SAR 1:1 DAR 16:9, 23.98 fps, 23.98 tbr, 24k tbn, 24k tbc (default)
    

    My goal is to encode it to VP9 with the best possible (reasonable) quality, almost indistinguishable from the original. The result file size is of no actual concern. Now I use the following, but the video in Chrome looks bad:

    ffmpeg -i Source.mov -c:v libvpx-vp9 -b:v 4M -pix_fmt yuv420p -speed 4 -frame-parallel 0 -threads 2 -c:a libopus -b:a 320K Result.webm
    

    I tried to increase -b:v 4M setting, the size rises, but the quality not. Also I tried this guide, but it is probably outdated and I cannot get any satisfactory result. By the way, I have latest ffmpeg compiled from source.

    Which ffmpeg settings should I use?

    • Elisa Cha Cha
      Elisa Cha Cha over 8 years
      But do you have the latest libvpx?
    • Neurotransmitter
      Neurotransmitter over 8 years
      libvpx-dev is from Debian Testing repository, which is now of version 1.5.0-2.
  • Neurotransmitter
    Neurotransmitter over 8 years
    Yep, yesterday gave the guide the second try and had success. Details are in my answer.
  • Gyan
    Gyan almost 8 years
    In CRF mode, you can skip using two passes, without much cost in quality.