Advertisement
nanogyth

Untitled

Nov 30th, 2012
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. LoadCPlugin("TASEncodingPackage/programs/freesub.dll")
  2.  
  3. scale=1  # 1 or 8
  4.  
  5. blankclip(1, 256*scale, 224*scale, color=$00ff00ff)
  6. ng_sub()
  7. bilinearresize(640, 480)
  8.  
  9. function ng_sub(
  10. \   clip clp,
  11. \ string "text",
  12. \    int "first_frame",
  13. \    int "last_frame",
  14. \    int "text_color",
  15. \    int "halo_color",
  16. \    int "x",
  17. \    int "y",
  18. \ string "font",
  19. \    int "size",
  20. \    int "align",
  21. \    int "lsp",
  22. \    int "font_width",
  23. \    int "halo_width",
  24. \    int "halo_height",
  25. \    int "x_scale",
  26. \    int "y_scale",
  27. \    int "text_color8",
  28. \    int "halo_color8",
  29. \    int "font8",
  30. \    int "spc8",
  31. \    int "lsp8",
  32. \    int "align8",
  33. \    int "x8",
  34. \    int "y8",
  35. \    int "size8",
  36. \    int "font_width8",
  37. \    int "font_angle8",
  38. \ string "halo8",
  39. \ string "shadow8"
  40. \){
  41.  
  42. #Version 1 2012/11/30
  43.  
  44.     text = default( text, "This is a tool-assisted recording.\n" + \
  45.                           "For details, visit http://TASVideos.org/")
  46.     first_frame = default(first_frame, 0)
  47.     last_frame  = default( last_frame, first_frame + 299)
  48.     text_color  = default( text_color, $00DDDDDD)
  49.     halo_color  = default( halo_color, $80000000)
  50.     font        = default(       font, "TASEncodingPackage/fonts/helvB12.bdf")
  51.     lsp         = default(        lsp, 0)
  52.     x_scale     = default(    x_scale, 8)
  53.     y_scale     = default(    y_scale, x_scale)
  54.     align       = default(      align, 8)
  55.     align_x = align % 3
  56.     align_y = (align - 1) / 3
  57.     default_x = (align_x == 0) ? clp.width - 2 : \
  58.                 (align_x == 2) ? clp.width / 2 : 2
  59.     default_y = (align_y == 0) ? clp.height - 2 : \
  60.                 (align_y == 1) ? clp.height / 2 : 2
  61.     x8 = (defined(x)) ? default(x8, x*x_scale) : default_x
  62.     y8 = (defined(y)) ? default(y8, y*y_scale) : default_y
  63.     x           = default(          x, default_x)
  64.     y           = default(          y, default_y)
  65.     size        = default(       size, 1)
  66.     font_width  = default( font_width, size)
  67.     halo_width  = default( halo_width, font_width)
  68.     halo_height = default(halo_height, size)
  69.  
  70.     text_color8 = default(text_color8, text_color)
  71.     halo_color8 = default(halo_color8, halo_color)
  72.     font8       = default(      font8, "Ariel")
  73.     spc8        = default(       spc8, 0)
  74.     lsp8        = default(       lsp8, lsp*y_scale)
  75.     align8      = default(     align8, align)
  76.     size8       = default(      size8, 112)
  77.     font_width8 = default(font_width8, 0)
  78.     font_angle8 = default(font_angle8, 0)
  79.     halo_radius8 = 0
  80.     mode8        = ""
  81.    
  82. #OO@
  83. #   OO@
  84. #      O@
  85. #        @
  86. #         @
  87. #          @
  88. #          O
  89. #           @
  90. #           O
  91. #           O
  92. #            @
  93. #            O
  94. #@           O
  95.  
  96. #using an unfilled circle reduces the number of calculations
  97. #by a factor of ~16
  98.     circle_12="0 0 "+\
  99.         "  2 12   5 11   7 10   8 9 "+\
  100.         "  12 2   11 5   10 7   9 8 "+\
  101.         " -2 12  -5 11  -7 10  -8 9 "+\
  102.         " -12 2  -11 5  -10 7  -9 8 "+\
  103.         "-2 -12 -5 -11 -7 -10 -8 -9 "+\
  104.         "-12 -2 -11 -5 -10 -7 -9 -8 "+\
  105.         " 2 -12  5 -11  7 -10  8 -9 "+\
  106.         " 12 -2  11 -5  10 -7  9 -8 "
  107.     halo8        = default(          halo8, circle_12)
  108.     shadow8      = default(        shadow8, " -4 -8")
  109.  
  110.     sub = FreeSub(clp, text, x, y, first_frame, last_frame, font, \
  111.         size, text_color, halo_color, align, lsp, font_width, \
  112.         halo_width, halo_height)
  113.  
  114.     sub_HD = ng_bighalo(clp, text, x8, y8, first_frame, last_frame, \
  115.         font8, size8, text_color8, halo_color8, align8, spc8, lsp8, \
  116.         font_width8, font_angle8, halo_radius8, mode8, halo8, shadow8)
  117.        
  118.     (clp.height >= 1080) ? sub_HD : sub
  119. }
  120.  
  121. function ng_bighalo(
  122. \   clip clp,
  123. \ string text,
  124. \  float "x",
  125. \  float "y",
  126. \    int "first_frame",
  127. \    int "last_frame",
  128. \ string "font",
  129. \  float "size",
  130. \    int "text_color",
  131. \    int "halo_color",
  132. \    int "align",
  133. \    int "spc",
  134. \    int "lsp",
  135. \  float "font_width",
  136. \  float "font_angle",
  137. \    int "halo_radius",
  138. \ string "mode",
  139. \ string "halo",
  140. \ string "shadow"
  141. \){
  142.  
  143. #Version 15 2012/11/30
  144. # - drop shadow added
  145. # - halo_radius still works, but calculating the points of
  146. #   a hollow circle for halo is much faster
  147. # - mode is depricated since memo-ing isn't as needed
  148.  
  149.     first_frame = default(first_frame, 0)
  150.     last_frame  = default( last_frame, first_frame + 299)
  151.     font        = default(       font, "Ariel")
  152.     size        = default(       size, 112)
  153.     x           = default(          x, -1)
  154.     y           = default(          y, -1)
  155.     text_color  = default( text_color, $00DDDDDD)
  156.     halo_color  = default( halo_color, $80000000)
  157.     align       = default(      align, 5)
  158.     spc         = default(        spc, 0)
  159.     lsp         = default(        lsp, 0)
  160.     font_width  = default( font_width, 0)
  161.     font_angle  = default( font_angle, 0)
  162.     halo_radius = default(halo_radius, 12)
  163.     mode        = default(       mode, "depricated")
  164.     halo        = default(       halo, mt_circle(halo_radius))
  165.     shadow      = default(     shadow, " -4 -8")
  166.     w           = clp.width
  167.     h           = clp.height
  168.  
  169.     invis = BlankClip(1, w, h, pixel_type="YV12")
  170.     tm = Subtitle(invis, text, x, y, 0, 0, font, size, $00FFFFFF,\
  171.         0, align, spc, lsp, font_width, font_angle)
  172.     text_mask = tm.mt_expand(mode="0 0 "+shadow, chroma="-128")
  173.     halo_mask = text_mask.mt_expand(mode=halo, chroma="-128")
  174.    
  175.     h_color = BitAND(halo_color, $00FFFFFF)
  176.     t_color = BitAND(text_color, $00FFFFFF)
  177.     h_alpha = 255 - BitRShiftU(BitAND(halo_color, $FF000000), 24)
  178.     t_alpha = 255 - BitRShiftU(BitAND(text_color, $FF000000), 24)
  179.     lut_str = string(h_alpha)+ " x * 255 / " +string(t_alpha)+\
  180.               " " +string(h_alpha)+ " - y * 255 / +"
  181.  
  182.     alpha_mask = mt_lutxy(halo_mask, text_mask, lut_str)
  183.  
  184.     hc = BlankClip(1, w, h, color=h_color)
  185.     tc = Subtitle(hc, text, x, y, 0, 0, font, size, t_color,\
  186.         0, align, spc, lsp, font_width, font_angle)
  187.     overlay = tc.Mask(alpha_mask.ConvertToRGB32())
  188.    
  189.     clp.ApplyRange(first_frame, last_frame, "Layer", overlay)
  190. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement