[FFmpeg-user] truehd request channels issue and fix for mplayer.

Andy Furniss andyqos at ukfsn.org
Fri Jan 11 19:32:03 CET 2013


38meg truehd channel check -

http://www.andyqos.ukfsn.org/71check.thd

Also tested with blu-ray above is ripped out of a file on demoworld.

Testing truehd I can't get -request_channels to work with ffmpeg - 
however with mplayer channels 2 does work.

Channels 6 on a 7.1 stream fails though.

The attached patch makes -channels 6 work with mplayer and also helps 
ffmpeg in that it gets rid of the error -

[truehd @ 0xadd9140] Lossless check failed - expected 2c, calculated db

which is present in both cases and with mplayer -channels 6 the stream 
still plays but has missing channels.

The patch just follows the stereo example seen above the new lines it 
adds which was added in April last year -

http://git.videolan.org/gitweb.cgi/ffmpeg.git/?p=ffmpeg.git;a=commit;h=a9cd12ee2afb3f3aad783c396816b23d8513f472

Without it further down in mlpdec.c the channels are set as 7.1 and some 
channel reordering occurs which I think causes the problem (well just 
commenting that out as a test will also work but I expect break 7.1).


  484     if (m->avctx->codec_id == AV_CODEC_ID_TRUEHD &&
  485         (m->avctx->channel_layout == AV_CH_LAYOUT_7POINT1 ||
  486         m->avctx->channel_layout == AV_CH_LAYOUT_7POINT1_WIDE)) {
  487         FFSWAP(int, s->ch_assign[4], s->ch_assign[6]);
  488         FFSWAP(int, s->ch_assign[5], s->ch_assign[7]);


Of course I don't know what I am doing really - but this does fix 
mplayer for me.

Below is output of vanilla ffmpeg failing with 2 and 6 channels - with 
the patch the 6 chan will loose the losless check errors - still doesn't 
work, but mplayer will also loose the same errors and does work.

bash-3.2$ ffm -request_channels 2 -i 71check.thd  ftest.wav
ffmpeg version N-48748-g8d06be6 Copyright (c) 2000-2013 the FFmpeg 
developers
   built on Jan 11 2013 17:05:16 with gcc 4.5.1 (GCC)
   configuration: --prefix=/usr --enable-gpl --enable-libx264
   libavutil      52. 13.100 / 52. 13.100
   libavcodec     54. 86.100 / 54. 86.100
   libavformat    54. 59.107 / 54. 59.107
   libavdevice    54.  3.102 / 54.  3.102
   libavfilter     3. 32.100 /  3. 32.100
   libswscale      2.  1.103 /  2.  1.103
   libswresample   0. 17.102 /  0. 17.102
   libpostproc    52.  2.100 / 52.  2.100
[truehd @ 0x90deee0] max_analyze_duration 5000000 reached at 5000000
[truehd @ 0x90deee0] Estimating duration from bitrate, this may be 
inaccurate
Input #0, truehd, from '71check.thd':
   Duration: N/A, start: 0.000000, bitrate: N/A
     Stream #0:0: Audio: truehd, 48000 Hz, 7.1, s32
File 'ftest.wav' already exists. Overwrite ? [y/N] y
Output #0, wav, to 'ftest.wav':
   Metadata:
     ISFT            : Lavf54.59.107
     Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz, 
7.1, s16, 6144 kb/s
Stream mapping:
   Stream #0:0 -> #0:0 (truehd -> pcm_s16le)
Press [q] to stop, [?] for help
Guessed Channel Layout for  Input Stream #0.0 : stereo
Input stream #0:0 frame changed from rate:48000 fmt:s32 ch:8 chl:7.1 to 
rate:48000 fmt:s32 ch:2 chl:stereo
Input stream #0:0 frame changed from rate:48000 fmt:s32 ch:2 chl:stereo 
to rate:48000 fmt:s32 ch:2 chl:2 channels (FL+FR+FC+LFE+BL+BR+SL+SR)
Layout indicates a different number of channels than actually present
     Last message repeated 5048 times
Layout indicates a different number of channels than actually present
     Last message repeated 4973 times
Layout indicates a different number of channels than actually present
     Last message repeated 1708 times
size=      80kB time=00:00:00.10 bitrate=6151.6kbits/s
video:0kB audio:80kB subtitle:0 global headers:0kB muxing overhead 0.124512%

bash-3.2$ ffm -request_channels 6 -i 71check.thd  ftest.wav
ffmpeg version N-48748-g8d06be6 Copyright (c) 2000-2013 the FFmpeg 
developers
   built on Jan 11 2013 17:05:16 with gcc 4.5.1 (GCC)
   configuration: --prefix=/usr --enable-gpl --enable-libx264
   libavutil      52. 13.100 / 52. 13.100
   libavcodec     54. 86.100 / 54. 86.100
   libavformat    54. 59.107 / 54. 59.107
   libavdevice    54.  3.102 / 54.  3.102
   libavfilter     3. 32.100 /  3. 32.100
   libswscale      2.  1.103 /  2.  1.103
   libswresample   0. 17.102 /  0. 17.102
   libpostproc    52.  2.100 / 52.  2.100
[truehd @ 0xadd2ee0] max_analyze_duration 5000000 reached at 5000000
[truehd @ 0xadd2ee0] Estimating duration from bitrate, this may be 
inaccurate
Input #0, truehd, from '71check.thd':
   Duration: N/A, start: 0.000000, bitrate: N/A
     Stream #0:0: Audio: truehd, 48000 Hz, 7.1, s32
File 'ftest.wav' already exists. Overwrite ? [y/N] y
Output #0, wav, to 'ftest.wav':
   Metadata:
     ISFT            : Lavf54.59.107
     Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz, 
7.1, s16, 6144 kb/s
Stream mapping:
   Stream #0:0 -> #0:0 (truehd -> pcm_s16le)
Press [q] to stop, [?] for help
Guessed Channel Layout for  Input Stream #0.0 : 5.1
Input stream #0:0 frame changed from rate:48000 fmt:s32 ch:8 chl:7.1 to 
rate:48000 fmt:s32 ch:6 chl:5.1
[truehd @ 0xadd9140] Lossless check failed - expected 44, calculated bb.
Input stream #0:0 frame changed from rate:48000 fmt:s32 ch:6 chl:5.1 to 
rate:48000 fmt:s32 ch:6 chl:6 channels (FL+FR+FC+LFE+BL+BR+SL+SR)
Layout indicates a different number of channels than actually present
     Last message repeated 127 times
[truehd @ 0xadd9140] Lossless check failed - expected 2c, calculated db.
Layout indicates a different number of channels than actually present
     Last message repeated 127 times
[truehd @ 0xadd9140] Lossless check failed - expected b2, calculated 44.
Layout indicates a different number of channels than actually present
     Last message repeated 127 times
[truehd @ 0xadd9140] Lossless check failed - expected 21, calculated 22.
Layout indicates a different number of channels than actually present
     Last message repeated 127 times
[truehd @ 0xadd9140] Lossless check failed - expected 4f, calculated bb.

<snip>
-------------- next part --------------
diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c
index c7de13c..959aa20 100644
--- a/libavcodec/mlpdec.c
+++ b/libavcodec/mlpdec.c
@@ -344,6 +344,8 @@ static int read_major_sync(MLPDecodeContext *m, GetBitContext *gb)
             if (m->avctx->channels==2)
                 m->avctx->channel_layout = AV_CH_LAYOUT_STEREO;
         }
+        if (m->avctx->channels == 6)
+            m->avctx->channel_layout = AV_CH_LAYOUT_5POINT1;
         if (m->avctx->channels &&
             !m->avctx->request_channels && !m->avctx->request_channel_layout &&
             av_get_channel_layout_nb_channels(m->avctx->channel_layout) != m->avctx->channels) {


More information about the ffmpeg-user mailing list