Opened 2 months ago

Last modified 10 days ago

#9864 open enhancement

DolbyED2 track cannot be decoded

Reported by: Francesco Bucciantini Owned by:
Priority: wish Component: avcodec
Version: git-master Keywords:
Cc: Francesco Bucciantini Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description (last modified by Francesco Bucciantini)

Summary of the bug: DolbyED2 5.1.4 Atmos tracks cannot be decoded, unlike their DolbyE 5.1 or 5.1+2.0 counterparts which can be decoded.

Unlike DolbyE which is carried as 1 AES (i.e 1 fake stereo pair - so 1 .wav - or 2 fake mono pairs - so 2 .wav), DolbyED2 is carried as 2 AES (i.e 2 fake stereo pairs) so either 2 separate fake stereo .wav files that need to be merged together to be decoded or 1 fake quad .wav file.

If we use the same logic as DolbyE, however, the decoder doesn't recognize the file as a valid file and therefore doesn't decode it.

How to reproduce:

% 
rem first we merge the 2 fake stereo pairs (2 AES) in 1:

ffmpeg.exe -i "Y:\00_INGEST_MAM\DolbyED2\ED2A.wav" -i "Y:\00_INGEST_MAM\DolbyED2\ED2B.wav" -filter_complex "[0:a][1:a]join=inputs=2:channel_layout=stereo[a]" -map "[a]" -c:a pcm_s24le -ar 48000 -f wav -y "A:\MEDIA\temp\DolbyED2\DolbyED2.wav"


rem now we save the DolbyED2 file as .u8 to decode it

ffmpeg.exe -i "A:\MEDIA\temp\DolbyED2\DolbyED2.wav" -map 0:0 -acodec copy -f u8 -y "A:\MEDIA\temp\DolbyED2\stream1.u8"

rem now we cycle through the channels of the DolbyED2 to decode it, but while this works with DolbyE files, unfortunately DolbyED2 ones aren't recognized...

ffmpeg.exe  -i "A:\MEDIA\temp\DolbyED2\stream1.u8" -acodec pcm_s24le -ar 48000 -ac 1 -map_channel 0.0.0:0.0.0 -y "A:\MEDIA\temp\DolbyED2\Out1.wav"

ffmpeg.exe  -i "A:\MEDIA\temp\DolbyED2\stream1.u8" -acodec pcm_s24le -ar 48000 -ac 1 -map_channel 0.0.1:0.0.0 -y "A:\MEDIA\temp\DolbyED2\Out2.wav"

ffmpeg.exe  -i "A:\MEDIA\temp\DolbyED2\stream1.u8" -acodec pcm_s24le -ar 48000 -ac 1 -map_channel 0.0.2:0.0.0 -y "A:\MEDIA\temp\DolbyED2\Out3.wav"

ffmpeg.exe  -i "A:\MEDIA\temp\DolbyED2\stream1.u8" -acodec pcm_s24le -ar 48000 -ac 1 -map_channel 0.0.3:0.0.0 -y "A:\MEDIA\temp\DolbyED2\Out4.wav"

ffmpeg.exe  -i "A:\MEDIA\temp\DolbyED2\stream1.u8" -acodec pcm_s24le -ar 48000 -ac 1 -map_channel 0.0.4:0.0.0 -y "A:\MEDIA\temp\DolbyED2\Out5.wav"

ffmpeg.exe  -i "A:\MEDIA\temp\DolbyED2\stream1.u8" -acodec pcm_s24le -ar 48000 -ac 1 -map_channel 0.0.5:0.0.0 -y "A:\MEDIA\temp\DolbyED2\Out6.wav"

ffmpeg version n5.2-dev-2022-08-01
built on 2022-08-01

Expected result: .u8 is recognized and decoded
Actual result: A:\MEDIA\temp\DolbyED2\stream1.u8: Invalid data found when processing input

With normal DolbyE tracks decoding works: https://forum.doom9.org/showthread.php?t=176739

The sample in attachment is DolbyED2 2 AES already coupled together, ready to be decoded, lasting just 1 sec due to the bug tracker restrictions.

More info about DolbyED2 https://developer.dolby.com/globalassets/professional/whitepapers/dolby-ed2-whitepaper.pdf

Attachments (6)

DolbyED2_trim.wav (283.9 KB ) - added by Francesco Bucciantini 2 months ago.
DolbyED2 Sample trimmed to 1 sec
DolbyED2_trim_2.wav (279.9 KB ) - added by Francesco Bucciantini 8 weeks ago.
DolbyED2 Sample 2
DolbyED2_trim_3.wav (279.9 KB ) - added by Francesco Bucciantini 8 weeks ago.
DolbyED2 Sample 3
DolbyED2_trim_4.wav (283.9 KB ) - added by Francesco Bucciantini 8 weeks ago.
DolbyED2 Sample 4
DolbyED2_trim_5.wav (2.2 MB ) - added by Francesco Bucciantini 8 weeks ago.
DolbyED2 Sample 5
0001-DolbyED2-support.patch (1.1 KB ) - added by Francesco Bucciantini 11 days ago.
Patch by Nicola Gaullier that allows ffmpeg to decode the provided samples

