Advertisement
Seedmanc

im@s2 subtitle generator - basic

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