Opened 9 years ago

Last modified 9 years ago

#4823 open defect

Options -ac, -ar and -sample_fmt do not behave as documented / use another stream_specifier than -codec

Reported by: John Galt Owned by:
Priority: normal Component: undetermined
Version: git-master Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

How to reproduce:
ffmpeg -c:a:0 ac3 -ac 6 -ab 448k -ar48000
Where a:0 = DTS or a DTS MA Track
9/1/2015

It appears to ignore the 6 in the -ac 6 and just down mixes to 2 tracks.

Change History (12)

comment:1 by Carl Eugen Hoyos, 9 years ago

Please provide an actual command line together with the complete, uncut console output to make this a valid ticket.

comment:2 by John Galt, 9 years ago

ffmpeg -probesize 5G -analyzeduration 5G -i "sample.mkv" -map 0:0 -map 0:1 -map 0:2 -map 0:1 -map 0:2 -c:v copy -c:a:0 copy -c:a:1 copy -c:a:2 ac3 -ac 6 -ab 448k -ar 48000 -c:a:3 aac -ac 2 -ab 192k -ar 48000 -scodec copy -strict experimental -f mp4 -movflags faststart "result.m4v"
ffmpeg version N-74737-g1acd631 Copyright (c) 2000-2015 the FFmpeg developers

built with gcc 4.9.3 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --enable-decklink --enable-zlib
libavutil 54. 31.100 / 54. 31.100
libavcodec 56. 59.100 / 56. 59.100
libavformat 56. 40.101 / 56. 40.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 40.100 / 5. 40.100
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.101 / 1. 2.101
libpostproc 53. 3.100 / 53. 3.100

Input #0, matroska,webm, from 'sample.mkv':

Metadata:

title : Sample
encoder : libebml v1.3.1 + libmatroska v1.4.2
creation_time : 2015-03-08 08:00:40

Duration: 01:22:16.31, start: 0.000000, bitrate: 24136 kb/s

Chapter #0:0: start 0.000000, end 312.395000
Metadata:

title : (01)00:00:00:000

Chapter #0:1: start 312.395000, end 746.287000
Metadata:

title : (02)00:05:12:395

Chapter #0:2: start 746.287000, end 778.527000
Metadata:

title : (03)00:12:26:287

Chapter #0:3: start 778.527000, end 1116.657000
Metadata:

title : (04)00:12:58:527

Chapter #0:4: start 1116.657000, end 1401.400000
Metadata:

title : (05)00:18:36:657

Chapter #0:5: start 1401.400000, end 1475.390000
Metadata:

title : (06)00:23:21:400

Chapter #0:6: start 1475.390000, end 1543.625000
Metadata:

title : (07)00:24:35:390

Chapter #0:7: start 1543.625000, end 1632.255000
Metadata:

title : (08)00:25:43:625

Chapter #0:8: start 1632.255000, end 2070.109000
Metadata:

title : (09)00:27:12:255

Chapter #0:9: start 2070.109000, end 2307.722000
Metadata:

title : (10)00:34:30:109

Chapter #0:10: start 2307.722000, end 2386.967000
Metadata:

title : (11)00:38:27:722

Chapter #0:11: start 2386.967000, end 2457.580000
Metadata:

title : (12)00:39:46:967

Chapter #0:12: start 2457.580000, end 2634.506000
Metadata:

title : (13)00:40:57:580

Chapter #0:13: start 2634.506000, end 2946.026000
Metadata:

title : (14)00:43:54:506

Chapter #0:14: start 2946.026000, end 3156.319000
Metadata:

title : (15)00:49:06:026

Chapter #0:15: start 3156.319000, end 3233.188000
Metadata:

title : (16)00:52:36:319

Chapter #0:16: start 3233.188000, end 3369.657000
Metadata:

title : (17)00:53:53:188

Chapter #0:17: start 3369.657000, end 3484.731000
Metadata:

title : (18)00:56:09:657

Chapter #0:18: start 3484.731000, end 3717.964000
Metadata:

title : (19)00:58:04:731

Chapter #0:19: start 3717.964000, end 4033.696000
Metadata:

title : (20)01:01:57:964

Chapter #0:20: start 4033.696000, end 4200.446000
Metadata:

title : (21)01:07:13:696

Chapter #0:21: start 4200.446000, end 4349.887000
Metadata:

title : (22)01:10:00:446

Chapter #0:22: start 4349.887000, end 4611.523000
Metadata:

title : (23)01:12:29:887

Chapter #0:23: start 4611.523000, end 4805.926000
Metadata:

title : (24)01:16:51:523

Chapter #0:24: start 4805.926000, end 4936.307000
Metadata:

title : (25)01:20:05:926

