View Full Version : script to display frame number on the video
ch3
2nd January 2009, 18:48
Hello and happy new year!
First post on the forum, even if I visit the site for many years now. I've only recently started looking into aviSynth, so I still have loads to find out.
I am rendering frames from a 3D application and before I convert them to an .avi I'd like to print the frame number on each frame so I can refer to them during editing.
I started looking in to the CoronaSequence plugIn which handles imageSequences, but didn't get that far.
I can't find a way to detect the first frame filename so I can extract the first frame number (the sequences don't necessarily start from frame 1)
and use it as an offset on the actual video frame.
Any ideas or a better way of doing it? Or even better is there a script that already does it?
Thanks a lot
pc_speak
2nd January 2009, 19:32
I don't know what application you're using for your 3D.
This is one way to number the video frames with AviSynth.
(C:\Program Files\AviSynth 2.5\Docs\english\corefilters\showframes.htm)
avisource("video.avi")
ShowFrameNumber(scroll=true, offset=0, x=10, y=30, font="arial", size=20, text_color=$ff0000)
Change offset=0 to the frame number before the frame you want start the count from.
ch3
2nd January 2009, 21:56
I am using Maya and like most of the VFX applications they deal with image sequences with 4 digits padding.
So an example sequence can be frame.0110.tif -> frame.0200.tif
So since I don't want to specify the first frame (offset) manually, I am after a way to detect this automatically. Are there any system commands available? Maybe I can just list the content of the directory and find the first file in alphabetical order.
Thanks for your quick reply.
pc_speak
3rd January 2009, 23:32
I don't know of a way to automatically insert the frame numbers.
A simple batch file, created with notepad, which lists the frames in the folder:
get_list.bat
dir *.tif /b/on > list.txt
list.txt
This will display in notepad.
Top of the list will be the first frame - the bottom one, the last frame.
============================================================================================
Change the paths as needed. The destination folder must be pre created. I've used \numbered (Innovative! That's me :))
Change the start and end frame numbers to suit.
Save the AVS
Open the AVS in VirtualDub.
Play the video/frames. (Hit the space bar.)
Close VirtualDub.
number_frames.avs
ImageSource("D:\video\frame.%04d.tif", 0110, 0115, use_DevIL=true)
ShowFrameNumber(scroll=true, offset=0, x=10, y=25, font="courier new", size=20, text_color=$ff0000)
ImageWriter("D:\video\numbered\", 0, 0, "tif")
Hope this, or some modification, can help.
ch3
5th January 2009, 16:56
hmm that's interesting.
But is there a way to run the batch from within the .avs script?
Otherwise I may look into a bash script from within cygwin that uses shake (compositing prog) to add the frame numbers on the frames and then execute the avs just to convert it to an .avi
I believe vDub can run from the command line as well right?
kemuri-_9
5th January 2009, 18:08
I believe vDub can run from the command line as well right?
it can be initialized from the command line and be given tasks to perform
run it from the command line with /? to see all the options.
i personally use the cli interface to encode .avs files to lossless .avis
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.