digitalaudionerd
25th October 2022, 05:32
I wrote a command line script that interleaves the AC3 and Dolby TrueHD bit streams in the exact manner found in blu-ray. Even though I wrote this script for my selfish purposes, because it would be useful to others, I’ve decided to freely share it on GitHub: https://github.com/digitalaudionerd/Interleave-AC3-TrueHD-Streams
I developed this script on Linux, but, because Python is cross-platform, it should run on any system with Python 3.
If you wish to find out how I know that this script produces interleaved AC3/TrueHD bit streams exactly as they are found in blu-ray, please continue reading.
Testing
I had some .ac3, .thd and .thd+ac3 files. After having my script interleave the various .ac3 and .thd files, I compared the .thd+ac3 files it made to the original .thd+ac3 files. The interleaved .thd+ac3 files were identical to the original .thd+ac3 files.
Content with those tests, I interleaved a set of .ac3 and .thd files from an MKV file. I then used the video from the MKV file and its newly corresponding .thd+ac3 file to create an AVCHD with tsMuxer. I transferred the AVCHD to my NAS and watched the AVCHD with my Oppo UDP-203 blu-ray player (my selfish purpose).
My Oppo identified the audio stream as Dolby TrueHD (if the audio track is only TrueHD without the AC3 “core,” the Oppo identifies the stream as MLP). My Denon AV receiver decoded the TrueHD audio, just as with any Dolby TrueHD blu-ray or blu-ray backup.
How do I know the structure of AC3 and TrueHD interleaving in blu-ray?
Before writing this interleave script, I wrote a previous Python script that examined the AC3 frames and TrueHD access headers of the .thd+ac3 files I had. After making the script count the frames and access headers, I noticed a clearly distinct pattern consistent in all of the .thd+ac3 files.
I developed this script on Linux, but, because Python is cross-platform, it should run on any system with Python 3.
If you wish to find out how I know that this script produces interleaved AC3/TrueHD bit streams exactly as they are found in blu-ray, please continue reading.
Testing
I had some .ac3, .thd and .thd+ac3 files. After having my script interleave the various .ac3 and .thd files, I compared the .thd+ac3 files it made to the original .thd+ac3 files. The interleaved .thd+ac3 files were identical to the original .thd+ac3 files.
Content with those tests, I interleaved a set of .ac3 and .thd files from an MKV file. I then used the video from the MKV file and its newly corresponding .thd+ac3 file to create an AVCHD with tsMuxer. I transferred the AVCHD to my NAS and watched the AVCHD with my Oppo UDP-203 blu-ray player (my selfish purpose).
My Oppo identified the audio stream as Dolby TrueHD (if the audio track is only TrueHD without the AC3 “core,” the Oppo identifies the stream as MLP). My Denon AV receiver decoded the TrueHD audio, just as with any Dolby TrueHD blu-ray or blu-ray backup.
How do I know the structure of AC3 and TrueHD interleaving in blu-ray?
Before writing this interleave script, I wrote a previous Python script that examined the AC3 frames and TrueHD access headers of the .thd+ac3 files I had. After making the script count the frames and access headers, I noticed a clearly distinct pattern consistent in all of the .thd+ac3 files.