Guest User

Moviemaker by gamax92 (hackstrife's mod)

a guest
Jan 10th, 2013
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.32 KB | None | 0 0
  1.     --MOVIEMAKER
  2.     --WRITTEN BY GAMAX92
  3.     --VER 1.0 UPDATE http://pastebin.com/raw.php?i=qhE2QGm9
  4.     --
  5.     --NUCULAR'S MOD
  6.     --i've only modified it for png support and fixed a few graphical glitches.
  7.     --based on official version 1.6
  8.     --all changes made by me are commented.
  9.     --all rights for this script are going to gamax92.
  10.     --HACKSTRIFE'MOD
  11.     -- Added quality setting and fixed compatibility with latest ffmpeg version
  12.     -- Based on nucular's mod and official version 1.6
  13.     -- Changes are commented and prefixed with "%%"
  14.     -- Credit goes to nucular and gamax92
  15.      
  16.     qual = 3 -- default quality bigger is worse ranges from 1 to 31
  17.     nob = 6
  18.     recording = 0
  19.     recordfps = 25 -- more realistic fps
  20.     recordframes = 0
  21.     recordft = ".avi"
  22.     recorduiseen = 0
  23.     recorduitype = 0
  24.     if package.config:sub(1,1) == "\\" then
  25.        recordds = "\\"
  26.     else
  27.        recordds = "/"
  28.     end
  29.      
  30.     uix = (612 / 2) - (146 / 2)
  31.     uiy = (384 / 2) - (58 / 2)
  32.      
  33.     function tpt.recordsui()
  34.        tpt.fillrect(612,nob * 16,14,14) -- fixed the fillrect-glitch in tptpp
  35.        tpt.drawtext(618,nob * 16 + 5,"S",0,0,0)
  36.        recordframes = recordframes + 1
  37.        tpt.drawtext(5,385,tostring(math.floor(recordframes / recordfps)) .. "s") -- show real seconds in result - divide by recordfps not by 60
  38.     end
  39.      
  40.     function tpt.recordui()
  41.        if recorduiseen == 1 then
  42.           tpt.fillrect(uix,uiy,146,58,0,0,0) -- fixed the fillrect-glitch in tptpp
  43.           tpt.drawrect(uix,uiy,146,58)
  44.           tpt.drawrect(uix + 107, uiy + 2, 37, 12)
  45.           if recorduitype == 0 then
  46.              tpt.drawtext(uix + 109, uiy + 5, "Options")
  47.              tpt.drawrect(uix + 2, uiy + 2, 12, 12)
  48.              tpt.drawrect(uix + 54, uiy + 2, 12, 12)
  49.      
  50.              if recordft == ".avi" then
  51.                 tpt.fillrect(uix + 2, uiy + 2, 10, 10, 0, 255, 0) -- fixed the fillrect-glitch in tptpp
  52.                 tpt.fillrect(uix + 54, uiy + 2, 10, 10, 0, 63, 0) -- fixed the fillrect-glitch in tptpp
  53.              else
  54.                 tpt.fillrect(uix + 2, uiy + 2, 10, 10, 0, 63, 0) -- fixed the fillrect-glitch in tptpp
  55.                 tpt.fillrect(uix + 54, uiy + 2, 10, 10, 0, 255, 0) -- fixed the fillrect-glitch in tptpp
  56.              end
  57.              tpt.drawrect(uix + 2, uiy + 16, 70, 12)
  58.              tpt.drawrect(uix + 74, uiy + 16, 70, 12)
  59.              tpt.drawrect(uix + 2, uiy + 30, 70, 12)
  60.              tpt.drawrect(uix + 74, uiy + 30, 70, 12)
  61.              tpt.drawrect(uix + 2, uiy + 44, 142, 12)
  62.              tpt.drawtext(uix + 16, uiy + 5, "AVI Out")
  63.              tpt.drawtext(uix + 68, uiy + 5, "GIF Out")
  64.      
  65.              tpt.drawtext(uix + 9, uiy + 18, "Clean folder")
  66.              tpt.drawtext(uix + 76, uiy + 18, "Start recording")
  67.              tpt.drawtext(uix + 13, uiy + 32, "Select AVI")
  68.              tpt.drawtext(uix + 85, uiy + 32, "Select GIF")
  69.              tpt.drawtext(287, uiy + 47, "CREATE!")
  70.           else
  71.              tpt.drawtext(uix + 115, uiy + 5, "Main")
  72.              tpt.drawrect(uix + 49, uiy + 16, 12, 12)
  73.              tpt.drawrect(uix + 63, uiy + 16, 19, 12)
  74.              tpt.drawrect(uix + 84, uiy + 16, 12, 12)
  75.              tpt.drawtext(uix + 2, uiy + 19, "FPS:")
  76.              tpt.drawline(uix + 52, uiy + 22, uix + 58, uiy + 22)
  77.              tpt.drawtext(uix + (72 - (tpt.textwidth(tostring(recordfps)) / 2)), uiy + 19, tostring(recordfps))
  78.              tpt.drawline(uix + 87, uiy + 22, uix + 93, uiy + 22)
  79.              tpt.drawline(uix + 90, uiy + 19, uix + 90, uiy + 25)
  80.              -- %%quality menu part
  81.              tpt.drawrect(uix + 49, uiy + 32, 12, 12)
  82.              tpt.drawrect(uix + 63, uiy + 32, 19, 12)
  83.              tpt.drawrect(uix + 84, uiy + 32, 12, 12)
  84.              tpt.drawtext(uix + 2, uiy + 35, "QUALITY:")
  85.              tpt.drawline(uix + 52, uiy + 38, uix + 58, uiy + 38)
  86.              tpt.drawtext(uix + (72 - (tpt.textwidth(tostring(qual)) / 2)), uiy + 35, tostring(qual))
  87.              tpt.drawline(uix + 87, uiy + 38, uix + 93, uiy + 38)
  88.              tpt.drawline(uix + 90, uiy + 35, uix + 90, uiy + 41)
  89.           end
  90.        end
  91.        tpt.drawrect(613,nob * 16 + 1,14,14)
  92.        tpt.drawtext(618,nob * 16 + 5,"S")
  93.     end
  94.      
  95.     function tpt.recordmouse(x,y,b,e)
  96.        if recording == 1 and x > 612 and y > (nob * 16) and x < 629 and y < (nob * 16 + 16) and b == 1 and e == 1 then
  97.           tpt.unregister_step(tpt.recordsui)
  98.           tpt.unregister_step(tpt.screenshot)
  99.           tpt.register_step(tpt.recordui)
  100.           tpt.set_pause(1)
  101.           recording = 0
  102.           recorduiseen = 1
  103.        elseif recording == 0 and x > 612 and y > (nob * 16) and x < 629 and y < (nob * 16 + 16) and b == 1 and e == 1 then
  104.           recorduiseen = math.mod(recorduiseen + 1, 2)
  105.           tpt.set_pause(recorduiseen)
  106.        end
  107.        if x > uix + 106 and y > uiy + 1 and x < uix + 148 and y < uiy + 15 and b == 1 and e == 1 then
  108.           recorduitype = math.mod(recorduitype + 1, 2)
  109.        end
  110.        if b == 1 and e == 1 and recorduiseen == 1 and recorduitype == 0 then
  111.           if x > uix + 1 and y > uiy + 15 and x < uix + 73 and y < uiy + 29 then
  112.              -- deleting only screenshot pngs
  113.              if recordds == "\\" then
  114.                 os.execute("del screenshot_*.png")
  115.              else
  116.                 os.execute("rm screenshot_*.png")
  117.              end
  118.              recordframes = 0
  119.              --%small bugfix
  120.           elseif x > uix + 73 and y > uiy + 15 and x < uix + 145 and y < uiy + 29 then
  121.              tpt.unregister_step(tpt.recordui)
  122.              tpt.register_step(tpt.recordsui)
  123.              tpt.register_step(tpt.screenshot)
  124.              tpt.set_pause(0)
  125.              recording = 1
  126.              recorduiseen = 0
  127.           elseif x > uix + 1 and y > uiy + 29 and x < uix + 73 and y < uiy + 43 then
  128.              recordft = ".avi"
  129.           elseif x > uix + 73 and y > uiy + 29 and x < uix + 145 and y < uiy + 43 then
  130.              recordft = ".gif"
  131.           elseif x > uix + 1 and y > uiy + 43 and x < uix + 145 and y < uiy + 57 then
  132.              videocount = 1
  133.              while io.open("Videos" .. recordds .. "tptvideo" .. string.format("%04d",videocount) .. ".*", "rb") ~= nil do
  134.                 videocount = videocount + 1
  135.              end
  136.              os.execute("ffmpeg -r " .. tostring(recordfps) .. "  -i screenshot_%06d.png -q:v " .. tostring(qual) .. " Videos" .. recordds .. "tptvideo" .. string.format("%04d",videocount).. recordft)
  137.              -- working png converting
  138.              -- %%updated with variable quality support '-q:v" .. qual ..'
  139.           end
  140.        elseif b == 1 and e == 1 and recorduiseen == 1 and recorduitype == 1 then
  141.           if x > uix + 48 and y > uiy + 15 and x < uix + 61 and y < uiy + 29 then
  142.              if recordfps > 1 then recordfps = recordfps - 1 end
  143.           elseif x > uix + 83 and y > uiy + 15 and x < uix + 96 and y < uiy + 29 then
  144.              if recordfps < 60 then recordfps = recordfps + 1 end
  145.           -- %% quality menu mouse click check
  146.           elseif x > uix + 48 and y > uiy + 33 and x < uix + 61 and y < uiy + 48 then
  147.              if qual > 1 then qual = qual - 1 end
  148.           elseif x > uix + 83 and y > uiy + 33 and x < uix + 96 and y < uiy + 48 then
  149.              if qual < 31 then qual = qual + 1 end
  150.           end
  151.        end
  152.     end
  153.      
  154.     tpt.register_step(tpt.recordui)
  155.     tpt.register_mouseclick(tpt.recordmouse)
Add Comment
Please, Sign In to add comment