ShowFrameNumber

From Avisynth wiki
(Difference between revisions)
Jump to: navigation, search
m (2nd example - caption)
(add link to avs+ documentation)
 
(19 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
<div {{BlueBox2|40|0|3px solid purple}} >
 +
{{AvsPlusFullname}}<br>
 +
Up-to-date documentation: [https://avisynthplus.readthedocs.io/en/latest/avisynthdoc/corefilters/showframes.html https://avisynthplus.readthedocs.io]
 +
</div>
 +
 
Show frame number or time on the screen.
 
Show frame number or time on the screen.
 
__TOC__
 
__TOC__
  
 
== ShowFrameNumber ==
 
== ShowFrameNumber ==
 
+
<div style="max-width:62em" >
{{Template:FuncDef
+
{{FuncDef
 
|ShowFrameNumber(clip ''clip'' [, bool ''scroll'', int ''offset'', float ''x'', float ''y'', <br>
 
|ShowFrameNumber(clip ''clip'' [, bool ''scroll'', int ''offset'', float ''x'', float ''y'', <br>
 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
string ''font'', int ''size'', int ''text_color'', int ''halo_color'', float ''font_width'', float ''font_angle''])}}
+
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.
 
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.
Line 49: Line 55:
 
* Default appearance if source is frame-based:
 
* Default appearance if source is frame-based:
 
:{|  
 
:{|  
 +
|[[File:ShowFrameNumber-Sintel-fr4592.jpg]]
 +
|-
 
| style="margin:0.5em;"|
 
| style="margin:0.5em;"|
 +
''generated by the following script:''
 +
[[FFmpegSource|FFmpegSource2]]("[http://www.sintel.org/ sintel].mp4")
 
  ShowFrameNumber
 
  ShowFrameNumber
|-
 
|[[File:ShowFrameNumber-Sintel-fr4592.jpg]]
 
 
|}
 
|}
  
 
* Draw the frame numbers in red, scrolling from top to bottom, starting with "00009":
 
* Draw the frame numbers in red, scrolling from top to bottom, starting with "00009":
<div {{BoxWidthIndent|60|2}} >
+
<div {{BoxWidthIndent|48|2}} >
  [[DGDecode/MPEG2Source|Mpeg2Source]]("clip.d2v") # is always top field first, therefore numbers will be on the left
+
# this is always top field first, therefore numbers will be on the left
 +
  [[DGDecode/MPEG2Source|Mpeg2Source]]("clip.d2v")  
 
  ShowFrameNumber(scroll=true, offset=9, text_color=$ff0000)
 
  ShowFrameNumber(scroll=true, offset=9, text_color=$ff0000)
 +
</div>
 
</div>
 
</div>
  
  
 
== ShowSMPTE ==
 
== ShowSMPTE ==
 
+
<div style="max-width:62em" >
{{Template:FuncDef|ShowSMPTE(clip ''clip'' [, float ''fps'', string ''offset'', int ''offset_f'', float ''x'', float ''y'', <br>
+
{{FuncDef
 +
|ShowSMPTE(clip ''clip'' [, float ''fps'', string ''offset'', int ''offset_f'', float ''x'', float ''y'', <br>
 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
string ''font'', int ''size'', int ''text_color'', int ''halo_color'', float ''font_width'', float ''font_angle''])}}
+
string ''font'', int ''size'', int ''text_color'', int ''halo_color'', float ''font_width'', float ''font_angle'' ] )
 +
}}
  
 
Displays [http://en.wikipedia.org/wiki/SMPTE_timecode SMPTE]-style timecode labels 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).  
 
Displays [http://en.wikipedia.org/wiki/SMPTE_timecode SMPTE]-style timecode labels 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).  
  
Frame 0 is marked "00:00:00:00", frame 1 is marked "00:00:00:01" and so on - unless an ''offset'' is applied.
+
Frame 0 is marked "00:00:00:00", frame 1 is marked "00:00:00:01" and so on unless an ''offset'' is applied.
 
+
<span style="color:blue;font-weight:bold;font-style:italic">Note: </span>ShowSMPTE framerate '''must''' be an integer (24, 25, 30, 31,...) or a standard drop-frame rate as listed in the table below. All other frame rates (eg, 24.5) are rounded to the nearest integer, implying that '''the timecode display will not correspond to the real or clock time'''.
+
  
 
Due to antialiased text rendering, this filter can be a little slow.
 
Due to antialiased text rendering, this filter can be a little slow.
 +
 +
<div {{BlueBox2|56|2|2px solid black}} >
 +
{{BoldColor|blue|110|''Note:''}}<br>
 +
With certain exceptions, SMPTE timecode has no concept of fractional frame rates (like 24.5 fps for example).
 +
 +
'''ShowSMPTE''' source clips must have an ''integer'' framerate (18, 24, 25, 30, 31,...) or a ''drop-frame'' rate ('29.97' being the most common). Supported drop-frame rates are listed in the table [[#drop_frame_rates|below]]. If that's not the case an error will be thrown.
 +
 +
If the framerate is not integral or drop-frame (let's call it "nonstandard" for short), use '''ShowFrameNumber''' or '''ShowTime''' instead.
 +
 +
You may encounter media sources that are ''almost'' at a standard framerate, but not quite – perhaps due to an error in processing at some point, or perhaps the source was something like a security camera or a video game console. In this case you should force the clip to the nearest standard framerate with [[AssumeFPS]].
 +
</div>
  
 
====Parameters====
 
====Parameters====
 
:{{Par2|clip|clip|}}
 
:{{Par2|clip|clip|}}
::Source clip.
+
::Source clip. See boxed note above.
  
 
:{{Par2|fps|float|(clip.Framerate)}}
 
:{{Par2|fps|float|(clip.Framerate)}}
Line 110: Line 131:
  
 
====Drop-Frame versus Non-Drop-Frame Time Code====
 
====Drop-Frame versus Non-Drop-Frame Time Code====
<div style="width:50em;margin-left:1em;padding:0.1em 0.5em;border-left:0;">
+
<div style="max-width:56em;margin-left:1em;padding:0.1em 0.5em;border-left:0;">
  
For some frame rates, [https://documentation.apple.com/en/finalcutpro/usermanual/index.html#chapter=D%26section=6%26tasks=true drop-frame timecode] is enabled. For example it is enabled if the framerate of the clip is between 29.969 and 29.971.  
+
When television began, it was black-and-white only. At that time NTSC ("American" standard) television ran at 30 frames per second (60 fields per second). When the television engineers added color, they slowed the frame rate by the precise ratio 1000/1001, due to [http://en.wikipedia.org/wiki/SMPTE_timecode#Drop_frame_timecode technical reasons]. NTSC televisions now run at 30×1000/1001 or approximately 29.97002997 frames per second. This is commonly called "29.97 fps." 29.97 is the ''nominal'' framerate, a convenient shortcut term for 30×1000/1001.
  
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  
+
This slight slowing of the framerate complicates the display of timecode. A second of time no longer consists of a whole number of frames. If the timecode readout simply advanced the ''seconds'' counter every 30 frames, the timecode reading would be slower than clock time by about 3.6 seconds per hour. Timecode displays cannot show "fractional" frames (their whole purpose is to uniquely identify every frame) so they [http://documentation.apple.com/en/finalcutpro/usermanual/index.html#chapter=D%26section=6%26tasks=true '''drop'''] the display of just enough frame numbers to make the displayed timecode correspond to ''real'' or clock time. This is done in a prescribed and repeatable fashion: the first two frame numbers of every minute, except for the tenth minute, are dropped, ie
 +
<div {{BoxWidthIndent|30|1}} >
 
  00:00:00:00, 00:00:00:01, 00:00:00:02, ...,  
 
  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:00:59:''29'', 00:01:00:''02'', 00:01:00:03,  
  00:01:59:29, 00:02:00:02, 00:02: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:08:59:''29'', 00:09:00:''02'', 00:09:00:03, ...,  
 
  00:09:59:29, 00:10:00:00, 00:10:00:01, etc  
 
  00:09:59:29, 00:10:00:00, 00:10:00:01, etc  
Dropping these frame numbers allows the timecode display to correspond to the ''real'' or clock time. Without doing this, the timecode would be slower than the real time by a factor of 1000/1001, or 3.6 seconds per hour.
+
</div>
 
+
<div id="drop_frame_rates" style="display:inline;font-size:50%;height:0;line-height:0;overflow:hidden;"></div>
Something similar also occurs for the following framerates:
+
'''ShowSMPTE''' automatically assumes [https://web.archive.org/web/20090206001750/http://teched.vt.edu/gcc/HTML/VirtualTextbook/PDFs/AdobeTutorialsPDFs/Premiere/PremiereTimecode.pdf drop-frame timecode] given certain input framerate ranges, as listed in the table below. For example, if the input framerate is > 29.969 and < 29.971 fps, the framerate is assumed to be 30×1000/1001 for time calculation, and drop-frame counting is used.  
 +
<div {{BoxWidthIndent|30|1}} >
 
{| class="wikitable"
 
{| class="wikitable"
 
|-
 
|-
! framerate range
+
! input fps (bounds excluded)
! base-rate
+
! &nbsp;assumed rate&nbsp;
 +
! nominal rate
 
|-
 
|-
 
|style="text-align:center"|23.975 – 23.977
 
|style="text-align:center"|23.975 – 23.977
|style="text-align:center"| 24
+
|style="text-align:center"|24×1000/1001
 +
|style="text-align:center"|23.98
 
|-
 
|-
 
|style="text-align:center"|29.969 – 29.971
 
|style="text-align:center"|29.969 – 29.971
|style="text-align:center"| 30
+
|style="text-align:center"|30×1000/1001
 +
|style="text-align:center"|29.97
 
|-
 
|-
 
|style="text-align:center"|47.951 – 47.953
 
|style="text-align:center"|47.951 – 47.953
|style="text-align:center"| 48
+
|style="text-align:center"|48×1000/1001
 +
|style="text-align:center"|47.95
 
|-
 
|-
 
|style="text-align:center"|59.939 – 59.941
 
|style="text-align:center"|59.939 – 59.941
|style="text-align:center"| 60
+
|style="text-align:center"|60×1000/1001
 +
|style="text-align:center"|59.94
 
|-
 
|-
|style="text-align:center;letter-spacing:-0.03em;"|119.879 119.881
+
|style="text-align:center;letter-spacing:-0.03em;"|119.879 - 119.881
|style="text-align:center"| 120
+
|style="text-align:center;letter-spacing:-0.03em;"|120×1000/1001
 +
|style="text-align:center;letter-spacing:-0.03em;"|119.88
 
|}
 
|}
ShowSMPTE framerate '''must''' be either an integer or one of the drop-frame rates.
+
</div>
 +
You may [http://www.sonycreativesoftware.com/forums/showmessage.asp?messageid=805428 encounter the term] "NDF" - this means "''non''-drop-frame." As you would expect, this is used for all the integer framerates. Sometimes though, video running at ''drop-frame'' rates will have NDF timecode. This is most common for short-form videos of a few minutes' duration at most: some video professionals prefer not to skip frame numbers at all, even though the time display will be off slightly. To get '''ShowSMPTE''' to show NDF timecode at drop-frame rates, see the example [[#SMPTE_Example2|below]].
 
</div>
 
</div>
  
Line 149: Line 179:
 
* Default appearance:
 
* Default appearance:
 
:{|  
 
:{|  
 +
|[[File:ShowSMPTE-Sintel-fr4592.jpg]]
 +
|-
 
| style="margin:0.5em;"|
 
| style="margin:0.5em;"|
 +
''generated by the following script:''
 +
[[FFmpegSource|FFmpegSource2]]("[http://www.sintel.org/ sintel].mp4")
 
  ShowSMPTE
 
  ShowSMPTE
|-
 
|[[File:ShowSMPTE-Sintel-fr4592.jpg]]
 
 
|}
 
|}
  
 
* Change the position:
 
* Change the position:
<div {{BoxWidthIndent|60|2}} >
+
<div id="SMPTE_Example2" {{BoxWidthIndent|45|2}} >
 
  fontheight=32
 
  fontheight=32
 
   
 
   
Line 170: Line 202:
 
  ##top right
 
  ##top right
 
  ShowSMPTE(size=fontheight, x=(Width-fontheight*3), y=(fontheight))
 
  ShowSMPTE(size=fontheight, x=(Width-fontheight*3), y=(fontheight))
 +
</div>
 +
 +
* Showing non-drop-frame timecode at drop-frame rates:
 +
<div id="SMPTE_Example3" {{BoxWidthIndent|52|2}} >
 +
ColorBars                ## (framerate = 29.97)
 +
ShowSMPTE(size=24, y=24)  ## timecode (top of screen) is DF (drop-frame)
 +
C=Last
 +
AssumeFPS(30)            ## force integer framerate
 +
ShowSMPTE                ## timecode (bottom of screen) is NDF
 +
AssumeFPS(C)              ## fps returned to original
 +
return Last         
 +
 +
## DF (top) skips frame numbers at frames 1800, 3598, 106094...
 +
## NDF (bottom) does not skip numbers but runs slower than real time
 +
##  (frame 106094 = DF "00:59:00:02" == NDF "00:58:56:14")
 
</div>
 
</div>
  
 
* Using {{FuncArg|offset}}, {{FuncArg|x}}, {{FuncArg|y}}, {{FuncArg|font}}, {{FuncArg|size}}, and {{FuncArg|text_color}} arguments:
 
* Using {{FuncArg|offset}}, {{FuncArg|x}}, {{FuncArg|y}}, {{FuncArg|font}}, {{FuncArg|size}}, and {{FuncArg|text_color}} arguments:
<div {{BoxWidthIndent|60|2}} >
+
<div id="SMPTE_Example4" {{BoxWidthIndent|60|2}} >
 
  ShowSMPTE(offset="00:00:59:29", x=360, y=576, font="georgia", size=24, text_color=$ff0000)
 
  ShowSMPTE(offset="00:00:59:29", x=360, y=576, font="georgia", size=24, text_color=$ff0000)
 +
</div>
 
</div>
 
</div>
  
  
 
== ShowTime ==
 
== ShowTime ==
 
+
<div style="max-width:62em" >
{{Template:FuncDef|ShowTime(clip ''clip'' [int ''offset_f'', float ''x'', float ''y'', <br>
+
{{FuncDef
 +
|ShowTime(clip ''clip'' [int ''offset_f'', float ''x'', float ''y'', <br>
 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
string ''font'', int ''size'', int ''text_color'', int ''halo_color'', float ''font_width'', float ''font_angle''])}}
+
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).
 
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).
Line 217: Line 267:
 
* Default appearance:
 
* Default appearance:
 
:{|  
 
:{|  
 +
|[[File:ShowTime-Sintel-fr4592.jpg]]
 +
|-
 
| style="margin:0.5em;"|
 
| style="margin:0.5em;"|
 +
''generated by the following script:''
 +
[[FFmpegSource|FFmpegSource2]]("[http://www.sintel.org/ sintel].mp4")
 
  ShowTime
 
  ShowTime
|-
 
|[[File:ShowTime-Sintel-fr4592.jpg]]
 
 
|}
 
|}
 +
</div>
  
  
 
== Changes ==
 
== Changes ==
 +
<div style="max-width:62em" >
 
{| border="1"
 
{| border="1"
 
|-
 
|-
 
| v2.60
 
| 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).
+
| All functions: position (x,y) can be float (previously int) (with 0.125 pixel granularity).<br>ShowSMPTE: added drop-frame for other framerates (other than 30).
 
|-
 
|-
 
| v2.58
 
| v2.58
Line 239: Line 293:
 
| ShowSMPTE: fps argument is made optional (and taken from the clip by default).
 
| ShowSMPTE: fps argument is made optional (and taken from the clip by default).
 
|}
 
|}
 +
</div>
  
  
 
[[Category:Internal filters]]
 
[[Category:Internal filters]]
 
[[Category:Debugging/Diagnostic filters]]
 
[[Category:Debugging/Diagnostic filters]]

Latest revision as of 10:07, 17 September 2022

AviSynth+
Up-to-date documentation: https://avisynthplus.readthedocs.io

Show frame number or time on the screen.

Contents


[edit] 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.

The frame numbers will be drawn on the left side of the clip for frame-based, top field first material; on the right side for frame-based, bottom field first material and alternating on the left side and right for field-based material, depending whether the field is top or bottom. Much more on the topic of interlaced video on this page: Interlaced Fieldbased.

Due to antialiased text rendering, this filter can be a little slow.

[edit] Parameters

clip  clip =
Source clip.
bool  scroll = false
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.
int  offset = 0
Sets the starting frame number.
float  x,y = 0.0
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.
string  font = "Arial"
Font name. All installed fonts on the current machine are available. Default "Arial"
int  size = 24
Height of the text in pixels. Default 24.
int  text_color = color_yellow
int  halo_color = color_black
Colors for font fill and outline respectively. Default yellow, black.
int  font_width = 0
Set character width in logical units, to the nearest 0.125 unit. See Subtitle for an example. Default=0, use Windows' default width.
float  font_angle = 0.0
Adjust the baseline angle of text in degrees anti-clockwise to the nearest 0.1 degree. Default 0, no rotation.

[edit] Examples

  • Default appearance if source is frame-based:
ShowFrameNumber-Sintel-fr4592.jpg

generated by the following script:

FFmpegSource2("sintel.mp4")
ShowFrameNumber
  • Draw the frame numbers in red, scrolling from top to bottom, starting with "00009":
# this is always top field first, therefore numbers will be on the left
Mpeg2Source("clip.d2v") 
ShowFrameNumber(scroll=true, offset=9, text_color=$ff0000)


[edit] 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-style timecode labels 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).

Frame 0 is marked "00:00:00:00", frame 1 is marked "00:00:00:01" and so on – unless an offset is applied.

Due to antialiased text rendering, this filter can be a little slow.

Note:
With certain exceptions, SMPTE timecode has no concept of fractional frame rates (like 24.5 fps for example).

ShowSMPTE source clips must have an integer framerate (18, 24, 25, 30, 31,...) or a drop-frame rate ('29.97' being the most common). Supported drop-frame rates are listed in the table below. If that's not the case an error will be thrown.

If the framerate is not integral or drop-frame (let's call it "nonstandard" for short), use ShowFrameNumber or ShowTime instead.

You may encounter media sources that are almost at a standard framerate, but not quite – perhaps due to an error in processing at some point, or perhaps the source was something like a security camera or a video game console. In this case you should force the clip to the nearest standard framerate with AssumeFPS.

[edit] Parameters

clip  clip =
Source clip. See boxed note above.
float  fps = (clip.Framerate)
Not required, unless the current fps can't be used.[clarification needed]
If used, fps must be either an integer or a standard drop-frame rate as listed in the table below.
string  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).
int  offset_f = 0
Sets the starting frame number; ignored if offset is supplied.
float  x, y = 0.0
Text position. Their interpretation corresponds to Subtitle's align=2.
string  font = "Arial"
Font name. All installed fonts on the current machine are available. Default "Arial"
int  size = 24
Height of the text in pixels. Default 24.
int  text_color = color_yellow
int  halo_color = color_black
Colors for font fill and outline respectively. Default yellow, black.
int  font_width = 0
Set character width in logical units, to the nearest 0.125 unit. See Subtitle for an example. Default 0.
float  font_angle = 0.0
Adjust the baseline angle of text in degrees anti-clockwise to the nearest 0.1 degree. Default 0, no rotation.

[edit] Drop-Frame versus Non-Drop-Frame Time Code

When television began, it was black-and-white only. At that time NTSC ("American" standard) television ran at 30 frames per second (60 fields per second). When the television engineers added color, they slowed the frame rate by the precise ratio 1000/1001, due to technical reasons. NTSC televisions now run at 30×1000/1001 or approximately 29.97002997 frames per second. This is commonly called "29.97 fps." 29.97 is the nominal framerate, a convenient shortcut term for 30×1000/1001.

This slight slowing of the framerate complicates the display of timecode. A second of time no longer consists of a whole number of frames. If the timecode readout simply advanced the seconds counter every 30 frames, the timecode reading would be slower than clock time by about 3.6 seconds per hour. Timecode displays cannot show "fractional" frames (their whole purpose is to uniquely identify every frame) so they drop the display of just enough frame numbers to make the displayed timecode correspond to real or clock time. This is done in a prescribed and repeatable fashion: the first two frame numbers of every minute, except for the tenth minute, are dropped, 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 

ShowSMPTE automatically assumes drop-frame timecode given certain input framerate ranges, as listed in the table below. For example, if the input framerate is > 29.969 and < 29.971 fps, the framerate is assumed to be 30×1000/1001 for time calculation, and drop-frame counting is used.

input fps (bounds excluded)  assumed rate  nominal rate
23.975 – 23.977 24×1000/1001 23.98
29.969 – 29.971 30×1000/1001 29.97
47.951 – 47.953 48×1000/1001 47.95
59.939 – 59.941 60×1000/1001 59.94
119.879 - 119.881 120×1000/1001 119.88

You may encounter the term "NDF" - this means "non-drop-frame." As you would expect, this is used for all the integer framerates. Sometimes though, video running at drop-frame rates will have NDF timecode. This is most common for short-form videos of a few minutes' duration at most: some video professionals prefer not to skip frame numbers at all, even though the time display will be off slightly. To get ShowSMPTE to show NDF timecode at drop-frame rates, see the example below.

[edit] Examples

  • Default appearance:
ShowSMPTE-Sintel-fr4592.jpg

generated by the following script:

FFmpegSource2("sintel.mp4")
ShowSMPTE
  • Change the position:
fontheight=32

##bottom center
ShowSMPTE(size=fontheight)

##top center
ShowSMPTE(size=fontheight, y=(fontheight))

##top left
ShowSMPTE(size=fontheight, x=(fontheight*3), y=(fontheight))

##top right
ShowSMPTE(size=fontheight, x=(Width-fontheight*3), y=(fontheight))
  • Showing non-drop-frame timecode at drop-frame rates:
ColorBars                 ## (framerate = 29.97)
ShowSMPTE(size=24, y=24)  ## timecode (top of screen) is DF (drop-frame)
C=Last
AssumeFPS(30)             ## force integer framerate
ShowSMPTE                 ## timecode (bottom of screen) is NDF 
AssumeFPS(C)              ## fps returned to original
return Last           

## DF (top) skips frame numbers at frames 1800, 3598, 106094...
## NDF (bottom) does not skip numbers but runs slower than real time
##  (frame 106094 = DF "00:59:00:02" == NDF "00:58:56:14")
  • Using offset, x, y, font, size, and text_color arguments:
ShowSMPTE(offset="00:00:59:29", x=360, y=576, font="georgia", size=24, text_color=$ff0000)


[edit] 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).

Due to antialiased text rendering, this filter can be a little slow.

[edit] Parameters

clip  clip =
Source clip.
int  offset_f = 0
Sets the starting frame number. Displayed time will be increased by offset_f/clip.FrameRate seconds.
int  x, y = 0
Text position. Their interpretation corresponds to Subtitle's align=2.
string  font = "Arial"
Font name. All installed fonts on the current machine are available. Default "Arial"
int  size = 24
Height of the text in pixels. Default 24.
int  text_color = color_yellow
int  halo_color = color_black
Colors for font fill and outline respectively. Default yellow, black.
int  font_width = 0
Set character width in logical units, to the nearest 0.125 unit. See Subtitle for an example. Default 0.
float  font_angle = 0.0
Adjust the baseline angle of text in degrees anti-clockwise to the nearest 0.1 degree. Default 0, no rotation.

[edit] Examples

  • Default appearance:
ShowTime-Sintel-fr4592.jpg

generated by the following script:

FFmpegSource2("sintel.mp4")
ShowTime


[edit] 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.
v2.53 ShowSMPTE: fps argument is made optional (and taken from the clip by default).
Personal tools