Change History (20)

by Francesco Bucciantini, 2 months ago

Attachment: DolbyED2_trim.wav added

DolbyED2 Sample trimmed to 1 sec

comment:1 by Francesco Bucciantini, 2 months ago

Description: modified (diff)

comment:2 by Francesco Bucciantini, 2 months ago

Description: modified (diff)

comment:3 by Francesco Bucciantini, 2 months ago

Description: modified (diff)

comment:4 by Balling, 2 months ago

Your file mostly consists of zero bytes.

by Francesco Bucciantini, 8 weeks ago

Attachment: DolbyED2_trim_2.wav added

DolbyED2 Sample 2

by Francesco Bucciantini, 8 weeks ago

Attachment: DolbyED2_trim_3.wav added

DolbyED2 Sample 3

by Francesco Bucciantini, 8 weeks ago

Attachment: DolbyED2_trim_4.wav added

DolbyED2 Sample 4

by Francesco Bucciantini, 8 weeks ago

Attachment: DolbyED2_trim_5.wav added

DolbyED2 Sample 5

comment:5 by Francesco Bucciantini, 8 weeks ago

I would upload a bigger sample if the bug tracker allowed me.

Here are more samples trimmed at different points with FFMpeg, as requested:

ffmpeg.exe -i "DolbyED2.wav" -acodec copy -ss 1200 -t 1 -f wav -y "DolbyED2_trim_2.wav"
ffmpeg.exe -i "DolbyED2.wav" -acodec copy -ss 1900 -t 1 -f wav -y "DolbyED2_trim_3.wav"
ffmpeg.exe -i "DolbyED2.wav" -acodec copy -ss 2400 -t 1 -f wav -y "DolbyED2_trim_4.wav"
ffmpeg.exe -i "DolbyED2.wav" -acodec copy -ss 2401 -t 8 -f wav -y "DolbyED2_trim_5.wav"

And if you look with an hex editor, you can see data:

https://i.imgur.com/FsreFTh.png

Last edited 8 weeks ago by Francesco Bucciantini (previous) (diff)

comment:6 by Carl Eugen Hoyos, 8 weeks ago

Please provide longer samples.

comment:7 by Francesco Bucciantini, 6 weeks ago

Hi Carl,
no problem. :)
I was trying to upload to your FTP, namely upload.ffmpeg.org but it fails to login and if I visit it with a browser https://upload.ffmpeg.org/ it says "The service has been decommissioned". :|
Is there any other official place where I could upload the sample?

In the meantime, here's a WeTransfer with the samples:

  • DolbyED2 carried as 2 fake stereo tracks that need to be merged (2 AES)

https://we.tl/t-ckWIdhYkW8

comment:8 by Balling, 6 weeks ago

It is here: https://streams.videolan.org/upload/

Select ffmpeg issue number.

The service that was decommissioned is Jenkins. In fact you can see it on broken https warning on that site.

comment:9 by Francesco Bucciantini, 6 weeks ago

Gotcha, thanks Balling.
I have uploaded the file called DolbyED2.rar at the address you provided, https://streams.videolan.org/upload/

Inside you're gonna find two files:

  • DolbyED2_AES1.wav
  • DolbyED2_AES2.wav

those are the two fake stereo pairs that carry the DolbyED2 Atmos 5.1.4, so ideally they should be merged together first to get 1 file and then decoded.

comment:12 by Carl Eugen Hoyos, 5 weeks ago

Component: undeterminedavcodec
Priority: normalwish

by Francesco Bucciantini, 11 days ago

Attachment: 0001-DolbyED2-support.patch added

Patch by Nicola Gaullier that allows ffmpeg to decode the provided samples

comment:13 by Balling, 11 days ago

This should also be applied cause apparently even first version was not correct 100% https://patchwork.ffmpeg.org/project/ffmpeg/patch/20220913213127.1756-1-nicolas.gaullier@cji.paris/

comment:14 by Francesco Bucciantini, 10 days ago

Yes, that patch right there that Balling quoted https://patchwork.ffmpeg.org/project/ffmpeg/patch/20220913213127.1756-1-nicolas.gaullier@cji.paris/ should really be merged upstream regardless of DolbyED2 'cause it's really really important. That bug affects the 20 bits section of standard DolbyE 5.1 + 2.0 files which raises an error “Read past end of channel XX” while decoding them with FFMpeg. That is bug 'cause it's not just a "simple warning" but rather a real error as it really truncates the audio, hence throwing away few ms. When I decode the very same file with the official Dolby DP600, however, there are no warnings and the decoding completes correctly. By applying Nicola's patch, there's gonna be a simple warning, but data will be preserved and we're gonna avoid the few ms of mute audio. This is really important as we use DolbyE 5.1 + 2.0 in production on a daily basis, therefore it should really be merged sooner rather than later.

Note: See TracTickets for help on using tickets.