Log in

View Full Version : Dolby TrueHD encoder? / DTS HD MA re-muxing issue


Lucius Snow
30th October 2021, 14:22
Hi all,

Except Dolby Media Producer, do you know any software which encodes PCM tracks to Dolby TrueHD?

I tried to mux a .dtshd audio file into BDedit but it results a m2ts file without an audio track. It seems it doesnt't occur with TrueHD files. Maybe is this link to this: https://forum.doom9.org/showthread.php?t=153498 ?

Thanks.

tebasuna51
30th October 2021, 21:36
Except Dolby Media Producer, do you know any software which encodes PCM tracks to Dolby TrueHD?

ffmpeg -i "INPUT" -vn -strict -2 -acodec truehd "OUTPUT.thd"

I tried to mux a .dtshd audio file into BDedit but it results a m2ts file without an audio track. It seems it doesnt't occur with TrueHD files. Maybe is this link to this: https://forum.doom9.org/showthread.php?t=153498 ?

In that thread have enough info about .dtshd, use eac3to to remove the extra header if BDedit don't support it.

Lucius Snow
30th October 2021, 22:36
[QUOTE=Lucius Snow;1956138]Except Dolby Media Producer, do you know any software which encodes PCM tracks to Dolby TrueHD?[/QUOTE

ffmpeg -i "INPUT" -vn -strict -2 -acodec truehd "OUTPUT.thd"
Good to know! A few questions about this:

- Should I make a single wave file with L/R/C/LFE/Ls/Rs audio mapping for a 5.1?

- Is it possible to configure the downmix options?

- When running the command with this kind of file, the encoder says "Only mono and stereo are supported at the moment". Strange thing because Mediainfo confirms the multichannel:

General
Complete name : E:\test1.thd
Format : MLP FBA
Format/Info : Meridian Lossless Packing FBA
Commercial name : Dolby TrueHD
File size : 271 MiB
Overall bit rate mode : Variable

Audio
Format : MLP FBA
Format/Info : Meridian Lossless Packing FBA
Commercial name : Dolby TrueHD
Bit rate mode : Variable
Maximum bit rate : 9 597 kb/s
Channel(s) : 6 channels
Channel layout : L R C LFE Ls Rs
Sampling rate : 48.0 kHz
Frame rate : 1 200.000 FPS (40 SPF)
Compression mode : Lossless


BDFix requires the AC3 file with it. I suppose it's the core. Should it be a separate encode in 640 kbit/s? By the way, the bitrate reaches almost 10 Mbit/s which looks high comparing to others similar files that I checked.

In that thread have enough info about .dtshd, use eac3to to remove the extra header if BDedit don't support it.
I haven't found the right line command to rewrite the file from a .dtshd file input.

Richard1485
30th October 2021, 23:41
BDFix requires the AC3 file with it. I suppose it's the core.

You should be able to add a "core" with eac3to:

eac3to input.thd output.thd+ac3
AFAIK, ffmpeg doesn't yet have the option to encode TrueHD with a "core". If it does, I'd like to know how myself...

tebasuna51
31st October 2021, 11:17
Also you can use eac3to to remove the extra header of a dtshd created with DTS-HD Master Audio:

eac3to input.dtshd output.dts

the output remain DTS HD but without the extra header.
DTS-HD Master Audio can create the same if you use extension .cpt

tebasuna51
31st October 2021, 11:39
A few questions about this:

- Should I make a single wave file with L/R/C/LFE/Ls/Rs audio mapping for a 5.1?

ffmpeg accept many formats like input, of course a correct wav or w64 uncompresed file but also dtshd, flac, ...

- Is it possible to configure the downmix options?

- When running the command with this kind of file, the encoder says "Only mono and stereo are supported at the moment". Strange thing because Mediainfo confirms the multichannel

The codec is experimental (for that the -strict -2), undocumented and not optimized. It is not a recommended lossless format (https://forum.doom9.org/showthread.php?p=1954754#post1954754) use only for compatibility reasons.

Lucius Snow
31st October 2021, 13:31
Thank you guys for these details.

Well, even with the extra header removed from the DTS file, BDFix corrupts the .m2ts remuxing. I have no idea why. However, I know it works with MultiAVCHD (through TSmuxer) but Eclipse software check fails in replication. BDFix doesn't.

BDFix with Dolby TrueHD may be the solution but would it be 100% compliant as it is experimental? We don't know how the downmix would be made. Also, the .thd file should integrate a framerate metadata that ffmpeg can't do, it seems.

Anyone would be able to check what's going on with BDFix and DTS HD?

EDIT : Just checked the .thd size file, it's 271 MB while the .wav takes 1,14 GB. Conclusion: It actually takes only two channels (stereo) since the ratio compression is 70%. Let' forget ffmpeg :\

SeeMoreDigital
31st October 2021, 14:22
Using a 6 channel pcm.wav as a source, a few hours ago I managed to create a 6 channel TrueHD .thd audio stream.

However, after muxing the .thd stream within the .mkv container along with some video (using mkvtoolnix-gui) and playing it with my OPPO, nothing could be heard.

I also tried adding an AC3 core (using UsEac3to) and muxing everything into the .m2ts container (using TSmuxerGUI), but again nothing can be heard.

On the good side... The OPPO reports that the Dolby TrueHD streams are present for both containers...

Lucius Snow
31st October 2021, 14:30
Using a 6 channel pcm.wav as a source, a few hours ago I managed to create a 6 channel TrueHD .thd audio stream.
That's what Mediainfos's metadatas show here too. But the size file shows it can only contain two channels, like ffmpeg warns about when we run the command.

SeeMoreDigital
31st October 2021, 14:51
But the size file shows it can only contain two channels, like ffmpeg warns about when we run the command.Actually no, the TrueHD encode does have 6 channels.

Indeed, this can easily be checked by re-encoding the TrueHD audio stream to a different audio format, such as FLAC... Which is what I have done for confirmation ;)

Lucius Snow
31st October 2021, 14:55
Actually no, the TrueHD encode does have 6 channels.

Indeed, this can easily be checked by re-encoding the TrueHD audio stream to a different audio format, such as FLAC... Which is what I have done for confirmation ;)

