Changes between Version 26 and Version 27 of AudioChannelManipulation


Ignore:
Timestamp:
Nov 28, 2017, 3:52:25 AM (18 months ago)
Author:
llogan
Comment:

added another "stereo → mono stream" situation. embiggened titles. updated note style.

Legend:

Unmodified
Added
Removed
Modified
  • AudioChannelManipulation

    v26 v27  
    1 = Manipulating audio channels with `ffmpeg` =
    2 
    3 [[PageOutline(2, Contents)]]
    4 
    5 == stereo → mono stream ==
     1{{{
     2#!html
     3<h1 style="font-size: 22px;">
     4Manipulating audio channels
     5</h1>
     6}}}
     7
     8[[PageOutline(1, Contents)]]
     9
     10= stereo → mono stream =
     11
     12== Downmix both channels ==
    613
    714[[Image(stereo_mono.png, nolink)]]
     
    1320}}}
    1421
    15 Note: Any out of phase stereo will cancel out.
    16 
    17 == stereo → 2 × mono files ==
     22{{{
     23#!div style="border: 1px solid #e5c7c7; margin: 1em; background-color: #fdd;"
     24'''Warning:''' Any out of phase stereo will cancel out.
     25}}}
     26
     27== Choose a specific channel ==
     28
     29[[Image(stereo_mono_exclude.png, nolink)]]
     30
     31This example uses the [https://ffmpeg.org/ffmpeg-filters.html#pan pan] audio filter to include only the right channel:
     32
     33{{{
     34ffmpeg -i stereo.wav -af "pan=mono|c0=c1" mono.m4a
     35}}}
     36
     37If you only want the left channel use `c0=c0` instead.
     38
     39= stereo → 2 × mono files =
    1840
    1941[[Image(stereo_2mono_outputs.png, nolink)]]
     
    2850
    2951{{{
    30 ffmpeg -i stereo.wav -filter_complex "[0:0]pan=1c|c0=c0[left];[0:0]pan=1c|c0=c1[right]" -map "[left]" left.wav -map "[right]" right.wav
    31 }}}
    32 
    33 == stereo → 2 × mono streams ==
     52ffmpeg -i stereo.wav -filter_complex "[0:a]pan=1c|c0=c0[left];[0:0]pan=1c|c0=c1[right]" -map "[left]" left.wav -map "[right]" right.wav
     53}}}
     54
     55= stereo → 2 × mono streams =
    3456
    3557[[Image(stereo_2mono_streams.png, nolink)]]
     
    4264
    4365{{{
    44 #!div style="border: 1pt dotted; margin: 1em; background-color: #ffffdd;"
     66#!div style="border: 1px solid #e5e5c7; margin: 1em; background-color: #ffd;"
    4567'''Note:''' Your player will likely play the first stream by default unless your player allows you to select the desired stream.
    4668}}}
    4769
    48 == mono → stereo ==
     70= mono → stereo =
    4971
    5072[[Image(mono_stereo.png, nolink)]]
     
    6385
    6486{{{
    65 #!div style="border: 1pt dotted; margin: 1em; background-color: #ffffdd;"
     87#!div style="border: 1px solid #e5e5c7; margin: 1em; background-color: #ffd;"
    6688'''Note:''' These examples will not magically create a "true" stereo output from the mono input, but simply place the same audio into both the left and right channels of the output (both channels will be identical).
    6789}}}
    6890
    69 == 2 × mono → stereo ==
     91= 2 × mono → stereo =
    7092
    7193[[Image(2mono_stereo.png, nolink)]]
     
    7799}}}
    78100
    79 == 6 × mono → 5.1 ==
     101= 6 × mono → 5.1 =
    80102
    81103[[Image(6mono_5point1.png, nolink)]]
     
    90112All inputs must have the same sample rate and format. If inputs do not have the same duration the output will stop with the shortest.
    91113
    92 == 5.1 → 6 × mono
     114= 5.1 → 6 × mono =
    93115
    94116[[Image(5point1_6mono.png, nolink)]]
     
    108130
    109131
    110 == 5.1 → stereo ==
     132= 5.1 → stereo =
    111133
    112134[[Image(5point1_stereo.png, nolink)]]
     
    119141
    120142{{{
    121 #!div style="border: 1pt dotted; margin: 1em; background-color: #ffffdd;"
     143#!div style="border: 1px solid #e5e5c7; margin: 1em; background-color: #ffd;"
    122144'''Notes:'''
    123145* By default when using `-ac 2` the LFE channel is omitted. See "[http://atsc.org/wp-content/uploads/2015/03/A52-201212-17.pdf Digital Audio Compression Standard (Document A/52:2012)]", sections 6.1.12 and 7.8 for more downmixing info.
     
    139161If the `=` in a channel specification is replaced by `<`, then the gains for that specification will be renormalized so that the total is 1, thus avoiding clipping noise. See the [https://ffmpeg.org/ffmpeg-filters.html#pan pan audio filter documentation] for additional information and examples.
    140162
    141 == 2 × stereo → stereo ==
     163= 2 × stereo → stereo =
    142164
    143165[[Image(2stereo_stereo.png, nolink)]]
     
    156178
    157179{{{
    158 #!div style="border: 1pt dotted; margin: 1em; background-color: #ffffdd;"
     180#!div style="border: 1px solid #e5e5c7; margin: 1em; background-color: #ffd;"
    159181'''Note:''' The output produced with the pan audio filter may not be identical to the output produced with `-ac 2`, so you'll have to listen to your outputs or view [#Statistics audio statistics] to determine which output suits you.
    160182}}}
     
    171193The pan audio filter has to be used in this situation instead of `-ac 2` unlike the previous example.
    172194
    173 == Mix both stereo channels to stereo ==
     195= Mix both stereo channels to stereo =
    174196
    175197[[Image(stereo_stereo_mix.png, nolink)]]
     
    181203}}}
    182204
    183 == Switch stereo channels ==
     205= Switch stereo channels =
    184206
    185207[[Image(switch_stereo_channels.png, nolink)]]
     
    197219}}}
    198220
    199 == Virtual Binaural Acoustics ==
     221= Virtual Binaural Acoustics =
    200222
    201223FFmpeg can produce virtual binaural acoustics files using sofalizer filter,
     
    210232----
    211233
    212 == Mute a channel ==
     234= Mute a channel =
    213235
    214236[[Image(mute_stereo_channel.png, nolink)]]
     
    222244----
    223245
    224 == Statistics ==
     246= Statistics =
    225247
    226248The [https://ffmpeg.org/ffmpeg-filters.html#astats astats audio filter] can display information including length, DC offset, min/max levels, peak/RMS level dB:
     
    266288----
    267289
    268 == Layouts ==
     290= Layouts =
    269291
    270292Output from `ffmpeg -layouts`: