Search code examples
ffmpeglibvpxvp9

ffmpeg vp9 not setting constant quality


I'm running ffmpeg to convert a 4k hevc video to vp9 but no matter what setting I use, it always comes out horrible quality and the same filesize.

Command:

ffmpeg -y -i /tmp/longsample.mkv -threads 6 -c:a libopus -c:v libvpx-vp9 -crf 30 /tmp/vp9-30.mkv
ffmpeg -y -i /tmp/longsample.mkv -threads 6 -c:a libopus -c:v libvpx-vp9 -crf 15 /tmp/vp9-15.mkv
ffmpeg -y -i /tmp/longsample.mkv -threads 6 -c:a libopus -c:v libvpx-vp9 -crf 0 /tmp/vp9-0.mkv

I'm using the ffmpeg:latest on docker.


Solution

  • What the VPx codecs in ffmpeg do is use the video bitrate value as a ceiling. If not set by the user, ffmpeg assumes a default of 200 kbps. You need to reset the value to get unconstrained CRF encoding.

    ffmpeg -y -i in.mkv -threads 6 -c:a libopus -c:v libvpx-vp9 -crf 30 -b:v 0 out.mkv
    

    See https://trac.ffmpeg.org/wiki/Encode/VP9#constantq