GetChannel

From Avisynth wiki
(Difference between revisions)
Jump to: navigation, search
m (added category)
(formatting, links, phrasing)
Line 1: Line 1:
{{Template:Func3Def|GetChannel(clip ''clip'', int ''ch1'' [, int ''ch2'', ...])|GetLeftChannel(clip ''clip'')|GetRightChannel(clip ''clip'')}}
+
<div style="max-width:68em" >
 +
{{Func3Def
 +
|GetChannel(clip ''clip'', int ''ch1'' [, int ''ch2'', ...] )
 +
|GetLeftChannel(clip ''clip'')
 +
|GetRightChannel(clip ''clip'')
 +
}}
  
GetChannel is present starting from v2.5 and it returns one or more channels of a multichannel signal. Prior to v2.5 GetLeftChannel returns the left and GetRightChannel the right channel from a stereo signal. GetChannels is an alias to GetChannel and they can be used interchangeably.  
+
*'''GetChannel''' returns one or more channels of a multichannel signal.  
 +
*'''GetLeftChannel''' returns the left and '''GetRightChannel''' the right channel from a stereo signal.  
 +
*'''GetChannels''' is an alias to '''GetChannel''' and can be used interchangeably.  
  
The ordering of the channels is determined by the ordering of the input file, because AviSynth doesn't assume any ordering (see [[GetChannel#Remarks|Remarks]]). In case of stereo 2.0 WAV and 5.1 WAV files the ordering should be as follows:
 
  
'''WAV, 2 channels (stereo):'''
+
The ordering of the channels is determined by the ordering of the input file, because AviSynth doesn't assume any ordering (see [[GetChannel#Remarks|Remarks]]).
{| border=1 cellspacing=1 cellpadding=4
+
 
 +
In case of WAV files, the ordering should be as follows:
 +
:{|class="wikitable" style="width:27em"
 +
|-
 +
! colspan="2" style="text-align:left" |&nbsp; WAV, 2 channels (stereo)&nbsp;
 +
|-
 
| 1 || left channel
 
| 1 || left channel
 
|-
 
|-
Line 12: Line 23:
 
|}
 
|}
  
'''WAV, 5.1 channels:'''
+
:{|class="wikitable" style="width:27em"
{|border=1 cellspacing=1 cellpadding=4
+
|-
| 1 || front left channel
+
! colspan="2" style="text-align:left" |&nbsp; WAV, 5.1 channels&nbsp;
 +
|-| 1 || front left channel
 
|-
 
|-
 
| 2 || front right channel   
 
| 2 || front right channel   
Line 26: Line 38:
 
| 6 || rear right channel
 
| 6 || rear right channel
 
|}
 
|}
 +
</div>
  
 
+
==== Examples ====
===Examples===
+
* Removes right channel information, and return as mono clip with only left channel:
 
+
<div {{BoxWidthIndent|36|2}} >
<code>
+
# Removes right channel information, and return as mono clip with only left channel:
+
 
  video = [[AviSource]]("c:\filename.avi")
 
  video = [[AviSource]]("c:\filename.avi")
  stereo = WavSource("c:\afx-ab3_t4.wav")
+
  stereo = [[WavSource]]("c:\afx-ab3_t4.wav")
 
  mono = GetLeftChannel(stereo)
 
  mono = GetLeftChannel(stereo)
 
  return [[AudioDub]](video, mono)
 
  return [[AudioDub]](video, mono)
 +
</div>
  
# Using v2.5 this becomes:
+
* Do the same, alternate syntax:
 +
<div {{BoxWidthIndent|36|2}} >
 
  video = AviSource("c:\filename.avi")
 
  video = AviSource("c:\filename.avi")
  stereo = [[WavSource]]("c:\afx-ab3_t4.wav")
+
  stereo = WavSource("c:\afx-ab3_t4.wav")
 
  mono = GetChannel(stereo, 1)
 
  mono = GetChannel(stereo, 1)
 
  return AudioDub(video, mono)
 
  return AudioDub(video, mono)
 +
</div>
  
# You could also obtain the channels from the avi file itself:
+
* You could also obtain the channels from the AVI file itself:
 +
<div {{BoxWidthIndent|36|2}} >
 
  video = AviSource("c:\filename.avi")
 
  video = AviSource("c:\filename.avi")
 
  return GetChannel(video, 1)
 
  return GetChannel(video, 1)
 +
</div>
  
