3

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!

sobutterysosmooth
  • 775
  • 1
  • 8
  • 11
  • 2
    This is what CRF (constant quality) mode is for. Use `-crf 20 -b:v 0` Skip the two passes. Test with different CRF values (0 to 63) on a short segment on the input. Once you hit value that produces small enough and good enough output, use that value. – Gyan Apr 06 '17 at 06:51
  • Bonus points on top of @Mulvya's comment: although with other encoders, 1-pass and 2-pass CRF should give the same results, this is unfortunately not the case for libvpx, and you should still do 2-pass encoding, even when doing CRF... – Ronald S. Bultje Jan 11 '18 at 23:12

1 Answers1

1

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.

bzipitidoo
  • 11
  • 1