FFmpeg -map 0 fails with error "Number of stream maps must match number of output streams"
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)
sashoalm
Updated on September 18, 2022Comments
-
sashoalm almost 2 years
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
-
slhck over 11 yearsPlease 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."
-
sashoalm over 11 yearsOK, I posted it.
-