Can you please give me your source size file (all PCM 6 channels cumulated) and the .thd one?

Richard1485
31st October 2021, 14:59
Yeah, I split the TrueHD 5.1 file that ffmpeg produced back to wavs and got my original mono wavs back. Maybe try burning eact3o's output to disc to see if that works in the Oppo.

SeeMoreDigital
31st October 2021, 15:06
Here you go: https://www.sendspace.com/file/utrnry

Lucius Snow
31st October 2021, 15:47
You're right, all 6 channels are here. But there's something wrong...

My sample test files - 20 min - 6 channels :

WAVE - PCM (source) : 1 GB
TrueHD (by Dolby Media Producer) : 608 MB
TrueHD (by ffmpeg) : 187 MB

If you convert back your TrueHD made by ffmpeg, you'll see it 16 bit only! So why doesn't ffmpeg support 24 bit as TrueHD output?

richardpl
31st October 2021, 16:00
I doubt that is case, use -c:a pcm_f24le when muxing into wav. As default one is pcm16 always.

Lucius Snow
31st October 2021, 16:05
I doubt that is case, use -c:a pcm_f24le when muxing into wav. As default one is pcm16 always.
That doesn't change anything, fffmpeg already considers the source as 24 bit.

Input #0, wav, from 'E:\test.wav':
Metadata:
date : 2021-10-31T16:15:02+01:00
encoder : Adobe Audition 12.1 (Windows)
Duration: 00:23:37.33, bitrate: 6912 kb/s
Stream #0:0: Audio: pcm_s24le ([1][0][0][0] / 0x0001), 48000 Hz, 5.1, s32 (24 bit), 6912 kb/s
Multiple -c, -codec, -acodec, -vcodec, -scodec or -dcodec options specified for stream 0, only the last option '-c:a truehd' will be used.
File 'E:\test3.thd' already exists. Overwrite? [y/N] y
Stream mapping:
Stream #0:0 -> #0:0 (pcm_s24le (native) -> truehd (native))
Press [q] to stop, [?] for help
[truehd @ 000001f060ac1b80] Only mono and stereo are supported at the moment.
Output #0, truehd, to 'E:\test3.thd':
Metadata:
date : 2021-10-31T16:15:02+01:00
encoder : Lavf59.4.101
Stream #0:0: Audio: truehd, 48000 Hz, 5.1, s16, 128 kb/s <- that's not a lossless bitrate
Metadata:
encoder : Lavc59.4.100 truehd

EDIT

