Monday, May 5, 2014

HEVC and VP9 video codecs - try them yourself


Abharana Bhat and Iain Richardson, May 2014

High efficiency video coding (HEVC) and Google / WebM VP9 are new codec formats designed to support HD and ultra HD streaming and broadcasting. This article explains how to start experimenting with HEVC and VP9 encoding. This is a short summary of the full article available at http://www.vcodex.com/h265.html

1.    HM reference software for HEVC

The HM software codec is a reference implementation of the HEVC coding standard developed by the Joint Collaborative Team on Video Coding (JCT-VC). It is suitable for experimenting with the various features available in the HEVC coding standard and/or for checking compliance, but may not be suitable for real-time implementations. The following steps will show you how to build and run the HM codec.

Step 1: Get the source code
Step 2: Build the software according to the instructions here:
Step 3: Using the encoder

The HEVC encoder requires three inputs:
·       uncompressed (raw) YUV or Y4M file,
·       codec configuration file
·       sequence specific configuration file
For example, the following command line runs the HM encoder with codec configuration file encoder_randomaccess.cfg and sequence configuration file jockey.cfg.
./TAppEncoder -c encoder_randomaccess.cfg -c jockey.cfg
Step 4: Decoding and playback

The encoder will output two files: a compressed .bin file and a reconstructed .yuv file. The YUV file can be played back using a YUV player such as GLYUVPlay. GPAC’s Osmo4 player can playback the .bin file if you change the file extension from .bin to .mp4.

2.    x265 encoder for HEVC

x265 is an open source software and library for HEVC encoding and decoding developed by a consortium led by MulticoreWare. It is available under the GNU General Public License. 
The software can be used as a standalone tool or with FFMPEG as a library. The download and installation instructions are as follows:

Step 1: Get the source code and install instructions from https://bitbucket.org/multicoreware/x265/wiki/Home.

Step 2: Follow the install instructions. Check if installation is successful by typing x265 at the terminal.

Step 3: The command line to run the encoder is

x265 [options] infile [-o] outfile

whereinfile” is an uncompressed source file (YUV or Y4M) and “outfile” is a compressed HEVC bitstream.

Step 4: Use x265 as a library in the FFMPEG framework

To use the x265 encoder via FFMPEG, install x265 by following steps 1-4 and re-configure FFMPEG with -enable-libx265.
The command line for using x265 library via FFMPEG is:
ffmpeg -i [input] -c:v libx265 [options] output[.265/.mkv]

FFMPEG currently does not support the MP4 file format for HEVC files. You can use MP4Box to convert .265 to mp4 format.

3.    WebM VP9 codec

Step 1: Download and install the vp9 codec from the WebM project website: http://www.webmproject.org/code/ 

Step 2 Type vpxenc at the command line to see if the installation was successful.

Step 3: Example command line for running the vp9 encoder using vpxenc.

vpxenc --codec=vp9  --profile=0  --fps=50000/1001 --static-thresh=0 --drop-frame=0 --good --auto-alt-ref=1  --kf-min-dist=50 --kf-max-dist=50 --min-q=32 --max-q=32 --max-intra-rate=50 -threads 4 -w 1280 -h 720 --limit=500  in_to_tree_420_720p500.yuv -o in_to_tree_420_720p500_vp9_qp32.webm

Step 4: Decoding and playback

Option 1: convert to uncompressed YUV video using FFMPEG for playback using the following command line:

ffmpeg -i input.webm -f rawvideo out.yuv

Option 2: use the latest version of VLC player to playback the webm file.

To find out more

Visit  http://www.vcodex.com/h265.html for a full version of this article and for more resources on HEVC, VP9 and other video codecs.