Converting H.264 Videos to VP9 In Linux / Ubuntu

1080p videos are all good, but my Internet connection’s upload speed is limited to 512 Kbps, so for example uploading a 20 minutes H.264 video shot at 1080p30 may easily take 10 hours, even after some processing with Handbrake. So this week-end I investigated how I could reduce the upload size, and going with H.265 codec appeared to be a good idea at first. So I tried again H.265 encoding in Handbrake in Ubuntu 14.04, and discovered that adjusting CRF (constant quality factor) to 25 with H.265 was roughly equivalent to 20 with H.264, and both the compression ratio and encoding speed were greatly improved compared to default settings with a minor degradation in quality. If you happen to have a second generation Nvidia Maxwell graphics card you may want to check Nvidia Video Encoding SDK for speedier encoding.

All was good until I decided to upload a test video, and I soon discovered that neither YouTube nor Vimeo would support H.265 with the former ending the upload with “The video has failed to process. Please make sure you are uploading a supported file type.”. Back to the drawing board, and I decided to give VP9 a try using ffmpeg/avconv using instructions here and there.

My computer is running Ubuntu 14.04 LTS, but I also have a virtual machine with the latest Ubuntu version, in this case Ubuntu 15.10, and I tried in both.

First install avconv with

Shell

1

sudo apt-getinstall libav-tools

and check whether VP9 is enabled in

Ubuntu 15.10

Shell

1

2

3

4

avconv-codecs|greplibvpx

...

DEV.L.vp8 On2 VP8(decoders:vp8 libvpx)(encoders:libvpx)

DEV.L.vp9 Google VP9(decoders:vp9 libvpx-vp9)(encoders:libvpx-vp9)

Ubuntu 14.04 LTS

Shell

1

2

3

avconv-codecs|greplibvpx

...

DEV.L.vp8 On2 VP8(decoders:vp8 libvpx)(encoders:libvpx)

Ubuntu 15.10 has a more recent version of avconv with VP9, but Ubuntu 14.04, so I looked for a PPA for avconv, but did not find any, instead installed ffmpeg. avconv and ffmpeg are very similar, because although both are developed by separate teams, the former is a fork of the latter, and in the instructions below you can replace avconv by ffmpeg and vice-versa.

So here’s about to install a more recent version of ffmpeg in Ubuntu 14.04:

Shell

1

2

3

sudo apt-add-repository ppa:mc3man/trusty-media

sudo apt-getupdate

sudo apt-getinstall ffmpeg

Once this is done, Ubuntu 14.04 also supports VP9 decoding and encoding.

The video sample, taken straight from my camera, is a 16-second MOV/H.264/1080p30 video recorded at about 45 Mbps and 97.5MB in size. I filmed a TV screen with some text as I though it might be easier to detect differences. When I used H.265 wit CRF 25 it took about 25 seconds in Handbrake with the resulting file being 7.6MB large.

After various trail and errors, I encoded the sample with two command lines, including one using -cpu-used 5 for faster encoding (over twice as fast), but lower quality:

The first one took 2 minutes 56 seconds (Video size: 4.1 MB), while the second was significantly faster, as it completed the task in 1 minute and 17 seconds (Video size: 4.3MB). I uploaded all three files to YouTube to let you guys compare the quality after upload. The videos need to be watched on a 16:9 screen (1920×1080 or greater) and at 1080p for proper comparison.

For some reasons, the camera samples from the camera were not as good as I would have expected, and even after YouTube processing the original camera samples look very similar to the original.

If you are not a big fan of the command line, you can also install Selene to encode VP9 video using a graphical user interface:

Shell

1

2

3

sudo add-apt-repository ppa:teejee2008/ppa

sudo apt-getupdate

sudo apt-getinstall selene

VP9 Encoding with Selene in Ubuntu 15.10 (Click to Enlarge)

Once you start the program, click Add Files, select preset “WebM Video (webm), and click on the bottom right icon to adjust the preset settings such as codec (VP8/VP9), bitrate, and so on. VP9 encoding in Ubuntu 14.04 did not work, even after install ffmpeg, as the program appears to only use avconv, but I did work in Ubuntu 15.10.

I selected VP9, variable bitrate, 2000 kbps and “best” speed at first, but I should have read the tooltips, as the encoding was done at about 0.3 fps in my machine (AMD FX8350 with 16GB RAM), and speed settings are described as below (with actual command show below):

The comment form collects your name, email and content to allow us keep track of the comments placed on the website. Please read and accept our website Terms and Privacy Policy to post a comment.

Subscribe

newestoldestmost voted

Notify of

Guest

Cdan

VP9 is not optimized for home PC encoding, it is specifically tailored to encoding video across datacenter servers with large numbers of CPU’s in action, in other words Youtube’s own gear.

However in time it will hopefully be optimized better for home use particularly with VP10 if it becomes the defacto codec for Internet streaming media.

The reason H.265/HEVC is not supported is because the IP licensing around it is toxic, a group broke away from MPEG LA (H.264/H.265 license pool) and demanded outrageous fees for anyone streaming video over the internet. Some of the companies involved tried this many years ago with MPEG-4 ASP (DivX/XviD) and it killed that format dead as no one would use it other than pirates.

So big tech companies were spooked and have now sided with Google on VP10 being the next gen codec, H.265 will still be used in Blu-ray/TV but not internet media sites, those will remain H.264 until VP10 is ready.

Vote Up0Vote Down Reply

3 years ago

Guest

ValdikSS

You can use CRF encoding with vp9 too. Set bitrate to 0 and CRF to some value.: