ShowFrameNumber

From Avisynth wiki
(Difference between revisions)
Jump to: navigation, search
m (added category:Debugging/Diagnostic_filters)
(formatting, some rearranging of text)
Line 1: Line 1:
__FORCETOC__
+
Show frame number or time on the screen.
 +
__TOC__
  
=== ShowFrameNumber ===
+
== ShowFrameNumber ==
  
 
{{Template:FuncDef|ShowFrameNumber(clip ''clip'' [, bool ''scroll'', int ''offset'', float ''x'', float ''y'', string ''font'', int ''size'', int ''text_color'', int ''halo_color'', float ''font_width'', float ''font_angle''])}}
 
{{Template:FuncDef|ShowFrameNumber(clip ''clip'' [, bool ''scroll'', int ''offset'', float ''x'', float ''y'', string ''font'', int ''size'', int ''text_color'', int ''halo_color'', float ''font_width'', float ''font_angle''])}}
  
ShowFrameNumber draws text on every frame indicating what number AviSynth thinks it is. This is sometimes useful when writing scripts. If you apply additional filters to the clip produced by ShowFrameNumber, they will treat the text on the frame just as they would treat an image, so the numbers may be distorted by the time you see them.
+
Draws text on every frame indicating what frame number AviSynth sees at that point in the script. This is sometimes useful when writing scripts. If you apply additional filters to the clip, they will treat the text on the frame just as they would treat an image, so the numbers may be distorted by the time you see them. Sometimes this is what you want, as it shows frame blending etc.
  
If scroll (default: false) is set to true the frame number will be drawn only once on the video and scroll from top to bottom, else it will be drawn on one side as often as it fits. For top field first material the framenumber will be drawn on the left side of the clip, for bottom field first material on the right side and for field-based material it will be drawn alternating on the left side and right side of the clip (depending whether the field is top or bottom).
+
For top field first material the frame number will be drawn on the left side of the clip, for bottom field first material on the right side and for field-based material it will be drawn alternating on the left side and right side of the clip (depending whether the field is top or bottom).
  
Starting from v2.56 other options (''offset'', ''x'', ''y'', ''font'', ''size'', ''text_color'', ''halo_color'', ''font_width'', ''font_angle'') are present. ''offset'' enables the user to add an offset to the shown framenumber. See [[Subtitle]] for an explanation of the other options - note that ''x'' and ''y'' must be used together or not at all; if they are present, the ''scroll'' option is ignored. In ShowFrameNumber, their interpretation corresponds to use with align=4 in Subtitle and the special meaning of -1 is not available. Default ''size'' is 24 instead of 18 as in Subtitle.
+
Due to text rendering, this filter can be slow.
  
=== ShowSMPTE ===
+
====Parameters====
 +
;''clip''
 +
:Source clip.
 +
 
 +
;''scroll''
 +
:If ''true'', the frame number will be drawn only once on the video and scroll from top to bottom;
 +
:If ''false'', it will be drawn on one side, stacked vertically as often as it fits. Default is ''false''.
 +
 
 +
;''offset''
 +
:Sets the starting frame number.
 +
 
 +
;''x'', ''y''
 +
: Text position. Their interpretation corresponds to [[Subtitle]]'s ''align=4'' and the special meaning of -1 is not available.
 +
:Note that ''x'' and ''y'' must be used together or not at all; if they are present, the ''scroll'' option is ignored.
 +
 
 +
;''font''
 +
:Font name. All installed fonts on the current machine are available. Default "Arial"
 +
 
 +
;''size''
 +
:Height of the text in pixels. Default 24.
 +
 
 +
;text_color, halo_color
 +
:Colors for font fill and outline respectively. Default yellow, black.
 +
 
 +
;font_width
 +
