ffmpeg stereo channels into two mono channels
I wanted to know if there is a way to split stereo into two mono wav files. My first guess was
ffmpeg -threads "16" -i "$2" -map 0:1:1 "$3"
because my example video has the following informations:
Audio
ID : 2
Format : AAC
Format/Info : Advanced Audio Codec
Format profile : LC
Codec ID : 40
Duration : 39mn 0s
Bit rate mode : Constant
Bit rate : 256 Kbps
Channel(s) : 2 channels
Channel positions : Front: L R
So I have this one audio stream with two channels and want two mono channels. At first I tried it with map_channel, but that didn't do the trick instead I was getting an error message:
Syntax error, mapchan usage: [file.stream.channel|-1][:syncfile:syncstream]
So I have tried it again with the above mentioned code and at least ffmpeg did something, but the outcome was not what I expected, instead of breaking it down into two mono wav files, the outcome was:
info.system.container = WAVE
info.system.size = 449413166 Bytes
info.system.size = 428.59 MiB
info.system.playtime = 2340.69 s
info.audio0.codec = PCM
info.audio0.desc =
info.audio0.format_endianness = Little
info.audio0.format_sign = Signed
info.audio0.format_resolution = 16 bits
info.audio0.samprate = 48000 Hz
info.audio0.channels = 2
again with two audio channels, so where did I go wrong?
Using ffmpeg there are several methods that I know of to go from stereo to two individual mono files, or two mono streams in one file:
stereo to 2 mono outputs
-map_channel
option
ffmpeg -i stereo.wav -map_channel 0.0.0 left.wav -map_channel 0.0.1 right.wav
pan
audio filter
ffmpeg -i stereo.wav -filter_complex \
"[0:0]pan=1|c0=c0[left]; \
[0:0]pan=1|c0=c1[right]" \
-map "[left]" left.wav -map "[right]" right.wav
stereo to 2 mono streams
channelsplit
audio filter
This will create one output file that has two individual mono streams:
ffmpeg -i input.m4a -filter_complex channelsplit out.mka
Also see
- Manipulating audio channels with ffmpeg
You should use channelsplit filter for that. -map can not do this. For example:
ffmpeg -i in.mp3 -filter_complex channelsplit out.mkv
Check link to documentation that I've provided.