Multiple audio tracks from one source in ffmpeg
Asked Answered
H

1

6

I'm transcoding my video using ffmpeg but I am unable to figure out how I can get both a 2 channel aac option (downmuxed) and a surround AC3 option in one go. My current command is:

ffmpeg -i input.mp4 \
-c:v libx265 -preset medium -crf 21 -pix_fmt yuv420p10le \
-tag:v hvc1 \
-c:a libfdk_aac -b:a 320k \
-c:a ac3 -b:a 512k \
movie_10bit.m4v

But I only get surround out of this. All help is much appreciated.

Hiphuggers answered 25/12, 2017 at 19:17 Comment(0)
A
12

Go with the -map option to ffmpeg. Suppose input stream 0:0 is the video stream and 0:1 is the audio stream (find out by ffmpeg -i input.mp4). Use -map to create one video stream and two audio streams in the output:

ffmpeg -i input.mp4 \
-map 0:0 -map 0:1 -map 0:1 \
-c:v libx265 -preset medium -crf 21 -pix_fmt yuv420p10le \
-tag:v hvc1 \
-c:a:0 libfdk_aac -b:a:0 320k \
-c:a:1 ac3 -b:a:1 512k \
movie_10bit.m4v

-c:a:0 and -c:a:1 describe the codec for the two audio streams.

Addict answered 25/12, 2017 at 19:57 Comment(2)
Thank you! This was very useful but now I notice that I get AAC and AC3 both in stereo. How can I get AAC to be stereo and AC3 to be surround (5.1-6ch)?Hiphuggers
@Hiphuggers I have limited experience with surround but I think you should try with -ac:1 6.Addict

© 2022 - 2024 — McMap. All rights reserved.