Opened 23 months ago

Closed 22 months ago

Last modified 22 months ago

#5941 closed defect (wontfix)

Dolby E corrupted when remuxed

Reported by: leoenc Owned by:
Priority: normal Component: avformat
Version: git-master Keywords: wav
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

I have found a strange issue with ffmpeg.
I am trying to remux a Dolby E track. It is important that the data will be completely untouched when remuxed otherwise it is unusable when decoded in a Dolby E decoder.
The data gets corrupted when using the Dolby E track as the only audio input but NOT when being loaded along with a regular PCM audio.

I have uploaded a Dolby E sample here:
https://www.datafilehost.com/d/c1cff95e

The same sample was used for both CLIs below, the one that works and the one that doesn't.

First the one that does work:
(Note that Dolby E is actually a single track with 2 channels, but MediaInfo? identifies it as 2 tracks, this is expected)

ffmpeg.exe -y -i video_source.avs -i audio_source_0.avs -i dolby_e.wav -map 0:0 -c:a pcm_s24be -c:v prores_ks -qscale:v 32 -profile:v 0 -map 1:1 -filter:a:0 "pan=mono|c0=c0" -map 1:1 -filter:a:1 "pan=mono|c0=c1" -map 2:0 -filter:a:0 "pan=mono|c0=c0" video.mov

ffmpeg version 3.2 Copyright (c) 2000-2016 the FFmpeg developers

built with gcc 5.4.0 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-libebur128 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-decklink --enable-zlib
libavutil 55. 34.100 / 55. 34.100
libavcodec 57. 64.100 / 57. 64.100
libavformat 57. 56.100 / 57. 56.100
libavdevice 57. 1.100 / 57. 1.100
libavfilter 6. 65.100 / 6. 65.100
libswscale 4. 2.100 / 4. 2.100
libswresample 2. 3.100 / 2. 3.100
libpostproc 54. 1.100 / 54. 1.100

Input #0, avisynth, from 'video_source.avs':

Duration: 00:02:32.24, start: 0.000000, bitrate: 0 kb/s

Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 1920x1080, 25 fps, 25 tbr, 25 tbn, 25 tbc

Guessed Channel Layout for Input Stream #1.1 : stereo
Input #1, avisynth, from 'audio_source_0.avs':

Duration: 00:02:32.24, start: 0.000000, bitrate: 0 kb/s

Stream #1:0: Video: rawvideo (BGRA / 0x41524742), bgra, 640x480, 25 fps, 25 tbr, 25 tbn, 25 tbc
Stream #1:1: Audio: pcm_s32le, 48000 Hz, stereo, s32, 3072 kb/s

Guessed Channel Layout for Input Stream #2.0 : stereo
Input #2, wav, from 'dolby_e.wav':

Duration: 00:02:32.24, bitrate: 2304 kb/s

Stream #2:0: Audio: pcm_s24le ([1][0][0][0] / 0x0001), 48000 Hz, stereo, s32 (24 bit), 2304 kb/s

[Parsed_pan_0 @ 000000000d2ccbe0] Pure channel mapping detected: 0
[Parsed_pan_0 @ 000000000d2cc3c0] Pure channel mapping detected: 1
Output #0, mov, to 'video.mov':

Metadata:

encoder : Lavf57.56.100
Stream #0:0: Video: prores (prores_ks) (apco / 0x6F637061), yuv422p10le, 1920x1080, q=2-31, 200 kb/s, 25 fps, 12800 tbn, 25 tbc
Metadata:

encoder : Lavc57.64.100 prores_ks

Stream #0:1: Audio: pcm_s24be (in24 / 0x34326E69), 48000 Hz, mono, s32, 1152 kb/s
Metadata:

encoder : Lavc57.64.100 pcm_s24be

Stream #0:2: Audio: pcm_s24be (in24 / 0x34326E69), 48000 Hz, mono, s32, 1152 kb/s
Metadata:

encoder : Lavc57.64.100 pcm_s24be

Stream #0:3: Audio: pcm_s24be (in24 / 0x34326E69), 48000 Hz, stereo, s32 (24 bit), 2304 kb/s
Metadata:

encoder : Lavc57.64.100 pcm_s24be

Stream mapping:

