Clip properties

From Avisynth wiki
(Difference between revisions)
Jump to: navigation, search
(add AVS+ information)
(rearrange subcat's; IsRGB, IsYUV, IsPlanarRGB(A) notes)
Line 1: Line 1:
 
<div style="max-width:62em" >
 
<div style="max-width:62em" >
You can access a variety of clip properties in AviSynth scripts. For example, if the variable ''clip'' holds a video clip, then ''clip.height'' is its height in pixels, ''clip.framecount'' is its length in frames, and so on. Clip properties can be manipulated just like [[Script_variables|script variables]], except that they are read-only (in [[wikipedia:C_(programming_language)|'''C''']] terminology, they cannot be ''L-values'').
+
You can access a variety of clip properties in AviSynth scripts. For example, if the variable ''clip'' holds a video clip, then ''clip''.{{FuncArg|Height}} is its height in pixels, ''clip''.{{FuncArg|FrameCount}} is its length in frames, and so on.  
 +
 
 +
Clip properties can be accessed like [[Script_variables|script variables]], except that they are read-only (in [[wikipedia:C_(programming_language)|'''C''']] terminology, they cannot be ''L-values'').
 +
 
 +
__TOC__
  
 
The full list of properties:
 
The full list of properties:
  
==== Resolution ====
+
==== Content Properties ====
 +
* ''bool'' clip.{{Term|HasAudio}}
 +
: Returns true if the clip has audio, false otherwise.
 +
* ''bool'' clip.{{Term|HasVideo}}
 +
: Returns true if the clip has video, false otherwise.
 +
 
 +
==== Video: Resolution ====
 
* ''int'' clip.{{Term|Width}}
 
* ''int'' clip.{{Term|Width}}
 
: Returns the width of the clip in pixels.
 
: Returns the width of the clip in pixels.
Line 10: Line 20:
 
: Returns the height of the clip in pixels.
 
: Returns the height of the clip in pixels.
  
==== Framerate and Duration ====
+
==== Video: Framerate and Duration ====
 
* ''int'' clip.{{Term|FrameCount}}
 
* ''int'' clip.{{Term|FrameCount}}
 
: Returns the total number of video frames contained in the clip.  
 
: Returns the total number of video frames contained in the clip.  
Line 21: Line 31:
 
: Returns the framerate denominator.
 
: Returns the framerate denominator.
  
==== Audio ====
+
==== Video: Interlacing ====
* ''int'' clip.{{Term|AudioRate}}
+
* ''bool'' clip.{{Term|IsFieldBased}}
: Returns the audio sample rate.
+
: Returns true if the clip is ''field-based''. What this means is explained [[Interlaced_fieldbased|'''here''']].
* ''int'' clip.{{Term|AudioLength}}
+
* ''bool'' clip.{{Term|IsFrameBased}}
: Returns the total number of audio samples, per audio channel.
+
: Returns true if the clip is ''frame-based''. What this means is explained [[Interlaced_fieldbased|'''here''']].
: Be aware of possible overflow on extremely long clips (with >= 2<sup>31</sup> audio samples) &ndash; see [[#Examples|Examples]] below.
+
* ''bool'' clip.{{Term|GetParity([ int ''f'' ])}}
* ''int'' clip.{{Term|AudioLengthLo([ int ''m'' ])}}  (from v2.60)
+
: Returns true if frame {{Term|''f''}} (default 0) is the top field of a field-based clip, or if it is a full frame with top field first of a frame-based clip.
* ''int'' clip.{{Term|AudioLengthHi([ int ''d'' ])}} (from v2.60)
+
: clip.{{Term|AudioLengthLo}} returns the total number of audio samples, modulo {{Term|''m''}}, which is 10<sup>9</sup> by default.
+
: clip.{{Term|AudioLengthHi}} returns the total number of audio samples, divided by {{Term|''d''}}, which is 10<sup>9</sup> by default.
+
: Therefore, assuming {{Term|''m''}}=={{Term|''d''}}, the (possibly 64-bit) total equals {{Term|AudioLengthHi}} × {{Term|''m''}} + {{Term|AudioLengthLo}}.
+
: (see [[#Examples|Examples]] below)
+
* ''float'' clip.{{Term|AudioLengthF}}
+
: Returns the total number of audio samples as a float-point number.
+
: No overflow limit, but there is a possible ''precision'' limit &ndash; see [[#Examples|Examples]] below.
+
* ''string'' clip.{{Term|AudioLengthS}} (from v2.60)
+
: Returns the total number of audio samples as a string.
+
* ''float'' clip.{{Term|AudioDuration}} (from v2.60)
+
: Returns the audio duration in seconds.
+
* ''int'' clip.{{Term|AudioChannels}}
+
: Returns the number of audio channels.
+
* ''int'' clip.{{Term|AudioBits}}
+
: Returns the audio bit depth, ''eg'', 8, 16, 24 or 32.
+
* ''bool'' clip.{{Term|IsAudioFloat}}
+
: Returns true if the audio format is [[Float]].
+
* ''bool'' clip.{{Term|IsAudioInt}}
+
: Returns true if the audio format is an integer type.
+
  
==== Color Format ====
+
==== Video: Color Format ====
 +
* ''bool'' clip.{{Term|IsPlanar}}
 +
: Returns true if the color format is [[Planar]], false otherwise.
 +
* ''bool'' clip.{{Term|IsInterleaved}}
 +
: Returns true if the color format is [[Interleaved]], false otherwise.
 
* ''bool'' clip.{{Term|IsRGB}}
 
* ''bool'' clip.{{Term|IsRGB}}
 
: Returns true if the color format is [[RGB]], false otherwise.
 
: Returns true if the color format is [[RGB]], false otherwise.
 +
: (applies to all RGB clips, whether Planar or Interleaved, RGB or RGBA)
 
* ''bool'' clip.{{Term|IsRGB24}}
 
* ''bool'' clip.{{Term|IsRGB24}}
 
: Returns true if the color format is [[RGB24]], false otherwise.
 
: Returns true if the color format is [[RGB24]], false otherwise.
Line 58: Line 53:
 
* ''bool'' clip.{{Term|IsYUV}}
 
* ''bool'' clip.{{Term|IsYUV}}
 
: Returns true if the color format is [[YUV]], false otherwise.
 
: Returns true if the color format is [[YUV]], false otherwise.
 +
: (note that {{Term|IsYUV}} returns ''false'' for a YUVA clip, and vice versa)
 
* ''bool'' clip.{{Term|IsYUY2}} (clip)
 
* ''bool'' clip.{{Term|IsYUY2}} (clip)
 
: Returns true if the color format is [[YUY2]], false otherwise.
 
: Returns true if the color format is [[YUY2]], false otherwise.
Line 78: Line 74:
 
* ''bool'' clip.{{Term|IsY}}
 
* ''bool'' clip.{{Term|IsY}}
 
: {{AvsPluscon}} Returns true if the color format is ''Y''-plane only, false otherwise.
 
: {{AvsPluscon}} Returns true if the color format is ''Y''-plane only, false otherwise.
 
 
* ''bool'' clip.{{Term|IsYUVA}}
 
* ''bool'' clip.{{Term|IsYUVA}}
 
: {{AvsPluscon}} Returns true if the color format is any [[Avisynthplus_color_formats|YUVA]], false otherwise.
 
: {{AvsPluscon}} Returns true if the color format is any [[Avisynthplus_color_formats|YUVA]], false otherwise.
Line 87: Line 82:
  
 
* ''bool'' clip.{{Term|IsPackedRGB}}
 
* ''bool'' clip.{{Term|IsPackedRGB}}
: {{AvsPluscon}} Returns true if the color format is RGB24 or RGB32, false otherwise.
+
: {{AvsPluscon}} Returns true if the color format is [[Interleaved]] RGB (RGB24/32/48/64), false otherwise.
 
* ''bool'' clip.{{Term|IsPlanarRGB}}
 
* ''bool'' clip.{{Term|IsPlanarRGB}}
: {{AvsPluscon}} Returns true if the color format is [[Avisynthplus_color_formats|RGB48]], false otherwise.
+
: {{AvsPluscon}} Returns true if the color format is [[Planar]] RGB, false otherwise.
 +
: (note that {{Term|IsPlanarRGB}} returns ''false'' for a Planar RGBA clip, and vice versa)
 
* ''bool'' clip.{{Term|IsPlanarRGBA}}
 
* ''bool'' clip.{{Term|IsPlanarRGBA}}
: {{AvsPluscon}} Returns true if the color format is [[Avisynthplus_color_formats|RGB64]], false otherwise.
+
: {{AvsPluscon}} Returns true if the color format is [[Planar]] RGBA, false otherwise.
 
* ''bool'' clip.{{Term|HasAlpha}}
 
* ''bool'' clip.{{Term|HasAlpha}}
 
: {{AvsPluscon}} Returns true if the color format has an alpha channe; (RGBA or YUVA), false otherwise.
 
: {{AvsPluscon}} Returns true if the color format has an alpha channe; (RGBA or YUVA), false otherwise.
Line 105: Line 101:
 
: Returns the pixel type as a string, ''eg'' "RGB32".
 
: Returns the pixel type as a string, ''eg'' "RGB32".
  
==== Other Properties ====
+
==== Audio ====
* ''bool'' clip.{{Term|IsFieldBased}}
+
* ''int'' clip.{{Term|AudioRate}}
: Returns true if the clip is ''field-based''. What this means is explained [[Interlaced_fieldbased|'''here''']].
+
: Returns the audio sample rate.
* ''bool'' clip.{{Term|IsFrameBased}}
+
* ''int'' clip.{{Term|AudioLength}}
: Returns true if the clip is ''frame-based''. What this means is explained [[Interlaced_fieldbased|'''here''']].
+
: Returns the total number of audio samples, per audio channel.
* ''bool'' clip.{{Term|IsPlanar}}
+
: Be aware of possible overflow on extremely long clips (with >= 2<sup>31</sup> audio samples) &ndash; see [[#Examples|Examples]] below.
: Returns true if the color format is [[Planar]], false otherwise.
+
* ''int'' clip.{{Term|AudioLengthLo([ int ''m'' ])}}  (from v2.60)
* ''bool'' clip.{{Term|IsInterleaved}}
+
* ''int'' clip.{{Term|AudioLengthHi([ int ''d'' ])}} (from v2.60)
: Returns true if the color format is [[Interleaved]], false otherwise.
+
: clip.{{Term|AudioLengthLo}} returns the total number of audio samples, modulo {{Term|''m''}}, which is 10<sup>9</sup> by default.
* ''bool'' clip.{{Term|GetParity([ int ''f'' ])}}
+
: clip.{{Term|AudioLengthHi}} returns the total number of audio samples, divided by {{Term|''d''}}, which is 10<sup>9</sup> by default.
: Returns true if frame {{Term|''f''}} (default 0) is the top field of a field-based clip, or if it is a full frame with top field first of a frame-based clip.
+
: Therefore, assuming {{Term|''m''}}=={{Term|''d''}}, the (possibly 64-bit) total equals {{Term|AudioLengthHi}} × {{Term|''m''}} + {{Term|AudioLengthLo}}.
* ''bool'' clip.{{Term|HasAudio}}
+
: (see [[#Examples|Examples]] below)
: Returns true if the clip has audio, false otherwise.
+
* ''float'' clip.{{Term|AudioLengthF}}
* ''bool'' clip.{{Term|HasVideo}}
+
: Returns the total number of audio samples as a float-point number.
: Returns true if the clip has video, false otherwise.
+
: No overflow limit, but there is a possible ''precision'' limit &ndash; see [[#Examples|Examples]] below.
 +
* ''string'' clip.{{Term|AudioLengthS}} (from v2.60)
 +
: Returns the total number of audio samples as a string.
 +
* ''float'' clip.{{Term|AudioDuration}} (from v2.60)
 +
: Returns the audio duration in seconds.
 +
* ''int'' clip.{{Term|AudioChannels}}
 +
: Returns the number of audio channels.
 +
* ''int'' clip.{{Term|AudioBits}}
 +
: Returns the audio bit depth, ''eg'', 8, 16, 24 or 32.
 +
* ''bool'' clip.{{Term|IsAudioFloat}}
 +
: Returns true if the audio format is [[Float]].
 +
* ''bool'' clip.{{Term|IsAudioInt}}
 +
: Returns true if the audio format is an integer type.
  
  

Revision as of 01:24, 27 October 2017

You can access a variety of clip properties in AviSynth scripts. For example, if the variable clip holds a video clip, then clip.Height is its height in pixels, clip.FrameCount is its length in frames, and so on.

Clip properties can be accessed like script variables, except that they are read-only (in C terminology, they cannot be L-values).

Contents


The full list of properties:

Content Properties

  • bool clip.HasAudio
Returns true if the clip has audio, false otherwise.
  • bool clip.HasVideo
Returns true if the clip has video, false otherwise.

Video: Resolution

  • int clip.Width
Returns the width of the clip in pixels.
  • int clip.Height
Returns the height of the clip in pixels.

Video: Framerate and Duration

  • int clip.FrameCount
Returns the total number of video frames contained in the clip.
  • float clip.FrameRate
Returns approximate framerate. Video framerate is actually a ratio of two 32-bit integers;
so for the precise number, use FrameRateNumerator and FrameRateDenominator.
  • int clip.FrameRateNumerator
Returns the framerate numerator.
  • int clip.FrameRateDenominator
Returns the framerate denominator.

Video: Interlacing

  • bool clip.IsFieldBased
Returns true if the clip is field-based. What this means is explained here.
  • bool clip.IsFrameBased
Returns true if the clip is frame-based. What this means is explained here.
  • bool clip.GetParity([ int f ])
Returns true if frame f (default 0) is the top field of a field-based clip, or if it is a full frame with top field first of a frame-based clip.

Video: Color Format

  • bool clip.IsPlanar
Returns true if the color format is Planar, false otherwise.
  • bool clip.IsInterleaved
Returns true if the color format is Interleaved, false otherwise.
  • bool clip.IsRGB
Returns true if the color format is RGB, false otherwise.
(applies to all RGB clips, whether Planar or Interleaved, RGB or RGBA)
  • bool clip.IsRGB24
Returns true if the color format is RGB24, false otherwise.
  • bool clip.IsRGB32
Returns true if the color format is RGB32, false otherwise.
  • bool clip.IsYUV
Returns true if the color format is YUV, false otherwise.
(note that IsYUV returns false for a YUVA clip, and vice versa)
  • bool clip.IsYUY2 (clip)
Returns true if the color format is YUY2, false otherwise.
  • bool clip.IsY8 (from v2.60)
Returns true if the color format is Y8, false otherwise.
  • bool clip.IsYV12
Returns true if the color format is YV12, false otherwise.
  • bool clip.IsYV16 (from v2.60)
Returns true if the clip color format is YV16, false otherwise.
  • bool clip.IsYV24 (v2.60)
Returns true if the color format is YV24, false otherwise.
  • bool clip.IsYV411 (from v2.60)
Returns true if the color format is YV411, false otherwise.
  • bool clip.Is420
AVS+ Returns true if the color format is 4:2:0, false otherwise.
  • bool clip.Is422
AVS+ Returns true if the color format is 4:2:2, false otherwise.
  • bool clip.Is444
AVS+ Returns true if the color format is 4:2:4, false otherwise.
  • bool clip.IsY
AVS+ Returns true if the color format is Y-plane only, false otherwise.
  • bool clip.IsYUVA
AVS+ Returns true if the color format is any YUVA, false otherwise.
  • bool clip.IsRGB48
AVS+ Returns true if the color format is 16-bit RGB (RGB48), false otherwise.
  • bool clip.IsRGB64
AVS+ Returns true if the color format is 16-bit RBGA (RGB64), false otherwise.
  • bool clip.IsPackedRGB
AVS+ Returns true if the color format is Interleaved RGB (RGB24/32/48/64), false otherwise.
  • bool clip.IsPlanarRGB
AVS+ Returns true if the color format is Planar RGB, false otherwise.
(note that IsPlanarRGB returns false for a Planar RGBA clip, and vice versa)
  • bool clip.IsPlanarRGBA
AVS+ Returns true if the color format is Planar RGBA, false otherwise.
  • bool clip.HasAlpha
AVS+ Returns true if the color format has an alpha channe; (RGBA or YUVA), false otherwise.
  • int clip.ComponentSize
AVS+ Returns 1 for 8-bit formats, 2 for 10/12/14/16-bit formats, 4 for 32-bit float.
  • int clip.NumComponents
AVS+ Returns 1 for Y-only formats, 3 for RGB and YUV, 4 for RGBA and YUVA.
  • int clip.BitsPerComponent
AVS+ Returns bit depth per channel – 8, 10, 12, 14, 16 or 32.
  • string clip.PixelType (from v2.60)
Returns the pixel type as a string, eg "RGB32".

Audio

  • int clip.AudioRate
Returns the audio sample rate.
  • int clip.AudioLength
Returns the total number of audio samples, per audio channel.
Be aware of possible overflow on extremely long clips (with >= 231 audio samples) – see Examples below.
  • int clip.AudioLengthLo([ int m ]) (from v2.60)
  • int clip.AudioLengthHi([ int d ]) (from v2.60)
clip.AudioLengthLo returns the total number of audio samples, modulo m, which is 109 by default.
clip.AudioLengthHi returns the total number of audio samples, divided by d, which is 109 by default.
Therefore, assuming m==d, the (possibly 64-bit) total equals AudioLengthHi × m + AudioLengthLo.
(see Examples below)
  • float clip.AudioLengthF
Returns the total number of audio samples as a float-point number.
No overflow limit, but there is a possible precision limit – see Examples below.
  • string clip.AudioLengthS (from v2.60)
Returns the total number of audio samples as a string.
  • float clip.AudioDuration (from v2.60)
Returns the audio duration in seconds.
  • int clip.AudioChannels
Returns the number of audio channels.
  • int clip.AudioBits
Returns the audio bit depth, eg, 8, 16, 24 or 32.
  • bool clip.IsAudioFloat
Returns true if the audio format is Float.
  • bool clip.IsAudioInt
Returns true if the audio format is an integer type.


Examples

  • Clip duration = 10 seconds. All AudioLength forms agree.
ColorBars(width=440, height=440)
Trim(0, 299)
Info
Levels(0, 1.0, 255, 64, 255-64, coring=false)
Subtitle(
\   "\nAudioLength  = "  + String(AudioLength)
\ + "\nAudioLengthS = '" + AudioLengthS + "'"
\ + "\nAudioLengthF = " + String(AudioLengthF)
\ + "\nAudioLengthLo= " + String(AudioLengthLo)
\ + "\nAudioLengthHi= " + String(AudioLengthHi)
\ , font="courier", text_color=$ffffff, size=32, align=4, lsp=0)
AudioLength-10s.png


  • Clip duration approximately 24 hours.

Integer AudioLength overloads (wraps around to a negative number), while the floating-point form has lost several digits of precision.

ColorBars(width=440, height=440)
#Trim(0, 299)
Loop(24)
Info
...
AudioLength-24hr.png

Note the AudioLengthHi / AudioLengthLo arithmetic:

total = 4 × 109 + 147195848
total = 4147195848



Back to AviSynth Syntax.

Personal tools