:Set character width in logical units, to the nearest 0.125 unit. See [[Subtitle#Using_spc_and_font_width_arguments|Subtitle]] for an example. Default=0, use Windows' default width.
 +
 
 +
;font_angle
 +
:Adjust the baseline angle of text in degrees anti-clockwise to the nearest 0.1 degree. Default 0, no rotation.
 +
 
 +
 
 +
== ShowSMPTE ==
  
 
{{Template:FuncDef|ShowSMPTE(clip ''clip'' [, float ''fps'', string ''offset'', int ''offset_f'', float ''x'', float ''y'', string ''font'', int ''size'', int ''text_color'', int ''halo_color'', float ''font_width'', float ''font_angle''])}}
 
{{Template:FuncDef|ShowSMPTE(clip ''clip'' [, float ''fps'', string ''offset'', int ''offset_f'', float ''x'', float ''y'', string ''font'', int ''size'', int ''text_color'', int ''halo_color'', float ''font_width'', float ''font_angle''])}}
  
ShowSMPTE is similar to ShowFrameNumber but displays SMPTE timecode (hours:minutes:seconds:frame). Starting from v2.53 the ''fps'' argument is not required, unless the current fps can't be used. Otherwise, the ''fps'' argument is required and must be 24, 25, 30, or 29.97. Starting from v2.56 other options (''offset'', ''offset_f'', ''x'', ''y'', ''font'', ''size'', ''text_color'', ''halo_color'', ''font_width'', ''font_angle'') are present. ''offset'' enables the user to add an offset to the timecode, while ''offset_f'' enables the user to add an offset to the timecode specifying the number of frames (''offset'' takes precedence over ''offset_f''). See [[Subtitle]] for an explanation of the other options. In ShowSMPTE, the interpretation of ''x'' and ''y'' corresponds to use with align=5 in Subtitle and the special meaning of -1 is not available. Default ''size'' is 24 instead of 18 as in Subtitle.
+
Displays SMPTE timecode for the current frame. Format is ''HH:MM:SS:FF'' (for example "03:52:39:24" = 3 hours, 52 minutes, 39 seconds and 24 frames).
  
Take care: both filters are due to text-drawing quite slow.
+
Due to text rendering, this filter can be slow.
  
'''drop-frame versus non-drop-frame timecode'''
+
====Parameters====
 +
;''clip''
 +
:Source clip.
  
For some framerates the [http://teched.vt.edu/gcc/HTML/VirtualTextbook/PDFs/AdobeTutorialsPDFs/Premiere/PremiereTimecode.pdf drop-frame timecode] is enabled. If for example the framerate of the clip is between 29.969 and 29.971 it is enabled. Originally, when the signal of the TV was black and white, NTSC ran at 60 Hz (30 fps). When they added color, they changed it to 59.94 Hz (29.97 fps) due to technical reasons. They run 1000 frames, but count 1001 (they never actually drop a frame, just a frame number). The first two frames are dropped of every minute except the tenth, ie 00:00:00:00, 00:00:00:01, 00:00:00:02, ..., 00:00:59:29, 00:01:00:02, 00:01:00:03, 00:01:59:29, 00:02:00:02, 00:02:00:03, ..., 00:08:59:29, 00:09:00:02, 00:09:00:03, ..., 00:09:59:29, 00:10:00:00, 00:10:00:01, etc ... Counting the dropped frames implies that 00:10:00:00 in drop-frame matches 00:10:00:00 in real time.
+
;''fps''
 +
:Not required, unless the current fps can't be used. Otherwise, the ''fps'' argument is required and must be 24, 25, 30, or 29.97.
  
Something similar holds also for the following framerates:
+
;''offset''
 +
:Sets the start time. Format is ''HH:MM:SS:FF'' (for example "03:52:39:24" - 3 hours, 52 minutes, 39 seconds and 24 frames).
  
{| border="1"
+
;''offset_f''
 +
:Sets the starting frame number; ignored if ''offset'' is supplied.
 +
 
 +
;''x'', ''y''
 +
: Text position. Their interpretation corresponds to [[Subtitle]]'s ''align=4'' and the special meaning of -1 is not available.
 +
:Note that ''x'' and ''y'' must be used together or not at all; if they are present, the ''scroll'' option is ignored.
 +
 
 +
;''font''
 +
:Font name. All installed fonts on the current machine are available. Default "Arial"
 +
 
 +
;''size''
 +
:Height of the text in pixels. Default 24.
 +
 
 +
;text_color, halo_color
 +
:Colors for font fill and outline respectively. Default yellow, black.
 +
 
 +
;font_width
 +
:Set character width in logical units, to the nearest 0.125 unit. See [[Subtitle#Using_spc_and_font_width_arguments|Subtitle]] for an example. Default 0.
 +
 
 +
;font_angle
 +
:Adjust the baseline angle of text in degrees anti-clockwise to the nearest 0.1 degree. Default 0, no rotation.
 +
 
 +
====Drop-Frame versus Non-Drop-Frame Time Code====
 +
<div style="width:50em;margin-left:0.5em;padding:0.1em 0.5em;border:none;">
 +
 
 +
For some frame rates, [http://teched.vt.edu/gcc/HTML/VirtualTextbook/PDFs/AdobeTutorialsPDFs/Premiere/PremiereTimecode.pdf drop-frame timecode] is enabled. For example it is enabled if the framerate of the clip is between 29.969 and 29.971.
 +
 
 +
Originally, when the signal of the TV was black and white, NTSC ran at 60 Hz (30 fps). When they added color, they changed it to 59.94 Hz (29.97 fps) due to technical reasons. They run 1000 frames, but count 1001 (they never actually drop a frame, just a frame number). The first two frames are dropped of every minute except the tenth, ie
 +
00:00:00:00, 00:00:00:01, 00:00:00:02, ...,
 +
00:00:59:29, 00:01:00:02, 00:01:00:03,
 +
00:01:59:29, 00:02:00:02, 00:02:00:03, ...,
 +
00:08:59:29, 00:09:00:02, 00:09:00:03, ...,
 +
00:09:59:29, 00:10:00:00, 00:10:00:01, etc
 +
Counting the dropped frames implies that 00:10:00:00 in drop-frame matches 00:10:00:00 in real time.
 +
 
 +
Something similar holds also for the following framerates:
 +
{| class="wikitable"
 
|-
 
|-
| framerate range
+
! framerate range
| base-rate
+
! base-rate
 
|-
 
|-
| [29.969, 29.971]
+
| 29.969 .. 29.971
 
| 30
 
| 30
 
|-
 
|-
| [47.951, 47.953]
+
| 47.951 .. 47.953
 
| 48
 
| 48
 
|-
 
|-
| [59.939, 59.941]
+
| 59.939 .. 59.941
 
| 60
 
| 60
 
|-
 
|-
| [119.879, 119.881]
+
| 119.879 .. 119.881
 
| 120
 
| 120
 
|}
 
|}
 +
</div>
  
 
==== Examples ====
 
==== Examples ====
Line 51: Line 124:
 
  ShowFrameNumber(scroll=true, offset=9, text_color=$ff0000)
 
  ShowFrameNumber(scroll=true, offset=9, text_color=$ff0000)
  
=== ShowTime ===
+
== ShowTime ==
  
 
{{Template:FuncDef|ShowTime(clip ''clip'' [int ''offset_f'', float ''x'', float ''y'', string ''font'', int ''size'', int ''text_color'', int ''halo_color'', float ''font_width'', float ''font_angle''])}}
 
{{Template:FuncDef|ShowTime(clip ''clip'' [int ''offset_f'', float ''x'', float ''y'', string ''font'', int ''size'', int ''text_color'', int ''halo_color'', float ''font_width'', float ''font_angle''])}}
  
ShowTime is similar to ShowSMPTE, but it displays just the time of the video instead of the SMPTE timecode. See ShowSMPTE for an explanation of the options.
+
Displays time for the current frame. Format is ''HH:MM:SS.DDD'' (for example "03:52:39.800" = 3 hours, 52 minutes, 39 seconds and 800 milliseconds).
 +
 
 +
====Parameters====
 +
;''clip''
 +
:Source clip.
 +
 
 +
;''offset_f''
 +
:Sets the starting frame number. Displayed time will be increased by <tt>offset_f/clip.FrameRate</tt> seconds.
 +
 
 +
;''x'', ''y''
 +
: Text position. Their interpretation corresponds to [[Subtitle]]'s ''align=4'' and the special meaning of -1 is not available.
 +
:Note that ''x'' and ''y'' must be used together or not at all; if they are present, the ''scroll'' option is ignored.
 +
 
 +
;''font''
 +
:Font name. All installed fonts on the current machine are available. Default "Arial"
 +
 
 +
;''size''
 +
:Height of the text in pixels. Default 24.
 +
 
 +
;text_color, halo_color
 +
:Colors for font fill and outline respectively. Default yellow, black.
 +
 
 +
;font_width
 +
:Set character width in logical units, to the nearest 0.125 unit. See [[Subtitle#Using_spc_and_font_width_arguments|Subtitle]] for an example. Default 0.
 +
 
 +
;font_angle
 +
:Adjust the baseline angle of text in degrees anti-clockwise to the nearest 0.1 degree. Default 0, no rotation.
  
'''Changes:'''
+
== Changes ==
 
{| border="1"
 
{| border="1"
 
|-
 
|-

Revision as of 00:30, 25 December 2015

Show frame number or time on the screen.

Contents


ShowFrameNumber

ShowFrameNumber(clip clip [, bool scroll, int offset, float x, float y, string font, int size, int text_color, int halo_color, float font_width, float font_angle])

Draws text on every frame indicating what frame number AviSynth sees at that point in the script. This is sometimes useful when writing scripts. If you apply additional filters to the clip, they will treat the text on the frame just as they would treat an image, so the numbers may be distorted by the time you see them. Sometimes this is what you want, as it shows frame blending etc.

For top field first material the frame number will be drawn on the left side of the clip, for bottom field first material on the right side and for field-based material it will be drawn alternating on the left side and right side of the clip (depending whether the field is top or bottom).

Due to text rendering, this filter can be slow.

Parameters

clip
Source clip.
scroll
If true, the frame number will be drawn only once on the video and scroll from top to bottom;
If false, it will be drawn on one side, stacked vertically as often as it fits. Default is false.
offset
Sets the starting frame number.
x, y
Text position. Their interpretation corresponds to Subtitle's align=4 and the special meaning of -1 is not available.
Note that x and y must be used together or not at all; if they are present, the scroll option is ignored.
font
Font name. All installed fonts on the current machine are available. Default "Arial"
size
Height of the text in pixels. Default 24.
text_color, halo_color
Colors for font fill and outline respectively. Default yellow, black.
font_width
Set character width in logical units, to the nearest 0.125 unit. See Subtitle for an example. Default=0, use Windows' default width.
font_angle
Adjust the baseline angle of text in degrees anti-clockwise to the nearest 0.1 degree. Default 0, no rotation.


ShowSMPTE

ShowSMPTE(clip clip [, float fps, string offset, int offset_f, float x, float y, string font, int size, int text_color, int halo_color, float font_width, float font_angle])

Displays SMPTE timecode for the current frame. Format is HH:MM:SS:FF (for example "03:52:39:24" = 3 hours, 52 minutes, 39 seconds and 24 frames).

Due to text rendering, this filter can be slow.

Parameters

clip
Source clip.
fps
Not required, unless the current fps can't be used. Otherwise, the fps argument is required and must be 24, 25, 30, or 29.97.
offset
Sets the start time. Format is HH:MM:SS:FF (for example "03:52:39:24" - 3 hours, 52 minutes, 39 seconds and 24 frames).
offset_f
Sets the starting frame number; ignored if offset is supplied.
x, y
Text position. Their interpretation corresponds to Subtitle's align=4 and the special meaning of -1 is not available.
Note that x and y must be used together or not at all; if they are present, the scroll option is ignored.
font
Font name. All installed fonts on the current machine are available. Default "Arial"
size
Height of the text in pixels. Default 24.
text_color, halo_color
Colors for font fill and outline respectively. Default yellow, black.
font_width
Set character width in logical units, to the nearest 0.125 unit. See Subtitle for an example. Default 0.
font_angle
Adjust the baseline angle of text in degrees anti-clockwise to the nearest 0.1 degree. Default 0, no rotation.

Drop-Frame versus Non-Drop-Frame Time Code

For some frame rates, drop-frame timecode is enabled. For example it is enabled if the framerate of the clip is between 29.969 and 29.971.

Originally, when the signal of the TV was black and white, NTSC ran at 60 Hz (30 fps). When they added color, they changed it to 59.94 Hz (29.97 fps) due to technical reasons. They run 1000 frames, but count 1001 (they never actually drop a frame, just a frame number). The first two frames are dropped of every minute except the tenth, ie

00:00:00:00, 00:00:00:01, 00:00:00:02, ..., 
00:00:59:29, 00:01:00:02, 00:01:00:03, 
00:01:59:29, 00:02:00:02, 00:02:00:03, ..., 
00:08:59:29, 00:09:00:02, 00:09:00:03, ..., 
00:09:59:29, 00:10:00:00, 00:10:00:01, etc 

Counting the dropped frames implies that 00:10:00:00 in drop-frame matches 00:10:00:00 in real time.

Something similar holds also for the following framerates:

framerate range base-rate
29.969 .. 29.971 30
47.951 .. 47.953 48
59.939 .. 59.941 60
119.879 .. 119.881 120

Examples

ShowSMPTE(offset="00:00:59:29", x=360, y=576, font="georgia", size=24, text_color=$ff0000)
# will draw the framenumber on the left side of the clip using an offset of 9 frames, scrolling from top to bottom
Mpeg2Source("clip.d2v") # is always top field first
ShowFrameNumber(scroll=true, offset=9, text_color=$ff0000)

ShowTime

ShowTime(clip clip [int offset_f, float x, float y, string font, int size, int text_color, int halo_color, float font_width, float font_angle])

Displays time for the current frame. Format is HH:MM:SS.DDD (for example "03:52:39.800" = 3 hours, 52 minutes, 39 seconds and 800 milliseconds).

Parameters

clip
Source clip.
offset_f
Sets the starting frame number. Displayed time will be increased by offset_f/clip.FrameRate seconds.
x, y
Text position. Their interpretation corresponds to Subtitle's align=4 and the special meaning of -1 is not available.
Note that x and y must be used together or not at all; if they are present, the scroll option is ignored.
font
Font name. All installed fonts on the current machine are available. Default "Arial"
size
Height of the text in pixels. Default 24.
text_color, halo_color
Colors for font fill and outline respectively. Default yellow, black.
font_width
Set character width in logical units, to the nearest 0.125 unit. See Subtitle for an example. Default 0.
font_angle
Adjust the baseline angle of text in degrees anti-clockwise to the nearest 0.1 degree. Default 0, no rotation.

Changes

v2.60 All functions: position (x,y) can be float (previously int) (with 0.125 pixel granularity). ShowSMPTE: added drop-frame for other framerates (other than 30).
v2.58 Added ShowTime. Added font_width and font_angle.
v2.56 Added offset and other options.
Personal tools