Clip properties

From Avisynth wiki
(Difference between revisions)
Jump to: navigation, search
(formatting, links, phrasing)
Line 1: Line 1:
You can access clip properties in AVS 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]] (see the [[AviSynth Syntax]] for more), except that they cannot be l-values in C-terminology.
+
<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'').
  
 
The full list of properties:
 
The full list of properties:
  
* {{Term|Width}} (clip)
+
* ''int'' clip.{{Term|Width}}
: Returns the width of the clip in pixels (type: int).
+
: Returns the width of the clip in pixels.
* {{Term|Height}} (clip)
+
* ''int'' clip.{{Term|Height}}
: Returns the height of the clip in pixels (type: int).
+
: Returns the height of the clip in pixels.
* {{Term|FrameCount}} (clip)
+
* ''int'' clip.{{Term|FrameCount}}
: Returns the number of frames of the clip (type: int).
+
: Returns the total number of video frames contained in the clip.  
* {{Term|FrameRate}} (clip)
+
* ''float'' clip.{{Term|FrameRate}}
: Returns the number of frames per seconds of the clip (type: float). The framerate is stored represented as a ratio though and more about it can be read [[AssumeFPS|here]].
+
: Returns approximate framerate. Video framerate is actually a ratio of two 32-bit integers;
* {{Term|FrameRateNumerator}} (clip)  (v2.55)
+
: so for the precise number, use {{Term|FrameRateNumerator}} and {{Term|FrameRateDenominator}}.
: Returns the numerator of the number of frames per seconds of the clip (type: int).
+
* ''int'' clip.{{Term|FrameRateNumerator}}
* {{Term|FrameRateDenominator}} (clip)  (v2.55)
+
: Returns the framerate numerator.
: Returns the denominator of the number of frames per seconds of the clip (type: int).
+
* ''int'' clip.{{Term|FrameRateDenominator}}
* {{Term|AudioRate}} (clip)
+
: Returns the framerate denominator.
: Returns the sample rate of the audio of the clip (type int).
+
* ''int'' clip.{{Term|AudioRate}}
* {{Term|AudioLength}} (clip)  (v2.51)
+
: Returns the audio sample rate.
: Returns the number of samples of the audio of the clip (type: int). Be aware of possible overflow on very long clips (2^31 samples limit).
+
* ''int'' clip.{{Term|AudioLength}}
* {{Term|AudioLengthLo}} (clip [, int])  (v2.60)
+
: Returns the total number of audio samples, per audio channel.
: Returns the number of samples of the audio of the clip modulo int. int is 1,000,000,000 by default (type: int).
+
: Be aware of possible overflow on extremely long clips (with >= 2<sup>31</sup> audio samples) &ndash; see [[#Examples|Examples]] below.
* {{Term|AudioLengthHi}} (clip [, int])  (v2.60)
+
* ''int'' clip.{{Term|AudioLengthLo([ int ''m'' ])}} (from v2.60)
: Returns the number of samples of the audio of the clip divided by int (truncated to nearest integer). int is 1,000,000,000 by default (type: int).
+
: Returns the total number of audio samples, modulo {{Term|''m''}}, which is 10<sup>9</sup> by default.
* {{Term|AudioLengthF}} (clip)  (v2.55)
+
* ''int'' clip.{{Term|AudioLengthHi([ int ''d'' ])}} (from v2.60)
: Returns the number of samples of the audio of the clip (type: float).
+
: Returns the total number of audio samples, divided by {{Term|''d''}}, which is 10<sup>9</sup> by default. Truncated to nearest integer.
* {{Term|AudioLengthS}} (clip)  (v2.60)
+
* ''float'' clip.{{Term|AudioLengthF}}
: Returns the number of samples of the audio of the clip as a string (type: string).
+
: Returns the total number of audio samples as a float-point number.
* {{Term|AudioDuration}} (clip)  (v2.60)
+
: No overflow limit, but there is a possible ''precision'' limit &ndash; see [[#Examples|Examples]] below.
: Returns the duration in seconds of the audio of the clip (type: float).
+
* ''string'' clip.{{Term|AudioLengthS}} (from v2.60)
* {{Term|AudioChannels}} (clip)
+
: Returns the total number of audio samples as a string.
: Returns the number of audio channels of the clip (type int).
+
* ''float'' clip.{{Term|AudioDuration}} (from v2.60)
* {{Term|AudioBits}} (clip)
+
: Returns the audio duration in seconds.  
: Returns the audio bit depth of the clip (type int).
+
* ''int'' clip.{{Term|AudioChannels}}
* {{Term|IsAudioFloat}} (clip)  (v2.55)
+
: Returns the number of audio channels.
: Returns true if the audio format of the clip is float (type: bool).
+
* ''int'' clip.{{Term|AudioBits}}
* {{Term|IsAudioInt}} (clip)  (v2.55)
+
: Returns the audio bit depth, ''eg'', 8, 16, 24 or 32.
: Returns true if the audio format of the clip is an integer type (type: bool).
+
* ''bool'' clip.{{Term|IsAudioFloat}}
* {{Term|IsRGB}} (clip)
+
: Returns true if the audio format is [[Float]].
: Returns true if the clip is [[RGB]], false otherwise (type: bool).
+
* ''bool'' clip.{{Term|IsAudioInt}}
* {{Term|IsRGB24}} (clip)  (v2.07)
+
: Returns true if the audio format is an integer type.
: Returns true if the clip is [[RGB24]], false otherwise (type: bool).
+
* ''bool'' clip.{{Term|IsRGB}}
* {{Term|IsRGB32}} (clip)  (v2.07)
+
: Returns true if the color format is [[RGB]], false otherwise.
: Returns true if the clip is [[RGB32]], false otherwise (type: bool).
+
* ''bool'' clip.{{Term|IsRGB24}}
* {{Term|IsYUV}} (clip)  (v2.54)
+
: Returns true if the color format is [[RGB24]], false otherwise.
: Returns true if the clip is [[YUV]], false otherwise (type: bool).
+
* ''bool'' clip.{{Term|IsRGB32}}
* {{Term|IsYUY2}} (clip)
+
: Returns true if the color format is [[RGB32]], false otherwise.
: Returns true if the clip is [[YUY2]], false otherwise (type: bool).
+
* ''bool'' clip.{{Term|IsYUV}}
* {{Term|IsY8}} (clip)  (v2.60)
+
: Returns true if the color format is [[YUV]], false otherwise.
: Returns true if the clip is [[Y8]], false otherwise (type: bool).
+
* ''bool'' clip.{{Term|IsYUY2}} (clip)
* {{Term|IsYV12}} (clip)  (v2.52)
+
: Returns true if the color format is [[YUY2]], false otherwise.
: Returns true if the clip is [[YV12]], false otherwise (type: bool).
+
* ''bool'' clip.{{Term|IsY8}} (from v2.60)
* {{Term|IsYV16}} (clip)  (v2.60)
+
: Returns true if the color format is [[Y8]], false otherwise.
: Returns true if the clip is [[YV16]], false otherwise (type: bool).
+
* ''bool'' clip.{{Term|IsYV12}}
* {{Term|IsYV24}} (clip)  (v2.60)
+
: Returns true if the color format is [[YV12]], false otherwise.
: Returns true if the clip is [[YV24]], false otherwise (type: bool).
+
* ''bool'' clip.{{Term|IsYV16}} (from v2.60)
* {{Term|IsYV411}} (clip)  (v2.60)
+
: Returns true if the clip color format is [[YV16]], false otherwise.
: Returns true if the clip is [[YV411]], false otherwise (type: bool).
+
* ''bool'' clip.{{Term|IsYV24}} (v2.60)
* {{Term|PixelType}} (clip)  (v2.60)
+
: Returns true if the color format is [[YV24]], false otherwise.
: Returns the pixel type of the clip (type: string).
+
* ''bool'' clip.{{Term|IsYV411}} (from v2.60)
* {{Term|IsFieldBased}} (clip)
+
: Returns true if the color format is [[YV411]], false otherwise.
: Returns true if the clip is field-based (type: bool). What this means is explained [[Interlaced_fieldbased|here]].
+
* ''string'' clip.{{Term|PixelType}} (from v2.60)
* {{Term|IsFrameBased}} (clip)
+
: Returns the pixel type as a string, ''eg'' "RGB32".
: Returns true if the clip is frame-based (type: bool). What this means is explained [[Interlaced_fieldbased|here]].
+
* ''bool'' clip.{{Term|IsFieldBased}}
* {{Term|IsPlanar}} (clip)  (v2.51)
+
: Returns true if the clip is ''field-based''. What this means is explained [[Interlaced_fieldbased|'''here''']].
: Returns true if the clip color format is [[Planar]], false otherwise (type: bool).
+
* ''bool'' clip.{{Term|IsFrameBased}}
* {{Term|IsInterleaved}} (clip)  (v2.52)
+
: Returns true if the clip is ''frame-based''. What this means is explained [[Interlaced_fieldbased|'''here''']].
: Returns true if the clip color format is [[Interleaved]], false otherwise (type: bool).
+
* ''bool'' clip.{{Term|IsPlanar}}
* {{Term|GetParity}} (clip, int n)
+
: Returns true if the color format is [[Planar]], false otherwise.
: Returns true if frame n (default 0) is top field of field-based clip, or it is full frame with top field first of frame-based clip (type: bool).
+
* ''bool'' clip.{{Term|IsInterleaved}}
* {{Term|HasAudio}} (clip)  (v2.56)
+
: Returns true if the color format is [[Interleaved]], false otherwise.
: Returns true if the clip has audio, false otherwise (type: bool).
+
* ''bool'' clip.{{Term|GetParity([ int ''f'' ])}}
* {{Term|HasVideo}} (clip)  (v2.56)
+
: 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.
: Returns true if the clip has video, false otherwise (type: bool).
+
* ''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.
 +
</div>
 +
 
 +
 
 +
====Examples====
 +
* Clip duration = 10 seconds. All {{Term|AudioLength}} forms agree.
 +
<div {{BoxWidthIndent|46|2}} >
 +
[[ColorBars]](width=440, height=440)
 +
[[Trim]](0, 299)
 +
[[Info]]
 +
[[Levels]](0, 1.0, 255, 64, 255-64, coring=false)
 +
[[Subtitle]](
 +
\  "\n"
 +
\ + "AudioLength  = "  + String(AudioLength)  + "\n"
 +
\ + "AudioLengthS = '" + String(AudioLengthS) + "'\n"
 +
\ + "AudioLengthF = " + String(AudioLengthF) + "\n"
 +
\ + "AudioLengthLo= " + String(AudioLengthLo) + "\n"
 +
\ + "AudioLengthHi= " + String(AudioLengthHi) + "\n"
 +
\ , font="courier", text_color=$ffffff, size=32, align=4, lsp=0)
 +
</div>
 +
:[[File:AudioLength-10s.png]]
 +
 
 +
 
 +
* Clip duration approximately 24 hours. Integer {{Term|AudioLength}} overloads (wraps around to a negative number), while the floating-point form has lost accuracy.
 +
<div {{BoxWidthIndent|24|2}} >
 +
[[ColorBars]](width=440, height=440)
 +
[[Loop]](24)
 +
...
 +
</div>
 +
:[[File:AudioLength-24hr.png]]
 +
 
  
 
----
 
----

Revision as of 07:44, 12 March 2016

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, except that they are read-only (in C terminology, they cannot be L-values).

The full list of properties:

  • int clip.Width
Returns the width of the clip in pixels.
  • int clip.Height
Returns the height of the clip in pixels.
  • 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.
  • 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)
Returns the total number of audio samples, modulo m, which is 109 by default.
  • int clip.AudioLengthHi([ int d ]) (from v2.60)
Returns the total number of audio samples, divided by d, which is 109 by default. Truncated to nearest integer.
  • 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.
  • bool clip.IsRGB
Returns true if the color format is RGB, false otherwise.
  • 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.
  • 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.
  • string clip.PixelType (from v2.60)
Returns the pixel type as a string, eg "RGB32".
  • 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.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.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.
  • bool clip.HasAudio
Returns true if the clip has audio, false otherwise.
  • bool clip.HasVideo
Returns true if the clip has video, false otherwise.


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(
\   "\n"
\ + "AudioLength  = "  + String(AudioLength)  + "\n"
\ + "AudioLengthS = '" + String(AudioLengthS) + "'\n"
\ + "AudioLengthF = " + String(AudioLengthF) + "\n"
\ + "AudioLengthLo= " + String(AudioLengthLo) + "\n"
\ + "AudioLengthHi= " + String(AudioLengthHi) + "\n"
\ , 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 accuracy.
ColorBars(width=440, height=440)
Loop(24)
...
AudioLength-24hr.png



Back to AviSynth Syntax.

Personal tools