PDA

View Full Version : Does anyone have working frame number superimpose scripts?


FredThompson
21st May 2003, 10:44
The only thing I've managed to find is the VirtualDub filter from Thomas Hargrove (http://toonarchive.com/addframenumbers/)

It works great but the characters are too small for what I'm doing. Does anyone have something similar what would be mroe configurable (or at least have larger numbers?) The time code isn't important to me, all I need is frame numbers.

(edit)

Whoops!!! Thomas has a new version with LOTS of configuration. The image on his page is old, the version I last used. The new one is very nice.

Wilbert
21st May 2003, 12:48
Maybe this is of any help: http://www.avisynth.org/index.php?page=Showframes

FredThompson
21st May 2003, 13:05
That's nice too. I think Thomas' is better for my needs because it's easier to read when I reduce to CVD.

neily
22nd May 2003, 01:14
Wilbert,
What is Showframes? The link only brings up a SourceForge AVISynth page with the heading "Showframes".

FredThompson,
In the mean time, one of the problems I had was that ShowFrameNumber always seemed to position itself on the right of the clip and more importantly would crop anything more than 5 1/2 digits. However, shOdan mentioned that position was dependent on whether the clip was field or frame-based, and parity. Thus, using just AVISynth, you can use something like:

AVISource("P:\PV Small 18.avi")
vid00=last
BlankClip(vid00,width=76,height=58,color=$FF0000)
SeparateFields()
AssumeTFF()
SelectEven()
vid01=ShowFrameNumber()
Layer(vid00,vid01,"add",x=10,y=10,use_chroma=true)

You can obviously change parameters to reposition/resize the text. This works for me at present until a better ShowFrameNumber comes along.

The original thread was:

http://forum.doom9.org/showthread.php?s=&threadid=49849

FredThompson
22nd May 2003, 01:36
Hmmm...I'll take a look. When I run field-swapped DV the numbers are on the left.

Yes, what you suggest looks great. I'm converting DV to CVD for proofing by my partner who lives a few hundred miles away. The numbers need to be large enough to be very visible but the position must be locked near the bottom so it doesn't obcure most of the intended source.

Thomas' VirtualDub filter uses 7-segment-style numbers but has an obnoxiously long counter and does not offer the outlining which AviSynth does. His latest version has an interesting effect of changing the color based ont he background pixels but it's not tuned properly. The contrast is always changing. Sometimes the numbers are very visible, sometimes not. Red on gray would "pop" visually, purple on gray does not.

I like your script. Thanks.

Wilbert
22nd May 2003, 09:11
Wilbert,
What is Showframes? The link only brings up a SourceForge AVISynth page with the heading "Showframes".
Try again. (I removed a dot in the url ...)

neily
22nd May 2003, 13:35
Fred,

I can't say I have ever done function scripting before, and I am sure someone else will be able to come up with something better, but the following seems to work, provided the dimensions are suitable for conversion between colour spaces. The paramaters are:

function NumberFrame(clip c,int scale,int hpos,int vpos,int backcolour)

hpos=1 :left, hpos=1 :centre, hpos=1 :right
hpos=1 :top, hpos=1 :centre, hpos=1 :bottom
backcolour is normally specified as a hexadecimal, ie red is $FF0000, green is $00FF00, and blue is $0000FF.

function NumberFrame(clip c,int scale,int hpos,int vpos,int backcolour) {
overlay=BlankClip(c.ConvertToYUY2,width=76,height=28,color=backcolour)
owidth=overlay.width*scale
oheight=overlay.height*scale
xpos = hpos == 2 ? (c.width-owidth) / 2 :hpos == 3 ? c.width-oheight -4 : 4
ypos = vpos == 2 ? (c.height-oheight) / 2 :vpos == 3 ? c.height-oheight -4 : 4
overlay=AssumeTFF(overlay)
overlay=ShowFrameNumber(overlay)
overlay=BilinearResize(overlay,owidth,oheight)
layer(c.ConvertToYUY2,overlay,x=xpos,y=ypos)
IsRGB24(c)?last.ConvertToRGB24:IsRGB32(c)?last.ConvertToRGB32:IsYV12(c)?last.ConvertToYV12:IsYUY2(c)?last.ConvertToYUY2:last
}

NumberFrame(vid00,1,2,2,$0000FF)

neily
22nd May 2003, 15:12
Fred,

A slightly different function which handles all clip sizes.

function NumberFrame(clip c,int scale,int hpos,int vpos,int backcolour) {
overlay=BlankClip(c.ConvertToRGB32,width=76,height=28,color=backcolour)
owidth=overlay.width*scale
oheight=overlay.height*scale
xpos = hpos == 2 ? (c.width-owidth) / 2 :hpos == 3 ? c.width-oheight -4 : 4
ypos = vpos == 2 ? (c.height-oheight) / 2 :vpos == 3 ? c.height-oheight -4 : 4
overlay=AssumeTFF(overlay)
overlay=ShowFrameNumber(overlay)
overlay=scale <> 1?BilinearResize(overlay,owidth,oheight): overlay
overlay=ResetMask(overlay)
layer(c.ConvertToRGB32,overlay,x=xpos,y=ypos)
IsRGB24(c)?last.ConvertToRGB24:IsYV12(c)?last.ConvertToYV12:IsYUY2(c)?last.ConvertToYUY2:last
}

FredThompson
22nd May 2003, 16:52
Whoa. That's really cool. Thanks!!

neily
23rd May 2003, 18:47
Fred,

I'm glad it works for you. If you change the first 3 lines to:

function NumberFrame(clip c,int scale,int hpos,int vpos,int backcolour) {
bcwidth = c.FrameCount < 100001?62:74
overlay=BlankClip(c.ConvertToXXXX,width=bcwidth,height=28,color=backcolour)

the overlay will also be sized a little better. ShowFrameNumber always shows a minimum of 5 digits, so the minimum width is about 62, but stretches to 6 digits where appropriate. 6 digits should be enough as it allows for over 9 hours of video at 30fps.

Depending on which colour space you mainly work with, you may of course wish to adapt the script to minimise the number of colour space conversions. Layer currently only works with YUY2 and RGB32.