Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage
Register FAQ Calendar Today's Posts Search

Reply
 
Thread Tools Search this Thread Display Modes
Old 20th June 2012, 11:29   #1  |  Link
Melvina
Registered User
 
Join Date: Jun 2011
Posts: 2
Script help needed to label video frames sequentially every 3 frames

Hello,

Hopefully someone may be able to help me out here?

I need a script that will label video frames sequentially every 3 frames.

At the moment I have a method for what I need to do where I take in a video file, and I have to select every third frame. In my video files only 1 out of each 3 will be any good, so currently I use the following bit of script and have to check out all 3 by trial and error:

Selectevery (3,0)
#selectevery (3,1)
#Selectevery (3,2)

What I'm hoping to work out how to do is to get an avisynth script to stamp the number 0, 1 or 2 onto each frame so that I can examine the whole file in one go, decide which of the 3 is good, and then select the relevant selectevery line as above without having to try all 3 all the time.

I tried messing around with modulo functions, but my script writing is pretty rudimentary, and I suspect there is probably a blindingly obvious way of doing this that I don't know about!

Thanks!
Melvina is offline   Reply With Quote
Old 20th June 2012, 12:21   #2  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,431
Code:
ScriptClip("Subtitle(string(current_frame % 3))")
__________________
GScript and GRunT - complex Avisynth scripting made easier
Gavino is offline   Reply With Quote
Old 20th June 2012, 23:40   #3  |  Link
IanB
Avisynth Developer
 
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,167
ScriptClip compiles a new Subtitle filter chain every frame. The Subtitle filter is particularly slow to initialise. The ShowFrameNumber and like text tagging variant suffers quite badly from this delay in setting up per frame variable text.

A significantly faster, but clumsier implementation. This is an all compile once at the script start solution :-
Code:
...Source...
A=SelectEvery(3, 0).Subtitle("0")
B=SelectEvery(3, 1).Subtitle("1")
C=SelectEvery(3, 2).Subtitle("2")
Interleave(A, B, C)
...
Another alternative based on the "only compile the decision not the function" philosophy :-
Code:
...Source...
T0=Subtitle("0")
T1=Subtitle("1")
T2=Subtitle("2")
ConditionalSelect(current_frame % 3,  T0,T1,T2)
...
ConditionalSelect is a new feature currently only available in CVS.

The above 2 solutions will be roughly the same speed. The selection criteria here, (current_frame % 3), is quite trivial, but other scripting needs may be a lot more expressive perhaps involving runtime functions like AverageLuma() and friends that may see a significant advantage.
IanB is offline   Reply With Quote
Old 22nd June 2012, 05:47   #4  |  Link
Melvina
Registered User
 
Join Date: Jun 2011
Posts: 2
Excellent!

Thanks both, I'll have a play around with those, seems to be exactly the sort of thing I need.
Melvina is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 00:13.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.