| Version 1 (modified by , 13 years ago) ( diff ) |
|---|
Manipulating audio channels with ffmpeg
Contents
stereo → 2 × mono streams
Output each channel in stereo input to individual mono streams in one output file with the channelsplit audio filter.
ffmpeg -i in.mp3 -filter_complex channelsplit out.mkv
stereo → 2 × mono files
Output each channel in stereo input to individual mono files:
ffmpeg -i stereo.wav -map_channel 0.0.0 left.wav -map_channel 0.0.1 right.wav
or with the pan audio filer:
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
2 × mono → stereo
Create a stereo output from two mono inputs:
ffmpeg -i left.mp3 -i right.mp3 -ac 2 output.mkv
or with the amerge audio filter:
ffmpeg -i left.mp3 -i right.mp3 -filter_complex amerge output.mkv
6 × mono → 5.1
Combine 6 mono inputs into one 5.1 (6 channel) output with the amerge audio filter:
ffmpeg -i front_left.wav -i front_right.wav -i front_center.wav -i lfe.wav -i back_left.wav -i back_right.wav \ -filter_complex "[0:1][0:2][0:3][0:4][0:5][0:6] amerge=inputs=6" output.wav
All inputs must have the same sample rate and format. If inputs do not have the same duration the output will stop with the shortest.
2 × stereo → stereo
Combine two stereo inputs into one stereo output with the amerge and pan audio filters:
ffmpeg -i input1.wav -i input2.wav -filter_complex "amerge,pan=stereo:c0<c0+c2:c1<c1+c3" output.mp3
Switch stereo channels
Switch left channel to right and right channel to left:
ffmpeg -i stereo.ogg -map_channel 0.0.1 -map_channel 0.0.0 output.wav
or with the pan audio filer:
ffmpeg -i stereo.ogg -af pan=stereo:c0=c1:c1=c0 output.wav
Mute a channel
This example will mute the first channel but keep the second channel as is:
ffmpeg -i stereo.wav -map_channel -1 -map_channel 0.0.1 output.wav
Attachments (15)
-
2mono_stereo.png
(10.4 KB
) - added by 12 years ago.
2 mono files to stereo diagram
-
5point1_stereo.png
(16.0 KB
) - added by 12 years ago.
5.1 to stereo diagram
-
mono_stereo.png
(8.5 KB
) - added by 12 years ago.
mono to stereo diagram
-
mute_stereo_channel.png
(8.4 KB
) - added by 12 years ago.
mute a stereo channel diagram
-
stereo_2mono_outputs.png
(11.4 KB
) - added by 12 years ago.
stereo to 2 mono outputs diagram
-
stereo_2mono_streams.png
(11.1 KB
) - added by 12 years ago.
stereo to 2 mono streams diagram
-
stereo_mono.png
(9.3 KB
) - added by 12 years ago.
stereo to mono diagram
-
stereo_stereo_mix.png
(10.1 KB
) - added by 12 years ago.
stereo to stereo mix diagram
-
switch_stereo_channels.png
(9.5 KB
) - added by 12 years ago.
switch stereo channels diagram
-
2stereo_stereo.png
(15.4 KB
) - added by 12 years ago.
2 stereo inputs to 1 stereo output diagram
-
6mono_5point1.png
(29.3 KB
) - added by 12 years ago.
6 mono inputs to 5.1 output
-
5point1_6mono.png
(29.2 KB
) - added by 12 years ago.
5.1 to individual channels
-
diagrams.tar.gz
(32.9 KB
) - added by 12 years ago.
.dia files for AudioChannelManipulation in case changes are wanted
-
2stereo_stereob.png
(15.3 KB
) - added by 12 years ago.
2 stereo inputs to 1 stereo output diagram, alt
- stereo_mono_exclude.png (9.1 KB ) - added by 9 years ago.
Download all attachments as: .zip