Stream #0:0: Video: h264 (High), yuv420p(tv, bt709), 1920x1080, SAR 1:1 DAR 16:9, 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
Metadata:

title : Sample

Stream #0:1(eng): Audio: dts (DTS-HD MA), 48000 Hz, 5.1(side), fltp (default)
Metadata:

title : Sample

Stream #0:2(eng): Audio: dts (DTS), 48000 Hz, 5.1(side), fltp, 1536 kb/s
Metadata:

title : Sample

Stream #0:3(fre): Audio: ac3, 48000 Hz, 5.1(side), fltp, 448 kb/s
Metadata:

title : Sample

Stream #0:4(spa): Audio: ac3, 48000 Hz, 5.1(side), fltp, 448 kb/s
Metadata:

title : Sample

Stream #0:5(por): Audio: ac3, 48000 Hz, 5.1(side), fltp, 448 kb/s
Metadata:

title : Sample

Stream #0:6(hun): Audio: ac3, 48000 Hz, 5.1(side), fltp, 448 kb/s
Metadata:

title : Sample

Stream #0:7(pol): Audio: ac3, 48000 Hz, 5.1(side), fltp, 448 kb/s
Metadata:

title : Sample

Stream #0:8(eng): Subtitle: hdmv_pgs_subtitle, 1920x1080
Stream #0:9(fre): Subtitle: hdmv_pgs_subtitle, 1920x1080
Stream #0:10(spa): Subtitle: hdmv_pgs_subtitle, 1920x1080
Stream #0:11(por): Subtitle: hdmv_pgs_subtitle, 1920x1080
Stream #0:12(bul): Subtitle: hdmv_pgs_subtitle, 1920x1080
Stream #0:13(hun): Subtitle: hdmv_pgs_subtitle, 1920x1080
Stream #0:14(pol): Subtitle: hdmv_pgs_subtitle, 1920x1080
Stream #0:15(rum): Subtitle: hdmv_pgs_subtitle, 1920x1080
Stream #0:16(spa): Subtitle: hdmv_pgs_subtitle, 1920x1080
Stream #0:17(por): Subtitle: hdmv_pgs_subtitle, 1920x1080
Stream #0:18(hun): Subtitle: hdmv_pgs_subtitle, 1920x1080
Stream #0:19(pol): Subtitle: hdmv_pgs_subtitle, 1920x1080
Stream #0:20(fre): Subtitle: hdmv_pgs_subtitle, 1920x1080

in reply to:  2 comment:3 by James, 9 years ago

Replying to JohnGalt:

ffmpeg -probesize 5G -analyzeduration 5G -i "sample.mkv" -map 0:0 -map 0:1 -map 0:2 -map 0:1 -map 0:2 -c:v copy -c:a:0 copy -c:a:1 copy -c:a:2 ac3 -ac 6 -ab 448k -ar 48000 -c:a:3 aac -ac 2 -ab 192k -ar 48000 -scodec copy -strict experimental -f mp4 -movflags faststart "result.m4v"

I think the problem is the -ac 2 meant for the aac track. It's being set for all the audio tracks.

Try using -ac:2 6 and -ac:3 2.

comment:4 by John Galt, 9 years ago

Changing it to:

-c:a:2 ac3 -ac:2 6 -ab:2 448k -ar:2 48000 -c:a:3 aac -ac:3 2 -ab:3 192k -ar:3 48000

Had the same results. The AC3 track is 2 channel stereo the same as the aac track

comment:5 by John Galt, 9 years ago

Other interesting thing: In Media Info the DTS:MA and DTS tracks show channels: 2, Original Channels: 8 and 6 respectively. It's like instead of doing a copy it's modifying them too.

comment:6 by James, 9 years ago

Could you post the entire console output? You left the details about the generated output file out in comment 2. And it would also help if you could upload the same, or at least a cut version of it as mentioned in https://ffmpeg.org/bugreports.html, then either upload it here or to the ftp.

Also, you may want to force the usage of libdcadec (which i see you enabled during configure), rather than the internal dca decoder since that one isn't truly lossless yet.
Simply add -c:a:# libdcadec before the -i parameter, or just recompile ffmpeg with --disable-decoder=dca.

comment:7 by John Galt, 9 years ago

You can download the sample from here:

http://www.demo-world.eu/download-2d-trailers/?file=dts_hd_master_audio_sound_check_7_1_lossless-DWEU.mkv&pic=dts_hd_master_audio_sound_check_7_1_lossless.jpg

and click on the mage between the two adds. This is simplified but the result is the same. You get DTSMA with channels(s): 2 channels, Channel(s)_Original: 8 channels/6 chnanels and then AC3 2 channel stereo and aac 2 channel stereo.

