Open Source H.264 Codec
C++ Assembly C Shell Objective-C Makefile Other
Latest commit 0724f61 Feb 28, 2017 @ruil2 ruil2 committed on GitHub Merge pull request #2664 from shihuade/SecurityIssue
fixed security issue for window dll project setting
Failed to load latest commit information.
autotest update scripts Dec 18, 2015
build Merge pull request #2647 from moriyoshi/moriyoshi/cygwin-x86_64-support Jan 23, 2017
codec fixed security issue for window dll project setting Feb 27, 2017
docs 1.doxgen documentation format for comments in api/*.h 2. comments to … Nov 21, 2014
module Make sure the output resolution of encoder doesn't exceed the Openh26… Jul 1, 2016
res fix parseonly length overflow Feb 16, 2017
test Merge pull request #2657 from huili2/parseonly_length_overflow_crashf… Feb 20, 2017
testbin modify configure file comments Jun 6, 2016
.gitignore Update .gitignore Apr 4, 2016
.reviewboardrc ReviewBoard .rc file for rbt. Jan 6, 2014
.travis.yml add SCC and SVC mulitilayer cases for encoder biniary comparison test Sep 30, 2016
CODING_STYLE Rerun astyle on the C++ source files Jan 5, 2014
CONTRIBUTORS Added support for "video signal type present" information. Feb 23, 2016
LICENSE Initial commit Oct 27, 2013
Makefile Properly set the version in openh264.pc Jan 2, 2017 updates Oct 23, 2016
RELEASES Update the binary files location for release v1.6.0 Jul 21, 2016 remove trailing white spaces Mar 13, 2014 change output interface Dec 2, 2015
openh264.def Convert tabs to spaces in .def files May 14, 2015 Include private dependencies in the Libs line in pkg-config if only i… Jan 2, 2015
openh264.rc change API for slicing part for easier usage (the UseLoadBalancing fl… Nov 10, 2015
openh264.rc.template Update openh264.rc when updating the version number Apr 20, 2015 Build using -Werror in travis unit tests Jan 16, 2015
ut.def Convert tabs to spaces in .def files May 14, 2015


OpenH264 is a codec library which supports H.264 encoding and decoding. It is suitable for use in real time applications such as WebRTC. See for more details.

Encoder Features

  • Constrained Baseline Profile up to Level 5.2 (Max frame size is 36864 macro-blocks)
  • Arbitrary resolution, not constrained to multiples of 16x16
  • Rate control with adaptive quantization, or constant quantization
  • Slice options: 1 slice per frame, N slices per frame, N macroblocks per slice, or N bytes per slice
  • Multiple threads automatically used for multiple slices
  • Temporal scalability up to 4 layers in a dyadic hierarchy
  • Simulcast AVC up to 4 resolutions from a single input
  • Spatial simulcast up to 4 resolutions from a single input
  • Long Term Reference (LTR) frames
  • Memory Management Control Operation (MMCO)
  • Reference picture list modification
  • Single reference frame for inter prediction
  • Multiple reference frames when using LTR and/or 3-4 temporal layers
  • Periodic and on-demand Instantaneous Decoder Refresh (IDR) frame insertion
  • Dynamic changes to bit rate, frame rate, and resolution
  • Annex B byte stream output
  • YUV 4:2:0 planar input

Decoder Features

  • Constrained Baseline Profile up to Level 5.2 (Max frame size is 36864 macro-blocks)
  • Arbitrary resolution, not constrained to multiples of 16x16
  • Single thread for all slices
  • Long Term Reference (LTR) frames
  • Memory Management Control Operation (MMCO)
  • Reference picture list modification
  • Multiple reference frames when specified in Sequence Parameter Set (SPS)
  • Annex B byte stream input
  • YUV 4:2:0 planar output

OS Support

  • Windows 64-bit and 32-bit
  • Mac OS X 64-bit and 32-bit
  • Linux 64-bit and 32-bit
  • Android 64-bit and 32-bit
  • iOS 64-bit and 32-bit
  • Windows Phone 32-bit

Processor Support

  • Intel x86 optionally with MMX/SSE (no AVX yet, help is welcome)
  • ARMv7 optionally with NEON, AArch64 optionally with NEON
  • Any architecture using C/C++ fallback functions

Building the Library

NASM needed to be installed for assembly code: workable version 2.10.06 or above, NASM can downloaded from For Mac OSX 64-bit NASM needed to be below version 2.11.08 as NASM 2.11.08 will introduce error when using RIP-relative addresses in Mac OSX 64-bit

To build the arm assembly for Windows Phone, gas-preprocessor is required. It can be downloaded from git://

For Android Builds

To build for android platform, You need to install android sdk and ndk. You also need to export **ANDROID_SDK**/tools to PATH. On Linux, this can be done by

