0

In AviSynth, is there a function that returns the current frame number? If not, how can I get the current frame number?

That's my question, but for quality standards:
The goal is the use it in a conditional statement so it's clear what one is looking at when comparing an encode to its source. Something like the following.

a=import("source.avs")
b=ffvideosource("encode.mkv")
interleave(a,b)
media = ((currentFrame % 2 > 0) ? "Encode" : "Source")
subtitle(media)
Louis Waweru
  • 3,572
  • 10
  • 38
  • 53

2 Answers2

2

There is such a runtime variable which is named *current_frame* . But to get what you want this way you should use ConditionalFilter function: http://avisynth.org/mediawiki/ScriptClip

Another way to solve this task, which is simpler I think:

a=import("source.avs").subtitle("Source")
b=ffvideosource("encode.mkv").subtitle("Encode")
interleave(a,b)
2

A simultaneous display of both videos with times and frame numbers can be created in PotPlayer or other players that support AVISynth and can play frame by frame. PotPlayer uses the "F" key to go forward and the "D" key to go backward. This was created by having AVISynth installed and the AVS script:

LoadPlugin("C:\Program Files (x86)\AviSynth 2.5\plugins\ffms2.dll")
V1 = FFVideoSource("Wham!Last Christmas.mp4")
V2 = FFVideoSource("Wham!Last Christmas.mp4")
stackvertical(v1,v2)
ShowFrameNumber(scroll=true, x=20, y=40, font="Arial", size=24, text_color=$ff0000)
ShowTime(x=82, y=64, font="Arial", size=24, text_color=$ff0000)
ShowSMPTE(fps=24, x=78, y=88, font="Arial", size=24, text_color=$ff0000)

FPS=24 was added in case the fps is not exact. V1 and V2 are the same file here but do not have to be and FFMS2.dll is the ffmpeg video loader but you can use directshowsource and eliminate loading the plugin ffms2 as:

V1 = DirectShowSource("Wham!Last Christmas.mp4")
V2 = DirectShowSource("Wham!Last Christmas.mp4")
stackvertical(v1,v2)
ShowFrameNumber(scroll=true, x=20, y=40, font="Arial", size=24, text_color=$ff0000)
ShowTime(x=82, y=64, font="Arial", size=24, text_color=$ff0000)
ShowSMPTE(fps=24, x=78, y=88, font="Arial", size=24, text_color=$ff0000)
budman1
  • 136
  • 3