Given that I'm explicit about the mappings now I would have expected the AC3 track to be 6 channel converted from the DTS-MA track and the aac track to be 2 channel converted from the DTS-MA track.

ffmpeg -probesize 5G -analyzeduration 5G -i "dts_hd_master_audio_sound_check_7_1_lossless-DWEU.mkv" -map 0:0 -map 0:1 -map 0:1 -map 0:1 -c:v copy -c:a:0 copy -c:a:1 ac3 -ac:1 6 -ab:1 448k -ar:1 48000 -c:a:2 aac -ac:2 2 -ab:2 192k -ar:2 48000 -scodec copy -strict experimental -f mp4 -movflags faststart "dts hd master audio sound check 7 1 lossless-DWEU.m4v"
ffmpeg version N-74737-g1acd631 Copyright (c) 2000-2015 the FFmpeg developers

built with gcc 4.9.3 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --enable-decklink --enable-zlib
libavutil 54. 31.100 / 54. 31.100
libavcodec 56. 59.100 / 56. 59.100
libavformat 56. 40.101 / 56. 40.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 40.100 / 5. 40.100
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.101 / 1. 2.101
libpostproc 53. 3.100 / 53. 3.100

Input #0, matroska,webm, from 'd:\downloads\dts_hd_master_audio_sound_check_7_1_lossless-DWEU.mkv':

Metadata:

encoder : libebml v1.3.0 + libmatroska v1.4.1
creation_time : 2015-04-06 09:50:07

Duration: 00:04:18.13, start: 0.000000, bitrate: 7533 kb/s

Stream #0:0(eng): Video: h264 (High), yuv420p, 1920x1080, SAR 1:1 DAR 16:9, 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
Stream #0:1(eng): Audio: dts (DTS-HD MA), 48000 Hz, 5.1(side), fltp (default)

[mp4 @ 0000000005890920] Codec for stream 0 does not use global headers but container format requires global headers
[mp4 @ 0000000005890920] Codec for stream 1 does not use global headers but container format requires global headers
[mp4 @ 0000000005890920] track 1: codec frame size is not set
Output #0, mp4, to 'd:\downloads\dts hd master audio sound check 7 1 lossless-DWEU.m4v':

Metadata:

Name : dts hd master audio sound check 7 1 lossless-DWEU
title : dts hd master audio sound check 7 1 lossless-DWEU
encoder : Lavf56.40.101
Stream #0:0(eng): Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 23.98 fps, 23.98 tbr, 16k tbn, 1k tbc (default)
Stream #0:1(eng): Audio: dts ([169][0][0][0] / 0x00A9), 48000 Hz, 5.1(side) (default)
Stream #0:2(eng): Audio: ac3 ([165][0][0][0] / 0x00A5), 48000 Hz, stereo, fltp, 192 kb/s (default)
Metadata:

encoder : Lavc56.59.100 ac3

Stream #0:3(eng): Audio: aac ([64][0][0][0] / 0x0040), 48000 Hz, 5.1(side), fltp, 128 kb/s (default)
Metadata:

encoder : Lavc56.59.100 aac

Stream mapping:

Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)
Stream #0:1 -> #0:2 (dts (dca) -> ac3 (native))
Stream #0:1 -> #0:3 (dts (dca) -> aac (native))

Press [q] to stop, ? for help
[mp4 @ 0000000005890920] Starting second pass: moving the moov atom to the beginning of the file
frame= 6188 fps=235 q=-1.0 Lsize= 247215kB time=00:04:18.13 bitrate=7845.4kbits/s
video:161764kB audio:84700kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.304666%

comment:8 by James, 9 years ago

Keywords: ac3 dts removed
Status: newopen

With the same mappings, try "-c:a:0 copy -c:a:1 ac3 -ac:2 6 -c:a:2 aac -ac:3 2" instead. Apparently the -ac option considers all the streams from the output file and not just the audio ones.
I'm not sure if this is intended, so I'll keep this open until someone else can confirm.

And again, i recommend you to use the libdcadec decoder instead of the internal dca decoder. It will allow you to decode all 8 channels from the dts-ma stream losslessly.

comment:9 by John Galt, 9 years ago

Ok, that's odd, but it works. Now the only thing that isn't working properly (or maybe it is) is that the DTS Master track that's the first one that is copied shows in the original .mkv as 8 channels for the channels property and in the remixed output it's showing as 2 channels and original = 8 instead of showing as 8 channels. (But then shows channel positions for all 8 channels)

If I use MKV instead of m4v, the resulting file shows all 8 channels though.

comment:10 by Elon Musk, 9 years ago

Can this still be reproduced?

comment:11 by Carl Eugen Hoyos, 9 years ago

