Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm trying to use Ubuntu's ffmpeg to convert a file to MKV while copying all the video and subtitle streams, but converting all the audio streams to AC3.

Using this command:

ffmpeg -i input.mkv -map 0 -vcodec copy -scodec copy -acodec ac3 -ab 256k output.mkv

fails with

Number of stream maps must match number of output streams

Removing the -map 0 fixes the problem, but not all of the subtitle streams are in the output file.

Edit

Here's the full console output:

user@laptop:~/$ ffmpeg -i input.mkv -map 0 -vcodec copy -scodec copy -acodec ac3 -ab 256k output.mkv
ffmpeg version 0.8.5-6:0.8.5-0ubuntu0.12.10.1, Copyright (c) 2000-2012 the Libav developers
  built on Jan 24 2013 14:49:20 with gcc 4.7.2
*** THIS PROGRAM IS DEPRECATED ***
This program is only provided for compatibility and will be removed in a future release. Please use avconv instead.
[matroska,webm @ 0xa0cb20] Estimating duration from bitrate, this may be inaccurate
Input #0, matroska,webm, from 'input.mkv':
  Duration: 00:10:56.88, start: 0.000000, bitrate: 1536 kb/s
    Stream #0.0(eng): Video: h264 (High), yuv420p, 1920x1080, PAR 1:1 DAR 16:9, 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
    Stream #0.1(eng): Audio: dca (DTS), 48000 Hz, 5.1, s16, 1536 kb/s (default)
    Stream #0.2(eng): Subtitle: pgssub (default)
    Stream #0.3(fre): Subtitle: pgssub
    Stream #0.4(spa): Subtitle: pgssub
Number of stream maps must match number of output streams
share|improve this question
    
Please post the full, uncut console output. I'm guessing this is because (from the docs), "ffmpeg includes only one stream of each type (video, audio, subtitle) present in the input files and adds them to each output file." –  slhck Mar 18 '13 at 19:28
    
OK, I posted it. –  sashoalm Mar 18 '13 at 19:36
add comment

1 Answer

The behavior you're seeing doesn't really make sense, but given that you're using the broken and "fake" ffmpeg that's actually from Libav and not the real deal, it's probably a bug that has long been fixed. Just a matter of using a recent version where this works normally.

Download a recent static build from the FFmpeg homepage or compile it yourself.

You can shorten down the command to:

ffmpeg -i in.mkv -c copy -c:a ac3 -map 0 out.mkv

FFmpeg will now automatically copy all the streams and map them all to the output, e.g. like this:

Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (aac -> ac3)
  Stream #0:2 -> #0:2 (copy)
  Stream #0:3 -> #0:3 (copy)
  Stream #0:4 -> #0:4 (copy)
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.