Opened 12 years ago

Closed 18 months ago

Last modified 14 months ago

#1726 closed defect (fixed)

Mono TrueHD file no longer decodes (and was not lossless)

Reported by: Carl Eugen Hoyos Owned by:
Priority: important Component: undetermined
Version: git-master Keywords: thd
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no

Description

(bug 356)
I will upload a Mono TrueHD Sample that could be converted to wav with old versions of ffmpeg (including 0.10), fails since f095391 / 27c7ca9, ffplay -ac 2 used to work well with older versions, current ffplay -request_channels 2 fails.

$ ffmpeg -i Mono.thd out.wav
ffmpeg version N-44381-g578bbf8 Copyright (c) 2000-2012 the FFmpeg developers
  built on Sep 12 2012 00:12:20 with gcc 4.5.3 (GCC)
  configuration: --cc=/usr/local/gcc-4.5.3/bin/gcc
  libavutil      51. 72.100 / 51. 72.100
  libavcodec     54. 55.100 / 54. 55.100
  libavformat    54. 26.101 / 54. 26.101
  libavdevice    54.  2.100 / 54.  2.100
  libavfilter     3. 16.103 /  3. 16.103
  libswscale      2.  1.101 /  2.  1.101
  libswresample   0. 15.100 /  0. 15.100
[truehd @ 0x148b240] max_analyze_duration 5000000 reached at 5000000
[truehd @ 0x148b240] Estimating duration from bitrate, this may be inaccurate
Input #0, truehd, from 'Mono.thd':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Audio: truehd, 48000 Hz, mono, s32
Output #0, wav, to 'out.wav':
  Metadata:
    encoder         : Lavf54.26.101
    Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz, mono, s16, 768 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (truehd -> pcm_s16le)
Press [q] to stop, [?] for help
[truehd @ 0x1491620] Max channel must be equal max matrix channel.
[truehd @ 0x1491620] No restart header present in substream 1.
[truehd @ 0x1491620] get_buffer() failed
Error while decoding stream #0:0: Invalid argument
[truehd @ 0x1491620] No restart header present in substream 1.
[truehd @ 0x1491620] get_buffer() failed
Error while decoding stream #0:0: Invalid argument

...

[truehd @ 0x1491620] No restart header present in substream 1.
[truehd @ 0x1491620] get_buffer() failed
Error while decoding stream #0:0: Invalid argument
[truehd @ 0x1491620] No restart header present in substream 1.
[truehd @ 0x1491620] get_buffer() failed
Error while decoding stream #0:0: Invalid argument
size=       0kB time=00:00:00.00 bitrate=   0.0kbits/s
video:0kB audio:0kB subtitle:0 global headers:0kB muxing overhead inf%
Output file is empty, nothing was encoded (check -ss / -t / -frames parameters if used)

Change History (16)

comment:1 by Carl Eugen Hoyos, 12 years ago

Sample uploaded to samples/ffmpeg-bugs/trac/ticket1726

comment:2 by Michael Niedermayer, 11 years ago

comment:3 by Michael Niedermayer, 11 years ago

Keywords: mlp added
Reproduced by developer: set
Resolution: fixed
Status: newclosed

comment:4 by Balling, 3 years ago

