A Look at Vidvox.net’s Open Source Hap Codecs, and How They Work
I’ve written about codecs in the past, and generally speaking, they more or less do the same job: compress and decompress video frames. And with new ones being created continually to address specific performance-related needs, it is not reasonable to definitively say “this one is best” without taking into account external factors like hardware, application needs, etc.
Having said that, in the world of real-time media playback and video mixing, one codec in particular has caught on like wildfire since its creation in 2013; that codec is Hap. Let’s take a closer look at some of the advantages (and a few disadvantages) of this popular codec.
Hap: What Is It?
In a one-sentence summary, the Hap codec is an open-source GPU video codec that supports transparency. It was first developed for VDMX, the OpenGL-based media playback software, and companies like U.K. based experiential design firm Renderheads prefer it because it “allows… visual artists to perform in real-time on consumer level hardware using multiple layers of high resolution videos without dropping frames.”* (See “More Resources,” below)
Okay, so you’re probably thinking, “That sounds interesting, but how does it do that?” Well, the answer lies in how it performs the task of data decompression. Vidvox.net, the creators of Hap, explain it succinctly: “Instead of using the CPU to decode video frames, HAP passes compressed image data directly to [the] computer’s graphics card to perform hardware accelerated decompression of movies during playback. By shifting this burden from your CPU to [the] GPU, HAP makes it both possible to use more movies and work at higher resolutions than typical CPU-bound codecs.”** (See “More Resources,” below)
Hap is not unique in being a GPU based codec. In fact, there are many GPU codecs available that work in the same way. But many of them are written to perform on specific hardware; nVidia Video Codec SDK, for example, is intended for nVidia graphics cards. What makes Hap particularly useful is that it works with both 32-bit and 64-bit software, and on both Macs and PCs via Hap for QuickTime (Mac or Windows) or Hap for Direct Show Codec (Windows only).
How does Hap compare to CPU-based codecs like Photo-Jpeg or AIC? As vidvox.net states, “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.”** (See below)
There are four Hap codecs: Hap, Hap Alpha, Hap Q, and Hap Q Alpha. Each one has a pro and a con, so it’s important to decide what your application requires and choose the one that best suits that goal. Hap has the lowest data-rate and a low image quality. Hap Alpha has the same image quality as Hap, but with Alpha channel support; therefore, the size of a Hap Alpha file will be about twice the size of a Hap file. Hap Q has a better image quality, but does not support an Alpha channel; the size of a Hap Q file will be approximately twice the size of a Hap file. Hap Q Alpha has the highest image quality of the Hap codec family as well as Alpha channel support, but at the expense of also having the largest file size as well.*** (See “More Resources,” below)
Because using Hap makes it possible to run multiple layers of HD video in real-time, the general consensus among ‘VJ’ style visual artists and a growing number of developers of pro-level media server/control systems is that the HAP codec is preferred. And what matters most is that, come showtime, if the computer can keep up with the person driving it, that’s a good time for all.
More Resources and Downloads
- The family of Hap codecs can be downloaded from this link: plsn.me/Hap-Aug-2017.
- For more information, here are the sources that Vickie used for this month’s column, including the asterisked items referenced above and a few more.
- *“HAP For Direct Show: Fast GPU Friendly Video Codec for Windows”. Renderheads. 2015. (www.renderheads.com/product/hap-for-directshow)
- **“Presenting Hap, a family of open-source GPU accelerated video codecs.” vidvox.net. February 26, 2013. (http://vdmx.vidvox.net/blog/hap)
- *** “Hap,” from Derivative, (https://www.derivative.ca/wiki088/index.php?title=Hap)
More Downloads:
- “GPU accelerated video playback in GoGe: Meet with the Hap codec!”. Imimot, Jan. 27, 2014; http://imimot.com/blog/gpu-accelerated-video-playback-in-coge-meet-with-the-hap-codec.
- “How to reduce video bitrate of realtime applications using the Hap codec,” Francois “Coyhot” Grassard, Feb. 28, 2016, http://www.coyhot.com/how-to-reduce-video-bitrate-of-realtime-applications-using-the-hap-codec/.
- “Supported Formats,” www.ventuz.com
- www.ventuz.com/support/help/latest/SupportedFormats.html?itm=9
- “Hap: A codec for fast video playback,” vidvox, 2017, www.github.com/Vidvox/hap