There is definitely a bug, it is just unknown whether the bug is in the documentation or the code:
https://ffmpeg.org/ffmpeg-all.html#Audio-Options mentions the same stream_specifier for -ac as https://ffmpeg.org/ffmpeg-all.html#Main-options for -codec but the following does not work as documented:

$ ffmpeg -i fate-suite/svq3/Vertical400kbit.sorenson3.mov -c:a:0 ac3 -ac:0 2 out.avi
ffmpeg version N-78323-gaa75157 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 4.7 (SUSE Linux)
  configuration: --enable-gpl --enable-libmp3lame
  libavutil      55. 17.100 / 55. 17.100
  libavcodec     57. 24.101 / 57. 24.101
  libavformat    57. 24.101 / 57. 24.101
  libavdevice    57.  0.101 / 57.  0.101
  libavfilter     6. 28.100 /  6. 28.100
  libswscale      4.  0.100 /  4.  0.100
  libswresample   2.  0.101 /  2.  0.101
  libpostproc    54.  0.100 / 54.  0.100
Guessed Channel Layout for  Input Stream #0.1 : mono
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'fate-suite/svq3/Vertical400kbit.sorenson3.mov':
  Metadata:
    creation_time   : 2001-03-20 16:17:18
    title           : Vertical Online SV3 Demo
    title-eng       : Vertical Online SV3 Demo
    artist          : Logan Kelsey
    artist-eng      : Logan Kelsey
    copyright       : © Vertical Online 2001
    copyright-eng   : © Vertical Online 2001
    encoder         : Sorenson Video 3
    encoder-eng     : Sorenson Video 3
  Duration: 00:00:43.58, start: 0.000000, bitrate: 580 kb/s
    Stream #0:0(eng): Video: svq3 (SVQ3 / 0x33515653), yuvj420p(pc), 320x240, 391 kb/s, 30.02 fps, 30 tbr, 600 tbn, 600 tbc (default)
    Metadata:
      creation_time   : 2001-03-20 16:17:18
      handler_name    : Apple Alias Data Handler
      encoder         : Sorenson Video 3
    Stream #0:1(eng): Audio: adpcm_ima_qt (ima4 / 0x34616D69), 44100 Hz, 1 channels, s16p, 176 kb/s (default)
    Metadata:
      creation_time   : 2001-03-20 16:17:18
      handler_name    : Apple Alias Data Handler
[swscaler @ 0x25fc740] deprecated pixel format used, make sure you did set range correctly
Output #0, avi, to 'out.avi':
  Metadata:
    ISFT            : Lavf57.24.101
    INAM            : Vertical Online SV3 Demo
    title-eng       : Vertical Online SV3 Demo
    IART            : Logan Kelsey
    artist-eng      : Logan Kelsey
    ICOP            : © Vertical Online 2001
    copyright-eng   : © Vertical Online 2001
    Stream #0:0(eng): Video: mpeg4 (FMP4 / 0x34504D46), yuv420p, 320x240, q=2-31, 200 kb/s, 30 fps, 30 tbn, 30 tbc (default)
    Metadata:
      creation_time   : 2001-03-20 16:17:18
      handler_name    : Apple Alias Data Handler
      encoder         : Lavc57.24.101 mpeg4
    Side data:
      unknown side data type 10 (24 bytes)
    Stream #0:1(eng): Audio: ac3 ([0] [0][0] / 0x2000), 44100 Hz, mono, fltp, 96 kb/s (default)
    Metadata:
      creation_time   : 2001-03-20 16:17:18
      handler_name    : Apple Alias Data Handler
      encoder         : Lavc57.24.101 ac3
Stream mapping:
  Stream #0:0 -> #0:0 (svq3 (native) -> mpeg4 (native))
  Stream #0:1 -> #0:1 (adpcm_ima_qt (native) -> ac3 (native))
Press [q] to stop, [?] for help
Multiple frames in a packet from stream 1
frame= 1308 fps=1234 q=2.0 Lsize=    1732kB time=00:00:43.60 bitrate= 325.4kbits/s speed=41.1x
video:1151kB audio:511kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 4.234080%

The following - unexpectedly - does produce stereo output:

$ ffmpeg -i fate-suite/svq3/Vertical400kbit.sorenson3.mov -c:a:0 ac3 -ac:1 2 out.avi

Not a regression afaict.

Last edited 9 years ago by Carl Eugen Hoyos (previous) (diff)

comment:12 by Carl Eugen Hoyos, 9 years ago

Summary: Conversion from DTS/DTS-MA to AC3 results in 2 channels instead of 6Options -ac, -ar and -sample_fmt do not behave as documented / use another stream_specifier than -codec
Note: See TracTickets for help on using tickets.