That is now printing stereo because of 494f868e93d1d671497d0d0884368f015eb7d31e. And that is not even talking about BS s32 (24 bit) (P.S. actually 24 bit info is correct, all TrueHD (0xba, not 0xbb) is 24 bit WITH no metadata whether it is 16 bit or 24, so 16 bit is just padded with zeroes to 24 bit, such metadata was available in 0xbb, see https://github.com/MediaArea/MediaInfoLib/issues/1102#issuecomment-908614414).

Still mono is decoded, as -v debug does print "Mono stream with 2 substreams, ignoring 2nd".

Last edited 3 years ago by Balling (previous) (diff)

comment:5 by Balling, 3 years ago

Interesting, so even now with 16 samples present, the reencoded file is larger (13866334 bytes vs 11141326 bytes) but also no longer has flags to drop the second channel and does not print with -v debug "Mono stream with 2 substreams, ignoring 2nd".

P.S. It is not printing stereo, but it creates wrong wav with 2 channels with second channel zeroed out in both source and reencoded file (when ffmpeg recognized the file as mono, the result was the same, two channel in wav).

P.S.2 WHAT IS VERY IMPORTANT is that LG C9 which uses hardware decoder for Truehd and Truehd + Atmos (yep, it decodes Atmos packed in MAT 2.0 by Lavfilters even on the internal speackers and signals Atmos) thinks that the reencoded truehd file is not longer mono: when you select Right+Right in the LG C9 sound menu it plays nothing on reencoded file (because reencoded file has nothing in the right channel and is not tagged as mono) while on source file Right+Right is the same as L+R and L+L, since mono is being played on all speakers. What is also a problem is that reencoded file is so much less loud and also that it loses sound when you select only one speacker (R+R is no sound as I said but left+left is less loud again). That may be a difference between stereo and mono or DRC (Dynamic range compression) that is not supported in mlpenc (while eac3 and ac3 do support it).

comment:6 by Balling, 2 years ago

Resolution: fixed
Status: closedreopened

This now regressed twice: because of 946493eb3e072b499909f606625480c928834a44 it also no longer decodes at all on latest master with a warning "Max channel must be equal max matrix channel". I suppose it thinks it is stereo due to previous regression and now it is a breaking change.

Last edited 2 years ago by Balling (previous) (diff)

comment:7 by Balling, 19 months ago

Keywords: regression mlp removed
Status: reopenedopen
Summary: Mono TrueHD file fails to decodeMono TrueHD file no longer decodes (and was not lossless)

Actually it is technically not a regression because the original was not decoding correctly compared to Plex + EAE.exe anyway.

Compare before regression (to extract mono channel losslessly):

ffmpeg.exe -i https://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket1726/Mono.thd -vn -c:a pcm_s24le -af channelmap=channel_layout=mono:map=0 fwefqaw.wav

vs what plex gives: "C:\Program Files\Plex\Plex Media Server\Plex Transcoder.exe" -i https://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket1726/Mono.thd -c:a pcm_s24le faefaw.wav

So this is a bug in our decoder, since truehd is lossless.

I will remove regression and mlp tags and attach Plex 24 bit flac (Mediaconcept EAE Dolby sdk).

https://0x0.st/o9S0.flac

Last edited 19 months ago by Balling (previous) (diff)

comment:8 by Balling, 18 months ago

That file is still broken, Paul. Again, there is either a bug in 494f868e93d1d671497d0d0884368f015eb7d31e or your code, that really should be reverted without samples.

comment:9 by Elon Musk, 18 months ago

There is patch for this on ML, but why I talk with trolls.

comment:10 by Elon Musk, 18 months ago

Resolution: fixed
Status: openclosed

comment:11 by Balling, 18 months ago

Yes, I was right, it was not regression! File is NOW bitperfect with Plex! Very cool! (There are 9 more samples in Plex in the end, but those are just zeroes.)

It is also recognized as mono now and decodes to one channel, moreover after reencoding it is still one channel. That is like perfect, 100% done.

FFplay should still be fixed, I use mpv for now to play thd with FFmpeg HEAD built in.

There is patch for this on ML

Did not see it yesterday.

comment:12 by Carl Eugen Hoyos, 18 months ago

We should really tell tdskywalker

in reply to:  12 comment:13 by Balling, 18 months ago

Replying to Carl Eugen Hoyos:

We should really tell tdskywalker

Who's that? I mean why would this Tim care?

Last edited 18 months ago by Balling (previous) (diff)

comment:14 by Carl Eugen Hoyos, 18 months ago

Tim Walker had originally reported bug 356.

comment:15 by Balling, 18 months ago

BTW, why is newly reencoded mono has (in older mpv)

truehd: No restart header present in substream 0.
truehd: No samples to output.

While old one has

[ffmpeg/audio] truehd: No restart header present in substream 1.
[ffmpeg/audio] truehd: No samples to output.

Maybe same substream should be used?

It plays all good on LG C9 and L+L and L+R and R+R do not affect the sound as on original sound.

Last edited 18 months ago by Balling (previous) (diff)

comment:16 by Balling, 18 months ago

Oh and also cosmetic, but ffmpeg -h encoder=truehd

should print Supported channel layouts: mono stereo 5.0 5.1

like ffmpeg -h encoder=opus

P.S. Actually it had mono already, I just used a different ffmpeg version.

Last edited 14 months ago by Balling (previous) (diff)
Note: See TracTickets for help on using tickets.