Stream #0:0 -> #0:0 (rawvideo (native) -> prores (prores_ks))
Stream #1:1 -> #0:1 (pcm_s32le (native) -> pcm_s24be (native))
Stream #1:1 -> #0:2 (pcm_s32le (native) -> pcm_s24be (native))
Stream #2:0 -> #0:3 (pcm_s24le (native) -> pcm_s24be (native))

Press [q] to stop, ? for help
frame= 22 fps=0.0 q=-0.0 size= 1531kB time=00:00:00.84 bitrate=14925.8kbitsframe= 45 fps= 44 q=-0.0 size= 3233kB time=00:00:01.76 bitrate=15049.8kbitsframe= 68 fps= 44 q=-0.0 size= 4937kB time=00:00:02.68 bitrate=15089.4kbitsframe= 80 fps= 44 q=-0.0 Lsize= 5892kB time=00:00:03.16 bitrate=15274.1kbits/s speed=1.73x
video:4116kB audio:1772kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.070707%
Exiting normally, received signal 2.

MediaInfo? of output - Dolby E data is correctly identified:

Audio #1
ID : 2
Format : PCM
Format settings, Endianness : Big
Format settings, Sign : Signed
Codec ID : in24
Duration : 14 s 440 ms
Bit rate mode : Constant
Bit rate : 1 152 kb/s
Channel(s) : 1 channel
Sampling rate : 48.0 kHz
Bit depth : 24 bits
Stream size : 1.98 MiB (8%)
Language : English
Default : Yes
Alternate group : 1

Audio #2
ID : 3
Format : PCM
Format settings, Endianness : Big
Format settings, Sign : Signed
Codec ID : in24
Duration : 14 s 440 ms
Bit rate mode : Constant
Bit rate : 1 152 kb/s
Channel(s) : 1 channel
Sampling rate : 48.0 kHz
Bit depth : 24 bits
Stream size : 1.98 MiB (8%)
Language : English
Default : No
Alternate group : 1

Audio #3
ID : 4-1
Format : Dolby E
Mode : 24
Format settings, Endianness : Big
Muxing mode : SMPTE ST 337
Codec ID : in24
Duration : 14 s 422 ms
Bit rate mode : Constant
Bit rate : 2 304 kb/s
Channel(s) : 6 channels
Channel positions : Front: L C R, Side: L R, LFE
Sampling rate : 48.0 kHz
Frame rate : 25.000 FPS (1920 spf)
Bit depth : 20 bits
Stream size : 3.96 MiB (16%)
Language : English
Default : No
Alternate group : 1

Audio #4
ID : 4-2
Format : Dolby E
Mode : 24
Format settings, Endianness : Big
Muxing mode : SMPTE ST 337
Codec ID : in24
Duration : 14 s 422 ms
Bit rate mode : Constant
Bit rate : 2 304 kb/s
Channel(s) : 2 channels
Channel positions : Front: L R
Sampling rate : 48.0 kHz
Frame rate : 25.000 FPS (1920 spf)
Bit depth : 20 bits
Stream size : 3.96 MiB (16%)
Language : English
Default : No
Alternate group : 1

Now the CLI that doesn't work as expected:

ffmpeg.exe -v 9 -loglevel "verbose" -y -i video_source.avs -i dolby_e.wav -map 0:0 -c:a pcm_s24be -c:v prores_ks -profile:v 0 -qscale:v 32 -map 1:0 -filter:a:0 "pan=stereo|c0=c0" video.mov

ffmpeg version 3.2 Copyright (c) 2000-2016 the FFmpeg developers

built with gcc 5.4.0 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-libebur128 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-decklink --enable-zlib
libavutil 55. 34.100 / 55. 34.100
libavcodec 57. 64.100 / 57. 64.100
libavformat 57. 56.100 / 57. 56.100
libavdevice 57. 1.100 / 57. 1.100
libavfilter 6. 65.100 / 6. 65.100
libswscale 4. 2.100 / 4. 2.100
libswresample 2. 3.100 / 2. 3.100
libpostproc 54. 1.100 / 54. 1.100

Input #0, avisynth, from 'video_source.avs':

Duration: 00:02:32.24, start: 0.000000, bitrate: 0 kb/s

Stream #0:0: Video: rawvideo, 1 reference frame (I420 / 0x30323449), yuv420p, 1920x1080, 25 fps, 25 tbr, 25 tbn, 25 tbc

[wav @ 00000000025bbda0] parser not found for codec pcm_s24le, packets or times may be invalid.

