3

I have a file that has the following format (note the number of tracks and channels within each track):

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'a.mov':
  Metadata:
    major_brand     : qt
    minor_version   : 537199360
    compatible_brands: qt
    creation_time   : 2015-05-13 12:07:36
    encoder         : Lavf56.15.102
  Duration: 00:01:02.04, start: 0.000000, bitrate: 29083 kb/s
    Stream #0:0(eng): Video: prores (apch / 0x68637061), yuv422p10le, 1920x1080, 19872 kb/s, 25 fps, 25 tbr, 12800 tbn, 12800 tbc (default)
    Metadata:
      creation_time   : 2015-05-13 12:07:36
      handler_name    : Apple Alias Data Handler
      encoder         : Lavc56.1.100 prores
    Stream #0:1(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, 8 channels (FL+FR+FC+LFE+BL+BR+DL+DR), s32 (24 bit), 9216 kb/s (default)
    Metadata:
      creation_time   : 2015-05-13 12:07:36
      handler_name    : Apple Alias Data Handler

I want to create 2 files from that - one with the video, and one with the audio. I also want the audio file to have 7 tracks - one with the first 2 channels, and another 6 with each of the remaining channels.

If I use the following command,

ffmpeg.exe -i "a.mov" -an -dn -sn -y "a.video.mp4" -map 0:1 -map_channel 0.1.0:0.0.0 -map_channel 0.1.1:0.0.1 -map 0:1 -map_channel 0.1.2:0.1.0 -map 0:1 -map_channel 0.1.3:0.2.0 -map 0:1 -map_channel 0.1.4:0.3.0 -map 0:1 -map_channel 0.1.5:0.4.0 -map 0:1 -map_channel 0.1.6:0.5.0 -map 0:1 -map_channel 0.1.7:0.6.0 -acodec pcm_s16le -ar 48000 -y "a.audio.mov"

...I get the correct video file but the audio file contains 7 tracks, each one containing 8 channels.

However, if I skip the video part and do:

ffmpeg -i "a.mov" -map 0:1 -map_channel 0.1.0:0.0.0 -map_channel 0.1.1:0.0.1 -map 0:1 -map_channel 0.1.2:0.1.0 -map 0:1 -map_channel 0.1.3:0.2.0 -map 0:1 -map_channel 0.1.4:0.3.0 -map 0:1 -map_channel 0.1.5:0.4.0 -map 0:1 -map_channel 0.1.6:0.5.0 -map 0:1 -map_channel 0.1.7:0.6.0 -acodec pcm_s16le -ar 48000 -y -ss 00:00:00 -t 00:01:02.0400000 "a.audio.mov"

I get the audio I'm expecting.

A workaround could be to call FFmpeg twice, one for video and one for audio, but I'd ideally like to avoid that.

Am I doing something wrong? Is map_channel not meant to work like that or is it a bug?

  • I think you need to specify -ac 1 to tell it to make the audio streams single channel. When you use the map command it makes a new stream, which can have any number of channels, and it defaults to the same number as the input. – stib Jul 23 '15 at 11:50
  • -ac 1 mixes all the channels together so it won't give me what I need (as described in the question). Are you sure that this is the expected behavior of the map command? Because it looks like it's working as I expect when I only have an audio file as output. – charisk Jul 23 '15 at 14:43
  • have a look at ffmpeg.org/ffmpeg.html#Audio-Options I think that means you need to do -ac:[stream specifier] 1 e.g. -ac:0.0.0 1 -ac:0.1.0 1… for each of your output streams. See if that works. – stib Jul 24 '15 at 2:08
  • Tried it and it doesn't do what I'm after - it downmixes channels into one so I end up with the audio of all 8 channels in a single channel. What I want is to just grab specific files. – charisk Jul 24 '15 at 10:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.