GetChannel

From Avisynth wiki
Revision as of 17:27, 8 November 2015 by Raffriff42 (Talk | contribs)

Jump to: navigation, search

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.

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 stereo 2.0 WAV and 5.1 WAV files the ordering should be as follows:

WAV, 2 channels (stereo):

1 left channel
2 right channel

WAV, 5.1 channels:

1 front left channel
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)
# Using v2.5 this becomes:
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 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:

Reference: 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