Last message repeated 1 times

Guessed Channel Layout for Input Stream #1.0 : stereo
Input #1, wav, from 'dolby_e.wav':

Duration: 00:02:32.24, bitrate: 2304 kb/s

Stream #1:0: Audio: pcm_s24le ([1][0][0][0] / 0x0001), 48000 Hz, stereo, s32 (24 bit), 2304 kb/s

[graph 0 input from stream 0:0 @ 0000000000dde260] w:1920 h:1080 pixfmt:yuv420p tb:1/25 fr:25/1 sar:0/1 sws_param:flags=2
[auto-inserted scaler 0 @ 0000000000dde980] w:iw h:ih flags:'bicubic' interl:0
[format @ 0000000000dde680] auto-inserting filter 'auto-inserted scaler 0' between the filter 'Parsed_null_0' and the filter 'format'
[auto-inserted scaler 0 @ 0000000000dde980] w:1920 h:1080 fmt:yuv420p sar:0/1 -> w:1920 h:1080 fmt:yuv422p10le sar:0/1 flags:0x4
[graph 1 input from stream 1:0 @ 000000000ae6fa80] tb:1/48000 samplefmt:s32 samplerate:48000 chlayout:0x3
[Parsed_pan_0 @ 00000000025fef00] o0 = 1 i0 + 0 i1
[Parsed_pan_0 @ 00000000025fef00] o1 = 0 i0 + 0 i1
[Parsed_pan_0 @ 00000000025fef00] Pure channel mapping detected: 0 M
Output #0, mov, to 'video.mov':

Metadata:

encoder : Lavf57.56.100
Stream #0:0: Video: prores (prores_ks), 1 reference frame (apco / 0x6F637061), yuv422p10le, 1920x1080, q=2-31, 200 kb/s, 25 fps, 12800 tbn, 25 tbc
Metadata:

encoder : Lavc57.64.100 prores_ks

Stream #0:1: Audio: pcm_s24be (in24 / 0x34326E69), 48000 Hz, stereo, s32 (24 bit), 2304 kb/s
Metadata:

encoder : Lavc57.64.100 pcm_s24be

Stream mapping:

Stream #0:0 -> #0:0 (rawvideo (native) -> prores (prores_ks))
Stream #1:0 -> #0:1 (pcm_s24le (native) -> pcm_s24be (native))

Press [q] to stop, ? for help
frame= 22 fps=0.0 q=-0.0 size= 1308kB time=00:00:00.84 bitrate=12754.8kbitsframe= 30 fps=0.0 q=-0.0 Lsize= 1856kB time=00:00:01.16 bitrate=13108.4kbits/s speed=1.68x
video:1535kB audio:320kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.092096%
Input file #0 (video_source.avs):

Input stream #0:0 (video): 30 packets read (93312000 bytes); 30 frames decoded;
Total: 30 packets (93312000 bytes) demuxed

Input file #1 (dolby_e.wav):

Input stream #1:0 (audio): 80 packets read (327360 bytes); 80 frames decoded (54560 samples);
Total: 80 packets (327360 bytes) demuxed

Output file #0 (video.mov):

Output stream #0:0 (video): 30 frames encoded; 30 packets muxed (1571739 bytes);
Output stream #0:1 (audio): 80 frames encoded (54560 samples); 80 packets muxed (327360 bytes);
Total: 110 packets (1899099 bytes) muxed

Exiting normally, received signal 2.

This is the MediaInfo? for the output (only audio section):
Dolby E is not detected - Format is being identified as regular PCM.

Audio
ID : 2
Format : PCM
Format settings, Endianness : Big
Format settings, Sign : Signed
Codec ID : in24
Duration : 6 s 295 ms
Bit rate mode : Constant
Bit rate : 2 304 kb/s
Channel(s) : 2 channels
Channel positions : Front: L R
Sampling rate : 48.0 kHz
Bit depth : 24 bits
Stream size : 1.73 MiB (18%)
Language : English
Default : Yes
Alternate group : 1

Change History (22)

comment:1 Changed 23 months ago by cehoyos

  • Keywords dolby removed

Is the issue you see reproducible with current FFmpeg git head?
Is prores encoding needed to reproduce or can the issue also be seen when encoding an audio-only file?

comment:2 Changed 23 months ago by leoenc

