Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FFmpeg - selecting appropriate bitrate for VP9 encoding

I am looking to encode a 4k video shot with iPhone 6s in VP9 in the best quality possible.

For reference, stream data of the video I would like to encode, via ffprobe:

Duration: 00:00:10.48, start: 0.000000, bitrate: 46047 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 3840x2160, 45959 kb/s, 29.98 fps, 29.97 tbr, 600 tbn, 1200 tbc (default)
    Metadata:
      creation_time   : 2017-03-13T21:12:56.000000Z
      handler_name    : Core Media Data Handler
      encoder         : H.264
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 79 kb/s (default)
    Metadata:
      creation_time   : 2017-03-13T21:12:56.000000Z
      handler_name    : Core Media Data Handler

I am using the following FFmpeg commands, based on these instructions (see Best Quality (Slowest) Recommended Settings section).

  1. ffmpeg -i INPUT.mov -c:v libvpx-vp9 -pass 1 -b:v 46000K -threads 4 -speed 4 -g 9999 -an -f webm -y /dev/null
  2. ffmpeg -I INPUT.mov -c:v libvpx-vp9 -pass 2 -b:v 46000K -threads 4 -speed 0 -g 9999 -an -f webm OUTPUT.webm

Is there a best practice to select an optimal -b:v value such that the resulting video is visually indistinguishable from the original? I have tried values ranging from 36000K-46000K, but these result in massive files with an overall bitrate exceeding the target bitrate.

Thanks in advance!

like image 814
sobutterysosmooth Avatar asked Jan 25 '26 05:01

sobutterysosmooth


1 Answers

Just have to experiment with different, much lower bit rates, and view the results. I try to watch for artifacts. Does hair still look good? Cloth? Lettering, like on road signs and store windows? No blockiness? No bleeding of dark and light at sharp edges? No echoes? I find motion blur in the original hard to judge, have to compare side by side to tell the difference between that and compression artifacts.

Try 1/10th of 36000k. I find vp9 at a nominal 400k bit rate works great on 1280x720 video. (ffmpeg with libvpx-vp9 overshoots, and I typically end up with a 20% higher actual bit rate, 480k) 4K is 3840x2160, 9x the size of 1280x720, so it would seem a 3600k bit rate should produce good results.

Another guide is that vp9 is reportedly about equal in quality to mp4 at half the bit rate. Video that looks good at a 1000k bit rate in mp4 should look good at 500k in vp9.

like image 196
bzipitidoo Avatar answered Jan 27 '26 19:01

bzipitidoo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!