'ffmpeg: Add multichannel audio stream (ac3 to aac)
I want my first audio stream to be stereo (by default) and my second to be multichannel (5.1 surround) in my .mp4 video.
There's no problem in replacing the stereo audio stream, but when I try to add a 5.1 multichannel audio stream to the video, ffmpeg does only take the first two channels (front left and right speakers). All other channels are silent. How do I add ALL the channels to my second audio stream?
Here's what I got so far:
ffmpeg -i video.mp4 -i multichannel.ac3 -map 0 -map 1 -c:v copy -c:a aac -strict -2 result.mp4
Here's what my console outputs:
c:a aac -strict -2 result.mp4
ffmpeg version 2.2.2 Copyright (c) 2000-2014 the FFmpeg developers
built on May 22 2014 19:56:44 with gcc 4.8.2 (GCC)
configuration: --disable-static --enable-shared --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-decklink --enable-zlib
libavutil 52. 66.100 / 52. 66.100
libavcodec 55. 52.102 / 55. 52.102
libavformat 55. 33.100 / 55. 33.100
libavdevice 55. 10.100 / 55. 10.100
libavfilter 4. 2.100 / 4. 2.100
libswscale 2. 5.102 / 2. 5.102
libswresample 0. 18.100 / 0. 18.100
libpostproc 52. 3.100 / 52. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'video.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
title :
artist :
encoder : Lavf55.33.100
Duration: 01:00:39.61, start: 0.033333, bitrate: 10521 kb/s
Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv), 1920x1080 [SAR 1:1 DAR 16:9], 10382 kb/s, 30.01 fps, 60 tbr, 30k tbn, 59.94 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
handler_name : SoundHandler
[ac3 @ 00f7d080] Estimating duration from bitrate, this may be inaccurate
Input #1, ac3, from 'multichannel.ac3':
Duration: 01:00:39.58, start: 0.000000, bitrate: 640 kb/s
Stream #1:0: Audio: ac3, 48000 Hz, 5.1(side), fltp, 640 kb/s
Does my problem have anything to do with 5.1(side)
given above? Do I have to change this?
Solution 1:[1]
Your ffmpeg is 7 years old. Much has changed since then. You're wasting your time using such an old version. See the links to already compiled builds on FFmpeg Download and get a new version.
Then run:
ffmpeg -i video.mp4 -i multichannel.ac3 -map 0 -map 1 -c copy output.mp4
Solution 2:[2]
The OP is trying to get an AAC audio, and since the original stream is AC3, he is getting an AC3 stream in this mp4 output. If he really wants AAC, he should run:
ffmpeg -i video.mp4 -i multichannel.ac3 -map 0 -map 1 -c:a aac output_with_aac.mp4
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | llogan |
Solution 2 | JMor |