export PATH=**ANDROID_SDK**/tools:$PATH

The codec and demo can be built by


Valid **ANDROID_TARGET** can be found in **ANDROID_SDK**/platforms, such as android-12. You can also set ARCH, NDKLEVEL according to your device and NDK version. ARCH specifies the architecture of android device. Currently arm, arm64, x86 and x86_64 are supported, the default is arm. (mips and mips64 can also be used, but there's no specific optimization for those architectures.) NDKLEVEL specifies android api level, the default is 12. Available possibilities can be found in **ANDROID_NDK**/platforms, such as android-21 (strip away the android- prefix).

By default these commands build for the armeabi-v7a ABI. To build for the other android ABIs, add ARCH=arm64, ARCH=x86, ARCH=x86_64, ARCH=mips or ARCH=mips64. To build for the older armeabi ABI (which has armv5te as baseline), add APP_ABI=armeabi (ARCH=arm is implicit). To build for 64-bit ABI, such as arm64, explicitly set NDKLEVEL to 21 or higher.

For iOS Builds

You can build the libraries and demo applications using xcode project files located in codec/build/iOS/dec and codec/build/iOS/enc.

You can also build the libraries (but not the demo applications) using the make based build system from the command line. Build with

make OS=ios ARCH=**ARCH**

Valid values for **ARCH** are the normal iOS architecture names such as armv7, armv7s, arm64, and i386 and x86_64 for the simulator. Another settable iOS specific parameter is SDK_MIN, specifying the minimum deployment target for the built library. For other details on building using make on the command line, see 'For All Platforms' below.

For Windows Builds

Our Windows builds use MinGW which can be downloaded from

To build with gcc, add the MinGW bin directory (e.g. /c/MinGW/bin) to your path and follow the 'For All Platforms' instructions below.

To build with Visual Studio you will need to set up your path to run cl.exe. The easiest way is to start MSYS from a developer command line session. Instructions can be found at If you need to do it by hand here is an example from a Windows 64bit install of VS2012:

export PATH="$PATH:/c/Program Files (x86)/Microsoft Visual Studio 11.0/VC/bin:/c/Program Files (x86)/Microsoft Visual Studio 11.0/Common7/IDE"

You will also need to set your INCLUDE and LIB paths to point to your VS and SDK installs. Something like this, again from Win64 with VS2012 (note the use of Windows-style paths here).

export INCLUDE="C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include;C:\Program Files (x86)\Windows Kits\8.0\Include\um;C:\Program Files (x86)\Windows Kits\8.0\Include\shared"
export LIB="C:\Program Files (x86)\Windows Kits\8.0\Lib\Win8\um\x86;C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\lib"

Then add OS=msvc to the make line of the 'For All Platforms' instructions.

For Windows Phone Builds

Follow the instructions above for normal Windows builds, but use OS=msvc-wp instead of OS=msvc. You will also need gas-preprocessor (as mentioned below "Building the Library").

If building for Windows Phone with MSVC 2013, there's no included bat file that sets the lib paths to the Windows Phone kit, but that can be done with a command like this:

export LIB="c:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\lib\store\arm;c:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\lib\arm;c:\Program Files (x86)\Windows Phone Kits\8.1\lib\arm"

This is only necessary for building the DLL; the static library can be built without setting this.

For All Platforms

From the main project directory:

  • make for automatically detecting architecture and building accordingly
  • make ARCH=i386 for x86 32-bit builds
  • make ARCH=x86_64 for x86 64-bit builds
  • make V=No for a silent build (not showing the actual compiler commands)
  • make DEBUGSYMBOLS=True for two libraries, one is normal libraries, another one is removed the debugging symbol table entries (those created by the -g option)

The command line programs h264enc and h264dec will appear in the main project directory.

A shell script to run the command-line apps is in testbin/

Usage information can be found in testbin/CmdLineReadMe

Using the Source

  • codec - encoder, decoder, console (test app), build (makefile, vcproj)
  • build - scripts for Makefile build system
  • test - GTest unittest files
  • testbin - autobuild scripts, test app config files
  • res - yuv and bitstream test files

Known Issues

See the issue tracker on

  • Encoder errors when resolution exceeds 3840x2160
  • Encoder errors when compressed frame size exceeds half uncompressed size
  • Decoder errors when compressed frame size exceeds 1MB
  • Encoder RC requires frame skipping to be enabled to hit the target bitrate, if frame skipping is disabled the target bitrate may be exceeded


BSD, see LICENSE file for details.