Friday, January 02, 2009

Converting AAC-HE LATM files to play on a Popcorn

As noted in a previous post TVNZ has chosen to broadcast its HD shows with H.264 video which is fine but AAC-HE LATM audio. This relatively new codec is difficult to handle on the PC platform though of course the DVB-T STB's can handle it. Only few programs can handle this audio including PowerDVD8, Winamp and some freeware/opensource software like gbpvr and mediaportal.

In order to process these files to play on the Popcorn Hour (a great media player by the way) I have had to resort to the following tortuous process.

Install PowerDVD8 (trial seems to be fine) to get the right audio codec loaded.

Play around with the merit values on the DS filters so that the PDVD8 Demuxer has a merit value of Preferred+1 (I am using Radlight to do this).

Load the ts file captured by gbpvr into Virtualdub using an avisynth script which only has one statement in it directshowsource("video file.ts")

If you have the filters right, the PDVD8 demux DS filter will pass the video/audio to Virtualdub. From there you can look at the properties of the audio. On my machine for some reason the audio is always sampled at 24Khz so I use Virtualdub to do a conversion to 48Khz. Then just save the wav file.

Next process the wav file into a more reasonable format (I use besweet to convert to AC3).

Finally using tsmuxer I input the original ts file (tsmuxer will complain about unrecognised audio - this is the AAC audio) and drop it. Then add in the AC3 file created above and output a new ts file with AC3 audio.

This will play fine on the Popcorn and VLC. There is a bit of art involved in this since on occasion the audio/video will not be in sync but luckily it is a constant difference. I have seen differences between 100ms (surprisingly easy to notice when looking at mouths speaking) to up to 1000ms. Anyway some experimentation and you can adjust the delay settings in tsmuxer to cater for that.

A lot of work but it can be done. Now Syabas - roll on a new firmware upgrade for the Popcorn Hour to handle this audio format.