Hap encoding on linux/osx/win now possible with Libav

Just a heads up: a Hap encoder/decoder was added yesterday to Libav.
(On the master git branch that is, not in a released/compiled version yet).

I just tried it (with some help of libav developer Vittorio Giovara who added the hap encoder/decoder), and it works perfectly. Now for the first time you can encode all your video’s to Hap on command line on a linux / osx /windows box :stuck_out_tongue:

Hap decoding works out of the box, Hap encoding needs an additional dependency, which is libsnappy.
When you have that installed, you have to configure Libav with --enable-libsnappy, compile it, and then you should be able to encode with this command line:

avconv -i mysourcefile.mp4 -vcodec hap -format hap_q thiswillbemyhapfile.mov

you can change the “format hap_q” bit to hap, hap_alpha or hap_q.
There is no further quality setting.

Happy encoding!
PS for OS X homebrew users I adapted the libav brew formula so you can install/compile it supereasy, let me know it you want it.

Looking at the patch, I don’t think they’ve added support for the chunked encoding yet, which is needed when you get to very high resolutions or frame rates. So just FYI you’ll still want to encode with TD for those cases.

Hey Malcolm could you tell a bit more about hap chunked encoding?

The on the CPU side of the Hap codec it does what is called ‘Snappy’ compression. For a 4Kx2K image this takes about 8ms. As you get up to higher resolutions this starts to be too high to maintain 60hz.
Chunked encoding allows the decompression of this data to be multi-threaded, bringing the decompress time way down.

Thanks for the info!

in the meantime, Hap chunked encoding has been added to libav (to the master git branch)

You have to set “-chunks XXX” in the encoding commandline and manually specify the number of chunks your video needs.

Hey all

Trying to follow this workflow on Windows (not using Touch Designer, but this thread was informative so thought it best to add to the conversation here).

From what I’ve found, the public windows build of libav (avconv) is not built with snappy, so it doesn’t support HAP, and you’d have to build libav yourself to get a version which does (which is no easy feat since you’ll need mingw and minsys2 to get started with that). I was about to start down that path, then checked in on ffmpeg. According to the ffmpeg readme, the 64bit static build was built with libsnappy enabled (ffmpeg.zeranoe.com/builds/readm … readme.txt) so I’m going to give that a try and let you know how I got on.

OK, i can confirm that

ffmpeg -framerate 60 -f image2 -i %07d.png -vcodec hap -chunks 16 hap.mov

is open for business!

(note : this post was edited to correct the input framerate option)

Nice find, didn’t know ffmpeg had also accepted the hap encoding feature in its source.

Hi, could you please share your homebrew formula for libav? I tried to convert with

ffmpeg -i in.mkv -vcodec hap -fs 100MB out_hap.mkv

but I get “Unknown encoder ‘hap’”. I installed libav via homebrew.

Well as this thread is already two years old I don’t have that specific macbook handy anymore :wink: But these days HAP is already included with ffmeg standard version, but you just need to install snappy compression as well. I think on macOS with homebrew this should do it:

brew install ffmpeg --with-snappy

See further instructions here: Encoding to Hap from the command line using FFmpeg