ffmpeg encoding to VP9 results in Google Chrome-unplayable video, while to VP8 works

2

Plenty of time passed, since I have encountered the problem, specified in the subject.

I tried multiple ffmpeg static builds, have built it from Git repository myself with different flags and on all major operating systems, even built libvpx, but the problem still persists. I cannot get ffmpeg to encode a VP9 video, which will not crash Google Chrome.

I have an Intel Core 2 Quad Q9550 with 4 cores, and for example I use brew-built ffmpeg with the following options:

ffmpeg version 2.8.1 Copyright (c) 2000-2015 the FFmpeg developers
built with Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)
configuration: --prefix=/usr/local/Cellar/ffmpeg/2.8.1_1 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-opencl --enable-libx264 --enable-libmp3lame --enable-libvo-aacenc --enable-libxvid --enable-libfreetype --enable-libvorbis --enable-libvpx --enable-libass --enable-ffplay --enable-libfdk-aac --enable-libopus --enable-libquvi --enable-libx265 --enable-nonfree --enable-vda
libavutil      54. 31.100 / 54. 31.100
libavcodec     56. 60.100 / 56. 60.100
libavformat    56. 40.101 / 56. 40.101
libavdevice    56.  4.100 / 56.  4.100
libavfilter     5. 40.101 /  5. 40.101
libavresample   2.  1.  0 /  2.  1.  0
libswscale      3.  1.101 /  3.  1.101
libswresample   1.  2.101 /  1.  2.101
libpostproc    53.  3.100 / 53.  3.100

the video in question is:

General 
Complete name : OneSecondTestYUV422.mov
Format : MPEG-4
Format profile : QuickTime
Codec ID : qt
File size : 13.0 MiB
Duration : 1s 0ms
Overall bit rate mode : Variable
Overall bit rate : 109 Mbps
Movie name : Untitled Project
Description : This video is about Untitled Project
Encoded date : UTC 2015-10-17 16:43:21
Tagged date : UTC 2015-10-17 16:43:22
Writing library : Apple QuickTime
com.apple.quicktime.keywords : ProRes Samples
com.apple.quicktime.author : No Name
com.apple.quicktime.title : Untitled Project

Video 
ID : 1
Format : ProRes
Format version : Version 0
Format profile : 422
Codec ID : apcn
Duration : 1s 0ms
Bit rate mode : Variable
Bit rate : 106 Mbps
Width : 1 920 pixels
Height : 1 080 pixels
Display aspect ratio : 16:9
Frame rate mode : Constant
Frame rate : 24.000 fps
Color space : YUV
Chroma subsampling : 4:2:2
Scan type : Progressive
Bits/(Pixel*Frame) : 2.138
Stream size : 12.7 MiB (98%)
Title : Core Media Video
Writing library : Apple
Encoded date : UTC 2015-10-17 16:43:21
Tagged date : UTC 2015-10-17 16:43:22
Color primaries : BT.709
Transfer characteristics : BT.709
Matrix coefficients : BT.709

Audio 
ID : 2
Format : PCM
Format settings, Endianness : Little
Format settings, Sign : Signed
Codec ID : lpcm
Duration : 1s 0ms
Bit rate mode : Constant
Bit rate : 2 304 Kbps
Channel(s) : 2 channels
Channel positions : Front: L R
Sampling rate : 48.0 KHz
Bit depth : 24 bits
Stream size : 281 KiB (2%)
Title : Core Media Audio
Encoded date : UTC 2015-10-17 16:43:21
Tagged date : UTC 2015-10-17 16:43:22

Other 
ID : 3
Type : Time code
Format : QuickTime TC
Duration : 1s 0ms
Time code of first frame : 00:00:00:00
Time code, striped : Yes
Title : Core Media Time Code
Encoded date : UTC 2015-10-17 16:43:22
Tagged date : UTC 2015-10-17 16:43:22

and the command I pass to ffmpeg is:

ffmpeg -i OneSecondTestYUV422.mov -map 0:0 -map 0:1 -c:a libvorbis -async 1 -c:v libvpx-vp9 -b:v 17418.24k -maxrate 34836.48k -bufsize 34836.48k -r 24 -s 1920x1080 -aspect 16:9 -trellis 0 -subq 6 -me_range 16 -b_strategy 1 -refs 3 -sws_flags fast_bilinear -direct-pred 1 -sc_threshold 40 -qmin 2 -qmax 51  -copyts -threads 4 -sn -y UnplayableResult.webm

I searched a lot on the Internet, these sites included, but to no avail.

Neurotransmitter

Posted 2015-10-18T11:27:13.380

Reputation: 996

1-trellis 0 -subq 6 -me_range 16 -b_strategy 1 -refs 3 -direct-pred 1 -sc_threshold 40. These all look like libx264 options (which should not be needed 99.9% of the time anyway due to the x264 presets). These options will be ignored by libvpx-vp9. – llogan – 2015-10-18T18:56:22.473

Thanks, I've actually made tests with iFFmpeg, so these extraneous parameters are inserted by it by default. My actual encoding line is ffmpeg -i OneSecondTestYUV422.mov -c:v libvpx-vp9 -b:v 4M -pix_fmt yuv420p -speed 4 -frame-parallel 0 -threads 4 -c:a libopus -b:a 320K PlayableResult.webm – Neurotransmitter – 2015-10-18T18:58:25.410

That looks more sane. Never heard of iFFmpeg. – llogan – 2015-10-18T19:04:29.613

iFFmpeg is just another paid ffmpeg GUI. Used it just for tests, made my real work from the command line. – Neurotransmitter – 2015-10-18T19:05:29.437

Answers

4

Seems like I figured it out (funny enough I had a problem for days and finally resolved it once the question has been published).

ffmpeg sees that the original video has pixel format YUV 4:2:2 and encodes it accordingly, to the same format. However, seems like Google Chrome doesn't work with this pixel format, and it expects it to be YUV 4:2:0.

So, I have passed -pix_fmt yuv420p to the command line and voilà, I have a Google Chrome-playable video!

Neurotransmitter

Posted 2015-10-18T11:27:13.380

Reputation: 996

I'm curious: can you show the Supported pixel formats line from: ffmpeg -h encoder=libvpx-vp9? – llogan – 2015-10-18T18:53:05.953

Sure, here you go: Supported pixel formats: yuv420p yuv422p yuv440p yuv444p – Neurotransmitter – 2015-10-18T19:00:55.780

0

I had a similar problem: Some of the WebM-VP9 videos I had encoded over the last year could be played in Firefox, some couldn't (Firefox 44, 45, Mac OS X). However Firefox 39 could play all of them!?

Thanks to TranslucentCloud's hint I finally checked some of the files using ffprobe. They just differed in yuv422p(tv) vs. yuv420p(tv).

Adding the -pix_fmt:v yuv420p option to the second run of the encoding ended my trouble. Nice, playable videos in all Firefox versions.

Draussenduscher

Posted 2015-10-18T11:27:13.380

Reputation: 1