Changes between Version 30 and Version 31 of AudioChannelManipulation


Ignore:
Timestamp:
Jan 22, 2019, 4:13:02 AM (6 months ago)
Author:
llogan
Comment:

added some more examples and fix some nits

Legend:

Unmodified
Added
Removed
Modified
  • AudioChannelManipulation

    v30 v31  
    3434[[Image(stereo_mono_exclude.png, nolink)]]
    3535
    36 This example uses the [https://ffmpeg.org/ffmpeg-filters.html#pan pan] audio filter to include only the right channel:
     36This example uses the [https://ffmpeg.org/ffmpeg-filters.html#channelsplit channelsplit] audio filter to include only the right channel:
     37
     38{{{
     39ffmpeg -i stereo.wav -filter_complex "[0:a]channelsplit=channel_layout=stereo:channels=FR[right]" -map "[right]" front_right.wav
     40}}}
     41
     42* If you only want the left channel use `FL` instead of `FR`. See `ffmpeg -layouts` for a list of channel names.
     43
     44Example using the [https://ffmpeg.org/ffmpeg-filters.html#pan pan] audio filter:
    3745
    3846{{{
     
    4048}}}
    4149
    42 If you only want the left channel use `c0=c0` instead.
     50* Alternatively, you could use `c0=FR` instead.
     51* If want the left channel instead use `c0=c0` or `c0=FL`.
     52
    4353
    4454= stereo → 2 × mono files =
     
    4656[[Image(stereo_2mono_outputs.png, nolink)]]
    4757
    48 Output each channel in stereo input to individual mono files:
     58Output each channel in stereo input to individual mono files with the [https://ffmpeg.org/ffmpeg-filters.html#channelsplit channelsplit] audio filter:
     59
     60{{{
     61ffmpeg -i stereo.wav -filter_complex "[0:a]channelsplit=channel_layout=stereo[left][right]" -map "[left]" left.wav -map "[right]" right.wav
     62}}}
     63
     64or with the `-map_channel` option:
    4965
    5066{{{
     
    6581
    6682{{{
    67 ffmpeg -i in.mp3 -filter_complex channelsplit=channel_layout=stereo out.mka
     83ffmpeg -i in.mp3 -filter_complex "[0:a]channelsplit=channel_layout=stereo" output.mka
    6884}}}
    6985
     
    86102
    87103{{{
    88 ffmpeg -i input.mp3 -filter_complex "[0:a][0:a]amerge=inputs=2[aout]" -map "[aout]" output.m4a
     104ffmpeg -i input.mp3 -filter_complex "[0:a][0:a]amerge=inputs=2[a]" -map "[a]" output.m4a
    89105}}}
    90106
     
    101117
    102118{{{
    103 ffmpeg -i left.mp3 -i right.mp3 -filter_complex "[0:a][1:a]amerge=inputs=2[aout]" -map "[aout]" output.mka
     119ffmpeg -i left.mp3 -i right.mp3 -filter_complex "[0:a][1:a]amerge=inputs=2[a]" -map "[a]" output.mka
    104120}}}
    105121
     
    112128{{{
    113129ffmpeg -i front_left.wav -i front_right.wav -i front_center.wav -i lfe.wav -i back_left.wav -i back_right.wav \
    114 -filter_complex "[0:a][1:a][2:a][3:a][4:a][5:a]amerge=inputs=6[aout]" -map "[aout]" output.wav
     130-filter_complex "[0:a][1:a][2:a][3:a][4:a][5:a]amerge=inputs=6[a]" -map "[a]" output.wav
    115131}}}
    116132
     
    121137[[Image(5point1_6mono.png, nolink)]]
    122138
    123 Split a 5.1 channel input into individual per-channel files:
     139Split a 5.1 channel input into individual per-channel files using the [https://ffmpeg.org/ffmpeg-filters.html#channelsplit channelsplit] audio filter:
    124140
    125141{{{
     
    152168}}}
    153169
    154 If you want to map specific channels and drop the rest you can use the [https://ffmpeg.org/ffmpeg-filters.html#pan pan audio filter]. This will map the `FL` (Front Left) of the input to the  `FL` of the output, and the `FR` (Front Right) of the input to the `FR` of the output:
     170If you want to map specific channels and drop the rest you can use the [https://ffmpeg.org/ffmpeg-filters.html#pan pan] audio filter. This will map the `FL` (Front Left) of the input to the  `FL` of the output, and the `FR` (Front Right) of the input to the `FR` of the output:
    155171
    156172{{{
     
    173189
    174190{{{
    175 ffmpeg -i input1.wav -i input2.wav -filter_complex "[0:a][1:a]amerge=inputs=2,pan=stereo|c0<c0+c2|c1<c1+c3[aout]" -map "[aout]" output.mp3
     191ffmpeg -i input1.wav -i input2.wav -filter_complex "[0:a][1:a]amerge=inputs=2,pan=stereo|c0<c0+c2|c1<c1+c3[a]" -map "[a]" output.mp3
    176192}}}
    177193
     
    179195
    180196{{{
    181 ffmpeg -i input1.wav -i input2.wav -filter_complex "[0:a][1:a]amerge=inputs=2[aout]" -map "[aout]" -ac 2 output.mp3
     197ffmpeg -i input1.wav -i input2.wav -filter_complex "[0:a][1:a]amerge=inputs=2[a]" -map "[a]" -ac 2 output.mp3
    182198}}}
    183199
     
    193209Just change the channel specifications in the pan filter:
    194210{{{
    195 ffmpeg -i input1.wav -i input2.wav -filter_complex "[0:a][1:a]amerge=inputs=2,pan=stereo|c0<c0+c1|c1<c2+c3[aout]" -map "[aout]" output.mp3
     211ffmpeg -i input1.wav -i input2.wav -filter_complex "[0:a][1:a]amerge=inputs=2,pan=stereo|c0<c0+c1|c1<c2+c3[a]" -map "[a]" output.mp3
    196212}}}
    197213
     
    212228[[Image(switch_stereo_channels.png, nolink)]]
    213229
    214 Switch left channel to right and right channel to left:
     230Switch left channel to right and right channel to left with the [https://ffmpeg.org/ffmpeg-filters.html#pan pan] audio filer:
     231
     232{{{
     233ffmpeg -i stereo.ogg -af pan=stereo|c0=c1|c1=c0 output.wav
     234}}}
     235
     236or with `-map_channel`:
    215237
    216238{{{
     
    218240}}}
    219241
    220 or with the [https://ffmpeg.org/ffmpeg-filters.html#pan pan] audio filer:
    221 
    222 {{{
    223 ffmpeg -i stereo.ogg -af pan=stereo|c0=c1|c1=c0 output.wav
    224 }}}
     242----
     243
     244= Mute a channel =
     245
     246[[Image(mute_stereo_channel.png, nolink)]]
     247
     248This example uses the [https://ffmpeg.org/ffmpeg-filters.html#pan pan] audio filter to mute the first channel (front left) but keep the second channel (front right) as is:
     249
     250{{{
     251ffmpeg -i stereo.wav -af "pan=stereo|c1=c1" output.wav
     252}}}
     253
     254Example using the `-map_channel` option:
     255
     256{{{
     257ffmpeg -i stereo.wav -map_channel -1 -map_channel 0.0.1 output.wav
     258}}}
     259
     260----
    225261
    226262= Virtual Binaural Acoustics =
    227263
    228 FFmpeg can produce virtual binaural acoustics files using sofalizer filter,
    229 most known channel layouts are supported for input, output is always stereo.
     264FFmpeg can produce virtual binaural acoustics files using the [https://ffmpeg.org/ffmpeg-filters.html#sofalizer sofalizer] audio filter. Most known channel layouts are supported for the input, and the output is always stereo.
    230265
    231266{{{
     
    233268}}}
    234269
    235 SOFA files can be found on http://sofacoustics.org/data/database/ari/
    236 
    237 ----
    238 
    239 = Mute a channel =
    240 
    241 [[Image(mute_stereo_channel.png, nolink)]]
    242 
    243 This example will mute the first channel (the left channel) but keep the second channel as is:
    244 
    245 {{{
    246 ffmpeg -i stereo.wav -map_channel -1 -map_channel 0.0.1 output.wav
    247 }}}
     270SOFA files can be found at [https://sofacoustics.org/data/database/ari/ sofacoustics.org].
     271
     272----
     273
     274= Multiple channel layouts =
     275
     276This example combines two layouts (5.1+2.0) into a single arbitrary layout using the [https://ffmpeg.org/ffmpeg-filters.html#pan pan] audio filter:
     277
     278{{{
     279ffmpeg -i input -filter_complex "pan=5.1+downmix|FL=c0|FR=c1|FC=c2|LFE=c3|BL=c4|BR=c5|DL=c6|DR=c7[a]" -map "[a]" out.wav
     280}}}
     281
     282The output in the example resulted in one audio stream with 8 channels.
    248283
    249284----
     
    251286= Statistics =
    252287
    253 The [https://ffmpeg.org/ffmpeg-filters.html#astats astats audio filter] can display information including length, DC offset, min/max levels, peak/RMS level dB:
     288The [https://ffmpeg.org/ffmpeg-filters.html#astats astats] audio filter can display information including length, DC offset, min/max levels, peak/RMS level dB:
    254289
    255290{{{
     
    293328----
    294329
    295 = Layouts =
     330= List channel names and standard channel layouts =
    296331
    297332Output from `ffmpeg -layouts`:
     
    299334{{{
    300335Individual channels:
    301 NAME        DESCRIPTION
    302 FL          front left
    303 FR          front right
    304 FC          front center
    305 LFE         low frequency
    306 BL          back left
    307 BR          back right
    308 FLC         front left-of-center
    309 FRC         front right-of-center
    310 BC          back center
    311 SL          side left
    312 SR          side right
    313 TC          top center
    314 TFL         top front left
    315 TFC         top front center
    316 TFR         top front right
    317 TBL         top back left
    318 TBC         top back center
    319 TBR         top back right
    320 DL          downmix left
    321 DR          downmix right
    322 WL          wide left
    323 WR          wide right
    324 SDL         surround direct left
    325 SDR         surround direct right
    326 LFE2        low frequency 2
     336NAME           DESCRIPTION
     337FL             front left
     338FR             front right
     339FC             front center
     340LFE            low frequency
     341BL             back left
     342BR             back right
     343FLC            front left-of-center
     344FRC            front right-of-center
     345BC             back center
     346SL             side left
     347SR             side right
     348TC             top center
     349TFL            top front left
     350TFC            top front center
     351TFR            top front right
     352TBL            top back left
     353TBC            top back center
     354TBR            top back right
     355DL             downmix left
     356DR             downmix right
     357WL             wide left
     358WR             wide right
     359SDL            surround direct left
     360SDR            surround direct right
     361LFE2           low frequency 2
    327362
    328363Standard channel layouts:
     
    357392downmix        DL+DR
    358393}}}
    359 
    360 == Multiple channel layouts. ==
    361 I had to do 5.1+2.0 in a single WAV file.  If you use 2 channel layouts in a Pan filter to do that, it looks like this =
    362 {{{
    363 pan=5.1+downmix|FL=c0|FR=c1|FC=c2|LFE=c3|BL=c4|BR=c5|DL=c6|DR=c7.
    364 }}}
    365 That way, 8 channels in 1 WAV file has all the channels you need.