Presenting Hap, a family of open-source GPU accelerated video codecs

[Update July 2018 – there is a new website with the latest information about the HAP video codecs: http://hap.video]

Today we are happy to share the fruits of a collaboration with Tom Butterworth that has been in the works for a while: Hap, a new video codec designed for digital video artists and VJs with the goal of achieving higher-performance video playback in OpenGL-based applications such as VDMX.

Instead of using the CPU to decode video frames, Hap passes compressed image data directly to your computer's graphics card to perform hardware accelerated decompression of movies during playback. By shifting this burden from your CPU to your GPU, Hap makes it both possible to use more movies and work at higher resolutions than typical CPU-bound codecs.

There are four different Hap codecs to choose from: Hap offers the lowest data rates for playing back the most clips at a time, Hap Alpha is similar to Hap with support for transparency, and Hap Q and Hap Q Alpha offer improved image quality at a higher data rate.

Getting started with Hap is easy: just download and run the latest installer for VDMX:  http://vidvox.net/download/vdmx_demo

Or visit the downloads page to find the standalone codec installers to use with other applications:

http://hap.video/using-hap.html

Once installed on your Mac or PC, Hap, Hap Alpha and Hap Q / Hap Q Alpha will show up as options in the export panel in all your regular QuickTime applications. More information on transcoding movies to the Hap format along with a standalone installer for the QuickTime component can be found in the movie exporting tutorial. We've also made some  free a/v sample clips available for download in Hap at 1080p and 480p.

Movies using the Hap codec will work in any QuickTime-based application, but Hap's hardware-accelerated speed gains will only be seen in apps that natively support it. This is why we're open-sourcing the Hap codec under the Free BSD License: it can be used completely free of charge by other developers of commercial and non-commercial software alike. More information can be found on the GitHub page: http://github.com/Vidvox/hap - if you want your favorite video application to support OpenGL-based image decoding, this is the link you should send them!

5 Layers of 1080p encoded in Hap playing in VDMX on 2.6 GHz Intel Core i7 Retina MacBook Pro.

Movies can be converted to Hap, Hap Alpha, and Hap Q from the standard QuickTime Export Panel. 


When should I use Hap?  Will my hardware support Hap?

For most realtime video projects, traditional CPU-based codecs such as Photo-JPEG or the Apple Intermediate Codec offer a reasonable tradeoff between image quality, CPU use and file size. However, when you need to play back a lot of movies at once — particularly if they are high-res — the CPU load may exceed the limits of your processors. These situations are where highly optimized codecs (like Hap) are most useful. On the Mac you will need to be running 10.6.8 or later, on PC Vista or newer — you don't need a super-fast computer, but you do need a fast drive for playback (preferably an SSD).


How does Hap compare to other codecs?  What are the pros and cons?

The main benefit of Hap is a greatly reduced CPU load during movie playback. This comes at the cost of higher data-rates, which can vary depending on the amount of detail in the content being played back. This is why you need a fast drive, such as an SSD, to benefit from Hap.

CPU Usage (%) GPU Throughput (Mbit/s) Data Rate (Mbit/s)
AIC
34
760
62
Photo JPEG
26
760
35
DXV
20
190
127
Hap
10
190
134
Hap Q
16
380
280

Animation Alpha
21
1520
133
DXV Alpha
24
380
97
Hap Alpha
16
380
100
1080 HD frames at 24 frames per second, measured on a dual-core 2.66 GHz i7 MacBook Pro (shorter bars are better)

More stats and sample clips in our follow up blog post.

For most video, Hap produces good quality images which are largely indistinguishable from the original during playback. However, the type of image compression used by Hap is based on OpenGL technologies that make it inherently lossy - like all such codecs, some artifacting may occur. When this becomes noticeable, the Hap Q codec can be used to significantly improve image quality as demonstrated in the following sets of images.

 

​Original render.

Original, zoomed.

​Hap encoded.

​Hap Q encoded.​

 
 

​Original photo.

​Original, zoomed.

​Hap encoded.

​Hap Q encoded.

 

Lastly, it's important to note that you'll only benefit from using Hap if your video application natively supports it: if you aren't sure, check with its developers before transcoding your clips. If you want to see Hap supported in other QuickTime-based video apps, please ask its developers to check out Hap on GitHub, where we have simple sample code demonstrating its use.

Thanks for taking the time to read about Hap. If you'd like to try it out here are links to sample clips in Hap at 1080p and 480p which can be used with the latest version of VDMX! Or download the Photo-JPEG 1080p versions to transcode into other formats.

And one more huge shout out to Tom Butterworth, without whom this would not have been possible.