# Converts avi with 5.1 audio to a stereo signal:
+
* Converts AVI with 5.1 audio to a stereo signal
# (But see below for channel ordering, and [http://forum.doom9.org/showthread.php?p=1243880#post1243880 here] for more complex downmix functions.)
+
<div {{ListItemContinue}} >
 +
(But see below for channel ordering, and [http://forum.doom9.org/showthread.php?p=1243880#post1243880 here] for more complex downmix functions.)
 +
</div>
 +
<div {{BoxWidthIndent|36|2}} >
 
  video = AviSource("c:\divx_51.avi")
 
  video = AviSource("c:\divx_51.avi")
 
  stereo = GetChannel(video, 1, 2)
 
  stereo = GetChannel(video, 1, 2)
 
  return AudioDub(video, stereo)
 
  return AudioDub(video, stereo)
 +
</div>
  
# Converts avi with "uncompressed 5.1 wav" audio to a stereo signal:
+
* Converts AVI with "uncompressed 5.1 wav" audio to a stereo signal:
 +
<div {{BoxWidthIndent|36|2}} >
 
  video = AviSource("c:\divx_wav.avi")
 
  video = AviSource("c:\divx_wav.avi")
 
  audio = WavSource("c:\divx_wav.avi")
 
  audio = WavSource("c:\divx_wav.avi")
 
  stereo = GetChannel(audio, 1, 2)
 
  stereo = GetChannel(audio, 1, 2)
 
  return AudioDub(video, stereo)
 
  return AudioDub(video, stereo)
</code>
+
</div>
  
===Remarks===
+
==== Remarks ====
 +
<div style="max-width:68em" >
 +
Every file format has a different internal channel ordering. The following table gives this internal ordering for some formats (useful for plugin writers), but it is the decoder's task to return the expected (WAV) channel order. If you use decoders like [[NicAudio]]/BassAudio or [[Ffdshow|ffdshow]]/AC3_filter you don't need to worry about this.
 +
</div>
  
Every file format has a different internal channel ordering. The following table gives this internal ordering for some formats (useful for plugin writers), but it is a decoder task supply to AviSynth the expected channel order (like WAV), if you use decoders like NicAudio/BassAudio or ffdshow/AC3_filter you don't need to worry about this:
+
:{|class="wikitable"
 
+
! Format !! Channel 1 !! Channel 2 !! Channel 3 !! Channel 4 !! Channel 5 !! Channel 6  
{|border=1 cellspacing=1 cellpadding=4
+
! Reference: !! Channel 1 !! Channel 2 !! Channel 3 !! Channel 4 !! Channel 5 !! Channel 6  
+
 
|-
 
|-
| [http://www.cs.bath.ac.uk/~jpff/NOS-DREAM/researchdev/wave-ex/wave_ex.html 5.1 WAV]  
+
| [http://www.cs.bath.ac.uk/~jpff/NOS-DREAM/researchdev/wave-ex/wave_ex.html 5.1 WAV]
 
| front left channel  
 
| front left channel  
 
| front right channel  
 
| front right channel  
| front center channel  
+
| front center channel&nbsp;
 
| LFE  
 
| LFE  
 
| rear left channel  
 
| rear left channel  
Line 77: Line 99:
 
| [https://web.archive.org/web/20051108165008/http://www.atsc.org/standards/a_52a.pdf 5.1 AC3]  
 
| [https://web.archive.org/web/20051108165008/http://www.atsc.org/standards/a_52a.pdf 5.1 AC3]  
 
| front left channel  
 
| front left channel  
| front center channel  
+
| front center channel&nbsp;
 
| front right channel  
 
| front right channel  
 
| rear left channel  
 
| rear left channel  
| rear right channel  
+
| rear right channel&nbsp;
 
| LFE  
 
| LFE  
 
|-
 
|-
 
| [http://www.etsi.org/deliver/etsi_ts/102100_102199/102114/01.01.01_60/ts_102114v010101p.pdf 5.1 DTS]  
 
| [http://www.etsi.org/deliver/etsi_ts/102100_102199/102114/01.01.01_60/ts_102114v010101p.pdf 5.1 DTS]  
| front center channel  
+
| front center channel&nbsp;
 
| front left channel  
 
| front left channel  
 
| front right channel  
 
| front right channel  
Line 92: Line 114:
 
|-
 
|-
 
| [http://web.archive.org/web/20070830151620/http://www.hydrogenaudio.org/forums/index.php?showtopic=10986 5.1 AAC]  
 
| [http://web.archive.org/web/20070830151620/http://www.hydrogenaudio.org/forums/index.php?showtopic=10986 5.1 AAC]  
| front center channel  
+
| front center channel&nbsp;
 
| front left channel  
 
| front left channel  
 
| front right channel  
 
| front right channel  
Line 102: Line 124:
 
| front left channel  
 
| front left channel  
 
| rear left channel  
 
| rear left channel  
| front center channel  
+
| front center channel&nbsp;
| front right channel  
+
| front right channel&nbsp;
 
| rear right channel  
 
| rear right channel  
 
| LFE
 
| LFE
Line 110: Line 132:
 
| front left channel
 
| front left channel
 
| front right channel
 
| front right channel
| front center channel
+
| front center channel&nbsp;
 
| LFE
 
| LFE
 
| rear left channel
 
| rear left channel
| rear right channel
+
| rear right channel&nbsp;
 
|-
 
|-
| [http://lists.mplayerhq.hu/pipermail/mplayer-users/2006-October/063511.html 5.1 WMA]
+
| [http://lists.mplayerhq.hu/pipermail/mplayer-users/2006-October/063511.html 5.1 WMA] &nbsp;
 
| front left channel
 
| front left channel
 
| front right channel
 
| front right channel
| front center channel
+
| front center channel&nbsp;
 
| LFE
 
| LFE
 
| rear left channel
 
| rear left channel
| rear right channel
+
| rear right channel&nbsp;
 
|}
 
|}
  

Revision as of 02:59, 15 February 2016

GetChannel(clip clip, int ch1 [, int ch2, ...] )
GetLeftChannel(clip clip)
GetRightChannel(clip clip)

  • GetChannel returns one or more channels of a multichannel signal.
  • GetLeftChannel returns the left and GetRightChannel the right channel from a stereo signal.
  • GetChannels is an alias to GetChannel and can be used interchangeably.


The ordering of the channels is determined by the ordering of the input file, because AviSynth doesn't assume any ordering (see Remarks).

In case of WAV files, the ordering should be as follows:

  WAV, 2 channels (stereo) 
1 left channel
2 right channel
  WAV, 5.1 channels 
2 front right channel
3 front center channel
4 LFE (Low Frequency Enhancement; Subwoofer)
5 rear left channel
6 rear right channel

Examples

  • Removes right channel information, and return as mono clip with only left channel:
video = AviSource("c:\filename.avi")
stereo = WavSource("c:\afx-ab3_t4.wav")
mono = GetLeftChannel(stereo)
return AudioDub(video, mono)
  • Do the same, alternate syntax:
video = AviSource("c:\filename.avi")
stereo = WavSource("c:\afx-ab3_t4.wav")
mono = GetChannel(stereo, 1)
return AudioDub(video, mono)
  • You could also obtain the channels from the AVI file itself:
video = AviSource("c:\filename.avi")
return GetChannel(video, 1)
  • Converts AVI with 5.1 audio to a stereo signal

(But see below for channel ordering, and here for more complex downmix functions.)

video = AviSource("c:\divx_51.avi")
stereo = GetChannel(video, 1, 2)
return AudioDub(video, stereo)
  • Converts AVI with "uncompressed 5.1 wav" audio to a stereo signal:
video = AviSource("c:\divx_wav.avi")
audio = WavSource("c:\divx_wav.avi")
stereo = GetChannel(audio, 1, 2)
return AudioDub(video, stereo)

Remarks

Every file format has a different internal channel ordering. The following table gives this internal ordering for some formats (useful for plugin writers), but it is the decoder's task to return the expected (WAV) channel order. If you use decoders like NicAudio/BassAudio or ffdshow/AC3_filter you don't need to worry about this.

Format Channel 1 Channel 2 Channel 3 Channel 4 Channel 5 Channel 6
5.1 WAV front left channel front right channel front center channel  LFE rear left channel rear right channel
5.1 AC3 front left channel front center channel  front right channel rear left channel rear right channel  LFE
5.1 DTS front center channel  front left channel front right channel rear left channel rear right channel LFE
5.1 AAC front center channel  front left channel front right channel rear left channel rear right channel LFE
5.1 AIFF front left channel rear left channel front center channel  front right channel  rear right channel LFE
5.1 FLAC front left channel front right channel front center channel  LFE rear left channel rear right channel 
5.1 WMA   front left channel front right channel front center channel  LFE rear left channel rear right channel 
  • 5.1 DTS: the LFE is on a separate stream (much like on multichannel MPEG2).
  • A free version of the AAC specifications are unavailable online.
Personal tools