I am not sure regarding git head, I used the latest build from Zeranoe and also tried various older versions dating to 2014.

Prores encoding isn't needed. An audio-only CLI will also produce the issue:
ffmpeg -i dolby_e.wav -acodec pcm_s24le output.wav

I've included the Prores CLI to show when it IS working as expected (only when there's a regular PCM input).

comment:3 Changed 23 months ago by cehoyos

The output you posted is not from the latest Zeranoe build.

comment:4 Changed 23 months ago by leoenc

Sorry about that, i am constantly trying different versions. The result is the same with the latest build.
Here is the console output I just ran again to verify:

ffmpeg.exe -v 9 -loglevel "verbose" -y -i video_source.avs -i dolby_e.wav -map 0:0 -c:a pcm_s24be -c:v prores_ks -profile:v 0 -qscale:v 32 -map 1:0 -filter:a:0 "pan=stereo|c0=c0" video.mov
ffmpeg version N-82324-g872b358 Copyright (c) 2000-2016 the FFmpeg developers

built with gcc 5.4.0 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-libebur128 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-decklink --enable-zlib
libavutil 55. 36.100 / 55. 36.100
libavcodec 57. 66.101 / 57. 66.101
libavformat 57. 57.100 / 57. 57.100
libavdevice 57. 2.100 / 57. 2.100
libavfilter 6. 66.100 / 6. 66.100
libswscale 4. 3.100 / 4. 3.100
libswresample 2. 4.100 / 2. 4.100
libpostproc 54. 2.100 / 54. 2.100

Input #0, avisynth, from 'video_source.avs':

Duration: 00:02:32.24, start: 0.000000, bitrate: 0 kb/s

Stream #0:0: Video: rawvideo, 1 reference frame (I420 / 0x30323449), yuv420p, 1920x1080, 25 fps, 25 tbr, 25 tbn, 25 tbc

[wav @ 00000000025bbda0] parser not found for codec pcm_s24le, packets or times may be invalid.

Last message repeated 1 times

Guessed Channel Layout for Input Stream #1.0 : stereo
Input #1, wav, from 'dolby_e.wav':

Duration: 00:02:32.24, bitrate: 2304 kb/s

Stream #1:0: Audio: pcm_s24le ([1][0][0][0] / 0x0001), 48000 Hz, stereo, s32 (24 bit), 2304 kb/s

[graph 0 input from stream 0:0 @ 0000000000dd6be0] w:1920 h:1080 pixfmt:yuv420p tb:1/25 fr:25/1 sar:0/1 sws_param:flags=2
[auto-inserted scaler 0 @ 00000000025f1200] w:iw h:ih flags:'bicubic' interl:0
[format @ 0000000000dd7000] auto-inserting filter 'auto-inserted scaler 0' between the filter 'Parsed_null_0' and the filter 'format'
[auto-inserted scaler 0 @ 00000000025f1200] w:1920 h:1080 fmt:yuv420p sar:0/1 -> w:1920 h:1080 fmt:yuv422p10le sar:0/1 flags:0x4
[graph 1 input from stream 1:0 @ 000000000ae6e320] tb:1/48000 samplefmt:s32 samplerate:48000 chlayout:0x3
[Parsed_pan_0 @ 00000000025fed60] o0 = 1 i0 + 0 i1
[Parsed_pan_0 @ 00000000025fed60] o1 = 0 i0 + 0 i1
[Parsed_pan_0 @ 00000000025fed60] Pure channel mapping detected: 0 M
Output #0, mov, to 'video.mov':

Metadata:

encoder : Lavf57.57.100
Stream #0:0: Video: prores (prores_ks), 1 reference frame (apco / 0x6F637061), yuv422p10le, 1920x1080, q=2-31, 200 kb/s, 25 fps, 12800 tbn, 25 tbc
Metadata:

encoder : Lavc57.66.101 prores_ks

Stream #0:1: Audio: pcm_s24be (in24 / 0x34326E69), 48000 Hz, stereo, s32 (24 bit), 2304 kb/s
Metadata:

encoder : Lavc57.66.101 pcm_s24be

Stream mapping:

Stream #0:0 -> #0:0 (rawvideo (native) -> prores (prores_ks))
Stream #1:0 -> #0:1 (pcm_s24le (native) -> pcm_s24be (native))

Press [q] to stop, ? for help
frame= 22 fps=0.0 q=-0.0 size= 1308kB time=00:00:00.84 bitrate=12754.8kbitsframe= 45 fps= 43 q=-0.0 size= 2752kB time=00:00:01.76 bitrate=12796.5kbitsframe= 68 fps= 44 q=-0.0 size= 4196kB time=00:00:02.68 bitrate=12827.1kbitsframe= 86 fps= 44 q=-0.0 Lsize= 5379kB time=00:00:03.40 bitrate=12959.1kbits/s speed=1.73x
video:4425kB audio:951kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.048555%
Input file #0 (video_source.avs):

Input stream #0:0 (video): 86 packets read (267494400 bytes); 86 frames decoded;
Total: 86 packets (267494400 bytes) demuxed

Input file #1 (dolby_e.wav):

Input stream #1:0 (audio): 238 packets read (973896 bytes); 238 frames decoded (162316 samples);
Total: 238 packets (973896 bytes) demuxed

Output file #0 (video.mov):

Output stream #0:0 (video): 86 frames encoded; 86 packets muxed (4531161 bytes);
Output stream #0:1 (audio): 238 frames encoded (162316 samples); 238 packets muxed (973896 bytes);
Total: 324 packets (5505057 bytes) muxed

Exiting normally, received signal 2.

comment:5 Changed 23 months ago by leoenc

This information might be of help: I found out that when using ffmbc, it works as expected.
https://github.com/bcoudurier/FFmbc

comment:6 Changed 22 months ago by cus

Why are you using "pan=stereo|c0=c0"? This way your second channel of the dolby-e pair will be muted. Is this intended? Also, can you reproduce this with more simplified command lines (e.g. without encoding video?)? Try to provide command lines which makes the issue more easliy reproducible. Also please use the code block {{{ code }}} formatting when posting command line or output.

comment:7 Changed 22 months ago by leoenc

"pan=stereo|c0=c0" was a typo. It's meant to be "pan=mono|c0=c0" as this is how I found it to work in the first case, where I had another audio input.

A simple audio only command line will also produce this issue:

ffmpeg -i dolby_e.wav -acodec pcm_s24le output.wav

comment:8 follow-up: Changed 22 months ago by leoenc

I've found out that when encoding to ProRes? and removing the filter from the second line - it works.
But with audio only encoding - it doesn't. So to summarize the current state:

This CLI works:
ffmpeg -i video.avs -i dolby_e.wav -map 0:0 -c:a pcm_s24le -c:v prores_ks -map 1:0 output.mov

This CLI doesn't: (output data is corrupted)
ffmpeg -i dolby_e.wav -c:a pcm_s24le output.wav

comment:9 in reply to: ↑ 8 Changed 22 months ago by cehoyos

Replying to leoenc:

This CLI works:
ffmpeg -i video.avs -i dolby_e.wav -map 0:0 -c:a pcm_s24le -c:v prores_ks -map 1:0 output.mov

This CLI doesn't: (output data is corrupted)
ffmpeg -i dolby_e.wav -c:a pcm_s24le output.wav

The commands produce very different output files.
Does this produce a working file?

$ ffmpeg -i output.mov -acodec copy out.wav

What about the following?

$ ffmpeg -i dolby_e.wav -acodec pcm_s24le out.mov

comment:10 Changed 22 months ago by leoenc

ffmpeg -i output.mov -acodec copy out.wav
Same issue.

ffmpeg -i dolby_e.wav -acodec pcm_s24le out.mov
produces a proper Dolby E track.

comment:11 Changed 22 months ago by cehoyos

What if you use the FFmpeg wav file to produce a mov?

$ ffmpeg -i out.wav -acodec pcm_s24le out2.mov

comment:12 Changed 22 months ago by leoenc

How odd, the audio track is then detected again as Dolby E!

comment:13 Changed 22 months ago by cehoyos

Feel free to test the following small patches (independently and both) but afaict, your wav file is invalid (it has no waveformatextensible header although bpp>16) and this ticket is therefore unlikely to get fixed in FFmpeg (unless one of the changes is sufficient).

