Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function frame2time(clip c, int f){
- rawtime= f/c.framerate
- hours= rawtime/3600.0
- minutes= frac(hours)*60.0
- seconds= frac(minutes)*60.0
- time=string(floor(hours),"%1.0f")+":"+string(floor(minutes),"%02.0f")+":"+string(seconds,"%05.2f")
- return time
- }
- function prepareline(clip c, string s, int f){
- result=RT_StrReplace(s,"0:00:00.00",frame2time(c,f))
- result=RT_StrReplace(result,"0:00:01.00",frame2time(c,f+round(c.framerate)))
- return result
- }
- ffmpegSource2("C:\Users\Seedmanc\Desktop\guiminer\avisynth\imas_question_pause.mkv")
- #Variables:
- filename = "c:\Users\Seedmanc\Desktop\guiminer\avisynth\subhelp\subtitle.ass"
- tbX=198 #Coordinates of the textbox for 720p
- tbY=584
- tbW=880
- tbH=92
- stringtemplate="Dialogue: 0,0:00:00.00,0:00:01.00,DefaultStyle,,0000,0000,0000,,"
- writefilestart(filename,"chr(13)",append=true) #Starting with a new line just to be sure.
- textbox=crop(tbx,tby,tbw,tbh).coloryuv(autogain=true,autowhite=true ).levels(8,1,255-8,0,255,coring=false)
- detected=false
- temp=""" detected=true \
- writefile(filename,"prepareline(last,stringtemplate,current_frame)",append=true) last"""
- t="overlay(blankclip(width=tbw,height=tbh,color=$00FF00),x=tbx,y=tby,opacity=0.3 ) "
- #^ indicates detection by placing green bar over the textbox when it occurs
- scriptclip("""
- tal=textbox.rt_averageluma
- (tal<235 && tal>190)? \
- eval(t+"(detected==false)? \
- eval(temp):last \
- "): \
- eval( "detected=false last")
- """)
- #assumefps(270) # You can make the script scan your video faster by raising the framerate here, if you're running it via player. It works at ~330 fps for me.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement