Guest User

Untitled

a guest
Aug 18th, 2013
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function frame2time(clip c, int f)
  2.     {
  3.         rawtime = f/c.framerate  
  4.         hours   = rawtime/3600.0
  5.         minutes = frac(hours)*60.0
  6.         seconds = frac(minutes)*60.0  
  7.         time    =string(floor(hours),"%1.0f")+":"+string(floor(minutes),"%02.0f")+":"+string(seconds,"%05.2f")
  8.        
  9.         return time
  10.     }
  11.  
  12. function prepareline(clip c, string s, int f)
  13.     {
  14.         result  = RT_StrReplace(s,"0:00:00.00",frame2time(c,f))
  15.         result  = RT_StrReplace(result,"0:00:01.00",frame2time(c,f+round(c.framerate)))
  16.  
  17.         return result
  18.     }  
  19.  
  20. directshowsource("test_hibiki.mkv")
  21.  
  22. #Variables:
  23. filename       = "subtitle.ass"
  24. stringtemplate = "Dialogue: 0,0:00:00.00,0:00:01.00,DefaultStyle,,0000,0000,0000,,"
  25.  
  26. #Coordinates of the textbox for 720p
  27. tbX      = 198
  28. tbY      = 584
  29. tbW      = 880
  30. tbH      = 92
  31.  
  32. #Starting with a new line just to be sure.    
  33. writefilestart(filename,"chr(13)",append=true)    
  34.  
  35. textbox  = crop(tbx,tby,tbw,tbh).coloryuv(autogain=true,autowhite=true ).levels(8,1,255-8,0,255,coring=false)
  36. detected = false
  37.  
  38. temp=""" detected=true          \
  39.    writefile(filename,"prepareline(last,stringtemplate,current_frame)",append=true) last"""
  40. t="overlay(blankclip(width=tbw,height=tbh,color=$00FF00),x=tbx,y=tby,opacity=0.3 ) "  
  41. #^ indicates detection by placing green bar over the textbox when it occurs
  42.  
  43. scriptclip("""
  44. tal=textbox.rt_averageluma
  45. (tal<235 && tal>190)?           \
  46.    eval(t+"(detected==false)?   \
  47.         eval(temp):last          \          
  48.     "):                          \
  49.    eval( "detected=false last")
  50. """)
  51.  
  52. 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