[FFmpeg-user] Handling video with four-channels of audio
Moritz Barsnick
barsnick at gmx.net
Thu Feb 25 23:12:47 CET 2016
On Thu, Feb 25, 2016 at 21:34:24 +0000, Karl E. Fitzke wrote:
> I've successfully experimented with extracting the four channels of
> audio, reconstructing two streams of two-channel audio from that, and
> then replacing the video's original audio with the new audio streams.
> But I wonder if there is a one command line solution?
Oh sure there is. Show me your command line, I'll show you mine. :-)
(Honestly, a command line and complete, uncut console output would help
in adapting to your needs, not to some theory about them.)
Let me assume you have a captured multimedia file with one video stream
0:0 and four mono audio streams 0:1, 0:2, 0:3, 0:4, right?
I assume you're mapping the audio to stereo something like this:
https://trac.ffmpeg.org/wiki/AudioChannelManipulation#a2monostereo
so:
$ [...] -filter_complex "[0:1][0:2]amerge=inputs=2[a1]; [0:3][0:4]amerge=inputs=2[a2]" [...] -map "[a1]" -map "[a2]"
Add the mapping of the video stream, then you have the input side of
your command.
> I'd like to store these masters as two streams of two-channel audio
> and generate mpeg4, prores, and msmpeg4v2 derivatives; with aac, aac,
> and mp3 audio for each of those respectively.
That is the output side. You can specify the three outputs in one
command. For each of these, the leading output options are valid,
respectively.
$ ffmpeg -i inputfile -filter_complex "[0:1][0:2]amerge=inputs=2[a1]; [0:3][0:4]amerge=inputs=2[a2]" -map 0:v -map "[a1]" -map "[a2]" -c:v mpeg4 -c:a aac file1.mkv -c:v prores -c:a aac file2.mkv -c:v msmpeg4v2 -c:a libmp3lame file3.mkv
Add your respective codec parameters (like -b:v, -b:a or -q:v, -q:a)
before each corresponding output file. Or just leave the defaults
ffmpeg chooses.
> Can I do that with two streams of audio for all cases above? Any
> reason I shouldn't bother doing so?
No! You can, so you should.
(You might be able to optimize the aac encoding by doing it only once,
if the tee muxer allows this case. But the aac encoding doesn't take
the most CPU of this command.)
> Assuming I should reformat the audio, any advice how?
What format where you thinking of? I think you already mentionend
2xmono -> stereo. If you don't have really weird sample rates or
something, then I don't see why. Video and audio formats may depend on
the output containers you are considering to use though. You didn't say
anything, I just used matroska in the above example.
Cheers,
Moritz
More information about the ffmpeg-user
mailing list