diff --git a/libavformat/wavenc.c b/libavformat/wavenc.c
index a21d4c5..fa5f010 100644
--- a/libavformat/wavenc.c
+++ b/libavformat/wavenc.c
@@ -365,7 +365,7 @@ static int wav_write_header(AVFormatContext *s)

     if (wav->write_peak != 2) {
         /* info header */
-        ff_riff_write_info(s);
+//        ff_riff_write_info(s);

         /* data header */
         wav->data = ff_start_tag(pb, "data");
diff --git a/libavformat/riffenc.c b/libavformat/riffenc.c
index c96329d..91b2fa7 100644
--- a/libavformat/riffenc.c
+++ b/libavformat/riffenc.c
@@ -76,6 +76,7 @@ int ff_put_wav_header(AVFormatContext *s, AVIOContext *pb,
                            par->sample_rate > 48000 ||
                            par->codec_id == AV_CODEC_ID_EAC3 ||
                            av_get_bits_per_sample(par->codec_id) > 16;
+waveformatextensible=0;

     if (waveformatextensible)
         avio_wl16(pb, 0xfffe);
Last edited 22 months ago by cehoyos (previous) (diff)

comment:14 Changed 22 months ago by leoenc

Thanks. I've never compiled ffmpeg before so if you could provide an updated binary, it would speed up the process. I have access to many Dolby E files. It could be that the particular sample I've provided is invalid.
How do you check for waveformatexstensible? Is there a switch in ffprobe that shows the wav header?

comment:15 follow-up: Changed 22 months ago by leoenc

Did some research and came up with the following conclusion: The extensible structure is only required for 32-bit float formats. It is not required for regular 24-bit data, which is how Dolby E is stored.

comment:16 Changed 22 months ago by cehoyos

More important would be to test if the issue is related to waveformatextensible at all.

comment:17 Changed 22 months ago by leoenc

I can confirm that the second patch solves the problem. Tried with several Dolby E files and encoding to WAV or to MOV as above.

Patch 1: No change
Patch 2: Issue resolved
Patch 1 & 2: Issue resolved

Thanks @cehoyos.

comment:18 Changed 22 months ago by leoenc

Just to make sure it's clear - the patch that resolves the issue is for riffenc.c.

comment:19 in reply to: ↑ 15 Changed 22 months ago by cehoyos

Replying to leoenc:

The extensible structure is only required for 32-bit float formats.

Why do you think so?

comment:20 follow-up: Changed 22 months ago by leoenc

I'm not sure about the float part, but I was told by the Dolby vendor that the waveformatextensible structure is not required for storing Dolby E as it is encoded in 2 channels, 24-bit and no channel mask data is needed.

I've tested many Dolby E files which came from the same source as my sample. The files were properly identified and decoded in pro Dolby hardware. MediaInfo? also identified them properly, so I think it's safe to assume that the sample that I've provided is the correct way to store Dolby E.

comment:21 in reply to: ↑ 20 Changed 22 months ago by cehoyos

  • Component changed from undetermined to avformat
  • Keywords wav added
  • Resolution set to wontfix
  • Status changed from new to closed
  • Version changed from unspecified to git-master

Replying to leoenc:

I'm not sure about the float part, but I was told by the Dolby vendor that the waveformatextensible structure is not required for storing Dolby E as it is encoded in 2 channels, 24-bit and no channel mask data is needed.

But your vendor isn't Microsoft, the company that defined the wav format decades ago and - iirc - requires waveformatextensible if bps > 16?
There is a major bug in the software you use to read the wav files, it does not support waveformatextensible. Or is this a hardware decoder that does not read these files? How are the files sent to the hardware decoder?

I've tested many Dolby E files which came from the same source as my sample. The files were properly identified and decoded in pro Dolby hardware. MediaInfo? also identified them properly, so I think it's safe to assume that the sample that I've provided is the correct way to store Dolby E.

Note that FFmpeg does not claim to support Dolby E - on the contrary, sadly! Your command line requests to mux pcm_s24 into wav.

Until Dobly E gets supported, this will not be fixed afaict, several very similar requests were refused in the past because we don't want to write invalid wav files.

comment:22 Changed 22 months ago by leoenc

Where does it say that we must use waveformatextensible when bpp > 16?

According to the Microsoft article https://msdn.microsoft.com/en-us/library/windows/desktop/dd757713(v=vs.85).aspx:

Formats that support more than two channels or sample sizes of more than 16 bits can be described in a WAVEFORMATEXTENSIBLE structure, which includes the WAVEFORMAT structure.

Note: See TracTickets for help on using tickets.