It's a know bug:
https://www.mail-archive.com/search?l=ffmpeg-user@ffmpeg.org&q=subject:%22Re%5C%3A+%5C%5BFFmpeg%5C-user%5C%5D%09MLP+encoder%5C%3A+encodes+24%5C-bit+wav+files+into+16%5C-bit+MLP%22&o=newest&f=1

Fixed in 2019:
http://ffmpeg.org/pipermail/ffmpeg-devel/2019-July/246357.html

But where is the right ffmpeg version which includes the fix?

Richard1485
31st October 2021, 16:15
So why doesn't ffmpeg support 24 bit as TrueHD output?

AFAIK, it simply doesn't at present.

ffmpeg -h encoder=truehd

Output:
Encoder truehd [TrueHD]:
General capabilities: delay small exp
Threading capabilities: none
Supported sample rates: 44100 48000 88200 96000 176400 192000
Supported sample formats: s16
Supported channel layouts: stereo 5.0 5.1


EDIT: Sorry. I didn't see your edit. But I've tried multiple builds and can't find one that supports 24-bit.

Lucius Snow
31st October 2021, 16:25
I've jut wrote to the developper to ask if a build including the fix would exist somewhere.

Have you tried the DTS remux with BDFix on your side?

SeeMoreDigital
31st October 2021, 16:26
No doubt, if the PCM.wav audio stream is not a genuine 24-bit encoded source it's superfluous/padded bits will be removed...

Lucius Snow
31st October 2021, 17:01
No doubt, if the PCM.wav audio stream is not a genuine 24-bit encoded source it's superfluous/padded bits will be removed...

Mine is genuine. It looks like a ffmpeg limitation to 16 bit. But why this fix from 2019 was not integrated into the builds?

Richard1485
31st October 2021, 17:23
I tried muxing eac3to's output to BD with tsMuxeR and burning the result to disc. My stand-alone player recognized the audio as TrueHD 5.1, and I could hear the audio, but there was no dialog. My setup is stereo, so I guess this is because of the absence of a downmix option: it sounded like I was hearing just the L and R channels. Is there way to add one? (There were no dialog issues when playing back the m2ts with a software player.)

Maybe someone with a 5.1 setup can do a test (with a physical disc, not mkv). My guess is that it will work.

SeeMoreDigital
31st October 2021, 17:47
Maybe someone with a 5.1 setup can do a test (with a physical disc, not mkv). My guess is that it will work.Sadly... Still no 6Ch TrueHD audio with my OPPO.

I also added a couple of Dolby Digital music tracks to the mux, which could be accessed by the OPPO and heard fine :eek:

Richard1485
31st October 2021, 17:54
Sadly... Still no 6Ch TrueHD audio with my OPPO.

But could you hear anything at all or was the track still silent?

SeeMoreDigital
31st October 2021, 18:14
But could you hear anything at all or was the track still silent?No sound at all from the Dolby TrueHD track. The regular 'lossy' Dolby Digital tracks can be heard fine.

Other Dolby TrueHD sources can be heard okay...

Richard1485
31st October 2021, 18:20
Whereas I could hear just the L and R channels, but they sounded fine... Maybe 5.1 playback will work on some players. Mine's an aging Sony. I don't know of any bitstream filters for TrueHD that might help.

SeeMoreDigital
31st October 2021, 21:07
A few hours ago I created another mux containing three Dolby TrueHD streams. The one created by FFmpeg was placed in-between the two.

My OPPO is able to access all streams tracks and I'm able to hear the first and third tracks perfectly but not the second FFmpeg created track.

Lucius Snow
31st October 2021, 21:20
There's no alternative encoder to Dolby Media Producer but ffmpeg?

Richard1485
31st October 2021, 22:06
^ Not as far as I know.

Stream #0:0: Audio: truehd, 48000 Hz, 5.1, s16, 128 kb/s <- that's not a lossless bitrate


If I use the nightly static build, I get:
Stream #0:0: Audio: truehd, 48000 Hz, 5.1, s32 (24 bit), 128 kb/s (default)
And a bigger file...

videoh
31st October 2021, 22:16
You requested account deletion, so why do you keep posting?

https://forum.doom9.org/showthread.php?p=1956204#post1956204

Happy Halloween to all!

Richard1485
31st October 2021, 22:18
You requested account deletion, so why do you keep posting?

It hasn't been deleted yet and might not be for a few days. While I am here, I can try to lend a hand.

EDIT: Output of ffmpeg -h encoder=truehd with the nighty build:

Encoder truehd [TrueHD]:
General capabilities: delay small exp
Threading capabilities: none
Supported sample rates: 44100 48000 88200 96000 176400 192000
Supported sample formats: s16 s32
Supported channel layouts: stereo 5.0 5.1

After adding a core to the output with eac3to, the result does read as 24-bit in ffmpeg, but it prints an error:
Assignment of matrix channel 0 to invalid output channel -22 is not implemented.

Lucius Snow
31st October 2021, 23:20
Good news! What about the stereo downmix process? Does it work?

richardpl
31st October 2021, 23:50
It is not implemented at all, and nobody is really interested in having it.

Lucius Snow
1st November 2021, 00:00
It is not implemented at all, and nobody is really interested in having it.
So it would be done directly by the standalone player?

Richard1485
1st November 2021, 00:15
^^ Isn't there interest in moving toward compatibility with BD?

What about the stereo downmix process? Does it work?
No, the stereo downmix didn't work on my player, but I didn't really expect that it would.

Lucius Snow
1st November 2021, 00:18
Isn't there interest in moving toward compatibility with BD?

No, the stereo downmix didn't work on my player, but I didn't really expect that it would.

Even with the nightly build + the AC3 core in 640 kbit/s?

It seems VLC makes the stereo downmix correctly. But I have to try tomorrow on my standalone player.

I wish DTS HD MA file would work properly with BDFix. That would be much easier and secure regarding BD compliance. I still don't know why the muxing results as a corruption .m2ts (with or without the DTS extra header). If someone has succeed to remux a DTS HD MA audio track with BDfix, please let me know. MultiAVCHD/TSmuxer do it but it doesn't reach BD compliance.

Richard1485
1st November 2021, 00:22
Even with the nightly build + the AC3 core in 640 kbit/s?

I'm afraid so.


It seems VLC makes the stereo downmix correctly. But I have to try tomorrow on my standalone player.


Yes, software players seem to handle the output fine. I'd be interested in hearing how your stand-alone player does.

tebasuna51
1st November 2021, 12:13
@Lucius Snow
I deleted my post because was only for 24 bits support of actual ffmpeg, and was solved already by Richard1485 in this second thread page than I don't see.

I can't check the downmix question, or other incompatibility issues, because I haven't a BD player. By software players and mkv/m2ts containers all work fine.

Lucius Snow
1st November 2021, 13:36
Just tried on my standalone player: no downmix. Only Left+Right.

Richard1485
1st November 2021, 15:55
Just tried on my standalone player: no downmix. Only Left+Right.

Same as mine then. I wonder if playback would be fine if the player were hooked up to a 5.1 system. In other words, is this simly a downmixing problem or are there other abnormalities in the stream? It's seems a shame not to have a fix for this because it limits the usefulness of the TrueHD encoder in ffmpeg considerably.

clidx
3rd November 2021, 20:19
^ Not as far as I know.


If I use the nightly static build, I get:

And a bigger file...

IIRC the bit depth and bitrate that ffmpeg shows when encoding to THD are arbitrary because both are variable in THD. Even bit depth. That just makes it more interesting that you got vastly different files.

richardpl
3rd November 2021, 20:34
If you really interested to improve encoder donate something to project instead of criticizing it anytime you can.

Richard1485
3rd November 2021, 22:09
If you really interested to improve encoder donate something to project instead of criticizing it anytime you can.

If this is addressed to me, then I don't criticize the encoder any time I can. It's very useful, and my intention was simply to point out something that could make it even more useful.

filler56789
4th November 2021, 04:43
^ Just a reminder that sometimes no donation can make a programmer work on something they don't want to work on -.-

https://sourceforge.net/p/gpac/discussion/287546/thread/43881fa9/

Emulgator
4th November 2021, 11:33
10$ buys...not that much.

jimbof
8th December 2021, 12:20
No sound at all from the Dolby TrueHD track. The regular 'lossy' Dolby Digital tracks can be heard fine.

Other Dolby TrueHD sources can be heard okay...

Have you managed to find a way to get this to work yet? I'm trying to author some test tones for some tests I need to do and coming up against what I think are the same / or at least similar issues.

MPV / VLC can decode an MKV with an ffmpeg created TrueHD stream, but playback on standalone players seems broken. My Oppo will refuse to play if the TrueHD stream is only stereo, and if 5.1 it plays, but without audio.