Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Notes on encoding settings
ffmpeg -c:v libvpx-vp9 uses kf_max_dist=9999 (infinite) and kf_mode=auto by default which means if your source is mostly static, you will have only one keyframe for the entire video (vpxenc CLI tool uses max keyframe interval of 5 seconds by default).
ffmpeg -loglevel debugin encoding command to check the actual settings
- Passing gop_size (-g) from ffmpeg: libvpxenc.c
Default values of kf_max_dist and kf_mode: vp9_cx_iface.c
- Docs on vpxenc CLI tool
- Slides on VP9, page 36
frame-parallel, tile-columns, row-mt
Read this thread. Summary:
-frame-parallel should be disabled since libvpx 1.4.0. Its multithreading capabilities were removed, resulting in it becoming effectively decrepit.
-tile-columns slightly affects output quality but it's the only mechanism in VP9 to provide multithread encoding and decoding.
UPDATE: ffmpeg 3.3/libvpx 1.7.0 support -row-mt option which provides better encoding parallelization.
Threads autodetection doesn't work with libvpx so you need to manually raise
- Current state of VP9 profiles in libvpx: , ; summary: support for different chroma subsamplings, support for higher bit depths, but some players/devices/decoders may lack support e.g. Chrome-based browsers; see also bug 1215089
- Current state of VP8/VP9 alpha: , , ; summary: you can encode video with alpha channel with libvpx (
-pix_fmt yuva420p), Chrome and Firefox 53+ can display it
Firefox always uses BT.601 colormatrix to display WebM, see bug 1210357. Chrome respects video's colormatrix tags and has height-based heuristics. In order to make WebM look exactly the same in these two browsers you need to convert video to BT.601 (
-vf colormatrix=bt709:bt601; also don't forget about dithering) and tag it so (
-colorspace bt470bg; only for VP9, VP8 always uses BT.601 per spec).
UPDATE: Firefox 52+ supports tagged BT.709 videos, BT.601 is default. Chrome also support colormatrix tags. So always mark your videos and they should be displayed correctly in both browsers.
UPDATE2: Firefox 53+ has BT.709 by default for VP9. It was compared with mpv's output on this video and showed almost the same picture, with minor differences for blue and pink stripes. Chromium's output for the same video is very different, slightly similar to
--vf format=colormatrix=bt.709:colorlevels=full. I.e. BT.709 is correctly chosen but overall picture seems to be very wrong.
TODO: Research Edge behavior?
TODO: Get some reference BT.709 implementation, file bugs to Firefox and Chrome.
These are the defaults when using ffmpeg with libvpx-vp9 1.6.0:
- quality=good (deadline=1000000)
- speed=1 (-cpu-used = -speed)
- kf_max_dist=128 (-g)