Log in

View Full Version : ffmpeg, container mxf and audio Dolby E


tebasuna51
27th October 2021, 11:11
The feature request by FranceBB in BestAudioSource (https://forum.doom9.org/showthread.php?p=1955763#post1955763) and L-SMASH Source (https://forum.doom9.org/showthread.php?p=1955777#post1955777) seems a ffmpeg problem supporting the mxf container because Dolby E tracks aren't recognized:

C:\tmp\DolbyE.mxf streams:

0: mpeg2video (4:2:2), yuv422p(tv, bt709, top first), 1920x1080 [SAR 1:1 DAR 16 :9], 50000 kb/s, 25 fps, 25 tbr, 25 tbn
1: pcm_s24le, 48000 Hz, 7.1, s32 (24 bit), 9216 kb/s -> must be dolby_e, 44800 Hz, 7.1, fltp
2: pcm_s24le, 48000 Hz, 7.1, s32 (24 bit), 9216 kb/s -> must be dolby_e, 44800 Hz, 7.1, fltp
3: pcm_s24le, 48000 Hz, stereo, s32 (24 bit), 2304 kb/s
4: pcm_s24le, 48000 Hz, stereo, s32 (24 bit), 2304 kb/s

With the workaround of extract the tracks like pcm unsigned 8 bits (u8 format):
ffmpeg.exe -i DolbyE.mxf -map 0:1 -acodec copy -f u8 stream1.u8
the extracted stream1.u8 is now recognized like Dolby E:

C:\tmp\stream1.u8 streams:

0: dolby_e, 44800 Hz, 7.1, fltp

1) ffmpeg must improve the mxf support to recognize Dolby E tracks and be capable to extract tracks with something like:

ffmpeg.exe -i DolbyE.mxf -map 0:1 -acodec copy -f dolby_e stream1.dbe

But there are other problem to be solved:
Seems the Dolby E is not a 7.1 but a 5.1 + 2.0 (downmix)
-------------- Media Info
Audio #1
ID : 3-1
Format : Dolby E
Channel(s) : 6 channels
Channel layout : L C Ls X R LFE Rs X
Title : Program_1

Audio #2
ID : 3-2
Format : Dolby E
Channel(s) : 2 channels
Channel layout : X X X L X X X R
Title : Program_2

When ffmpeg decode the stream1.u8 audio show:
[dolby_e @ 0000022094688b80] Stream has 2 programs (configuration 0), channels will be output in native order.

We need select the Program (also EAC3 files can have more than 1 Program)

2) ffmpeg must let select the Program in audio streams. Maybe with something like:

-map 0:1:p:1

The 7.1 output (the same with ffmpeg and FFAudioSource) is show in the attached image and seems the first 6 chanels are the 5.1 and the last the 2.0 downmix.
Then the workaound to obtain the 2 Programs is

FFMPEG -i stream1.u8 -filter_complex "asplit [s][d]; [s] pan=5.1|c0=c0|c1=c1|c2=c2|c3=c3|c4=c4|c5=c5 [ss]; [d] pan=stereo|c0=c6|c1=c7 [dd]" -map "[ss]" -acodec pcm_s24le surround.wav -map "[dd]" -acodec pcm_s24le downmix.wav

In AviSynth we can use for the 5,1:
FFAudioSource("C:\tmp\stream1.u8")
ConvertAudioTo24bit()
GetChannel(1, 2, 3, 4, 5, 6)
#GetChannel(7, 8)
And the GetChannel(7, 8) for the 2.0

FranceBB
27th October 2021, 15:34
Opened a ticket: https://trac.ffmpeg.org/ticket/9479

Please comment and/or upvote

FranceBB
8th November 2021, 10:26
Replied to the ticket with 2 more samples.

Currently we have:

FFMpeg bugtracker: https://trac.ffmpeg.org/ticket/9479
LWLibavAudioSource BugTracker: https://github.com/AkarinVS/L-SMASH-Works/issues/17
MPV Player BugTracker: https://github.com/mpv-player/mpv/issues/9353