Warm tip: This article is reproduced from stackoverflow.com, please click
ffmpeg

ffmpeg map mkv with multiple audio to mkv with more audio

发布于 2020-04-11 11:47:37

I've an MKV like this:

Input #0, matroska,webm, from 'MyVideo.mkv':
  Stream #0:0(eng): Video: h264 (High), yuv420p(progressive), 1920x1080, 23.98 fps
  Stream #0:1(fre): Audio: dts (DTS), 48000 Hz, 5.1(side), fltp, 768 kb/s (default)
  Stream #0:2(eng): Audio: dts (DTS), 48000 Hz, 5.1(side), fltp, 1536 kb/s

I've would like an output MKV like this:

Output:
  Stream #0:0(eng): Video: h264 (High), yuv420p(progressive), 1920x1080, 23.98 fps
  Stream #0:1(fre): Audio: E-AC-3, 5.1, 384 kb/s
  Stream #0:2(fre): Audio: E-AC-3, stereo, 384 kb/s
  Stream #0:3(eng): Audio: E-AC-3, 5.1, 384 kb/s
  Stream #0:4(eng): Audio: E-AC-3, stereo, 384 kb/s

Following this page: https://trac.ffmpeg.org/wiki/Map (Example 1), I'm doing this:

ffmpeg -i MyVideo.mkv \
-map 0:0 -map 0:1 -map 0:1 -map 0:2 -map 0:2 \
-c:v copy
-c:a:0 eac3 -ab 384k -ac 6 \
-c:a:1 eac3 -ab 384k -ac 2 \
-c:a:2 eac3 -ab 384k -ac 6 \
-c:a:3 eac3 -ab 384k -ac 2
output.mkv

But I'm getting this output:

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'output.mkv':
  Stream #0:0(eng): Video: h264 (High) (High), yuv420p(progressive), 1920x1080, 23.98 fps
  Stream #0:1(fre): Audio: eac3 (ec-3), 48000 Hz, stereo, fltp, 384 kb/s
  Stream #0:2(fre): Audio: eac3 (ec-3), 48000 Hz, stereo, fltp, 384 kb/s
  Stream #0:3(eng): Audio: eac3 (ec-3), 48000 Hz, stereo, fltp, 384 kb/s
  Stream #0:4(eng): Audio: aac (LC) (mp4a), 48000 Hz, stereo, fltp, 378 kb/s

Do you have an idea what is my mistake ? I think it's around my map and -c:a:x parameters

Questioner
locobastos
Viewed
121
locobastos 2020-02-02 06:13

Found my error, missing ab:x and ac:x to specify the bitrate and the channel to each output audio stream

from:

-c:a:0 eac3 -ab 384k -ac 6
-c:a:1 eac3 -ab 384k -ac 2
-c:a:2 eac3 -ab 384k -ac 6
-c:a:3 eac3 -ab 384k -ac 2

to:

-c:a:0 eac3 -ab:0 384k -ac:0 6
-c:a:1 eac3 -ab:1 384k -ac:1 2
-c:a:2 eac3 -ab:2 384k -ac:2 6
-c:a:3 eac3 -ab:3 384k -ac:3 2