SHARE
TWEET

Untitled

a guest May 23rd, 2019 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @echo off
  2. COLOR 03
  3. echo ========================================================================
  4. echo = WELCOME TO SUPER GIFMAKER 5000 EX ALPHA TURBO ARCADE EDITION v0.6.01 =
  5. echo ========================================================================
  6.  
  7.  
  8. REM ## Variables & Information %%
  9. set ext=%~x1
  10. set ext=%ext:tp=ts%
  11. set ext=%ext:m2ts=ts%
  12. set ext=%ext:m2t=ts%
  13. set dirFiles=%~dp0files
  14. set dirTemp=%~dp0temp
  15. set input=%dirTemp%\bat_cut%ext%
  16. set output=%dirTemp%\export
  17. set range=full
  18. set rangeduration=0
  19. set startsec=0
  20. set endsec=0
  21. set errorcheck=0
  22. echo Working in: "%~dp0" & echo.
  23. echo Working with: %1 & echo.
  24.  
  25. :avisynthcheck
  26. IF not exist "%dirFiles%\plugindir.txt" (
  27.   goto :avisynthfind
  28. ) ELSE (
  29.   goto :avisynthfound
  30. )
  31.  
  32. :avisynthfind
  33. echo * * * First time running. Checking for Avisynth plugin directory * * * & echo.
  34. for /f "tokens=2*" %%a in ('REG QUERY HKLM\SOFTWARE\WOW6432Node\AviSynth /v plugindir2_5') do set "plugindir=%%~b"
  35. IF NOT "%plugindir%" == "" goto :avisynthsave
  36. for /f "tokens=2*" %%a in ('REG QUERY HKCU\SOFTWARE\WOW6432Node\AviSynth /v plugindir2_5') do set "plugindir=%%~b"
  37. IF NOT "%plugindir%" == "" goto :avisynthsave
  38. for /f "tokens=2*" %%a in ('REG QUERY HKLM\SOFTWARE\AviSynth /v plugindir2_5') do set "plugindir=%%~b"
  39. IF NOT "%plugindir%" == "" goto :avisynthsave
  40. for /f "tokens=2*" %%a in ('REG QUERY HKCU\SOFTWARE\AviSynth /v plugindir2_5') do set "plugindir=%%~b"
  41. IF NOT "%plugindir%" == "" goto :avisynthsave
  42. echo. & echo ERROR: Could not locate avisynth plugin folder. Please make sure Avisynth 2.5 is installed. & echo.
  43. pause
  44. goto :end
  45.  
  46. :avisynthsave
  47. <nul set /p ".=%plugindir%\" > "%dirFiles%\plugindir.txt
  48.  
  49. :avisynthfound
  50. set /p plugindir=<"%dirFiles%\plugindir.txt"
  51. echo. & echo AviSynth plugin directory: %plugindir% & echo ----- & echo.
  52.  
  53. :datetime
  54. for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a"
  55. set "YY=%dt:~2,2%" & set "YYYY=%dt:~0,4%" & set "MM=%dt:~4,2%" & set "DD=%dt:~6,2%"
  56. set "HH=%dt:~8,2%" & set "Min=%dt:~10,2%" & set "Sec=%dt:~12,2%"
  57. set "fullstamp=%YYYY%-%MM%-%DD%_%HH%-%Min%-%Sec%"
  58.  
  59. :timestamps
  60. REM ## Timestamps ##
  61. set endtime=
  62. echo.
  63. set /P "starttime=Please enter a starting timestamp in hh:mm:ss format: "
  64. IF "%starttime%" == "" goto :cleanup
  65. set /P "endtime=Please enter an ending timestamp in hh:mm:ss format (leave blank for default 10s cut): "
  66. set hours=%starttime:~0,2%
  67. set minutes=%starttime:~3,2%
  68. set seconds=%starttime:~6,2%
  69. IF "%hours:~0,1%" == "0" set hours="%hours:~1,1%"
  70. IF "%minutes:~0,1%" == "0" set minutes="%minutes:~1,1%"
  71. IF "%seconds:~0,1%" == "0" set seconds="%seconds:~1,1%"
  72. set /a "startsec=(%hours% * 3600) + (%minutes% * 60) + %seconds%"
  73. set hours=%endtime:~0,2%
  74. set minutes=%endtime:~3,2%
  75. set seconds=%endtime:~6,2%
  76. IF "%hours:~0,1%" == "0" set hours="%hours:~1,1%"
  77. IF "%minutes:~0,1%" == "0" set minutes="%minutes:~1,1%"
  78. IF "%seconds:~0,1%" == "0" set seconds="%seconds:~1,1%"
  79. set /a "endsec=(%hours% * 3600) + (%minutes% * 60) + %seconds%"
  80. set /a rangeduration=%endsec% - %startsec%
  81. IF "%endtime%" == "" (
  82.   echo. & echo * * Creating 10s video clip starting at %starttime% & echo.
  83.   set range=0
  84. ) ELSE (
  85.     echo. & echo * * Clipping video from %starttime% to %endtime% & echo.
  86.     set range=1
  87.   )
  88. )
  89.  
  90. :cleanup
  91. REM ## Temp folder cleanup ##
  92. echo. & echo * * Cleaning up temp files & echo.
  93. timeout /t 1 /nobreak >nul
  94. IF not exist "%dirTemp%" mkdir "%dirTemp%"
  95. IF exist "%dirTemp%\previous" rd "%dirTemp%\previous" /s /q
  96. mkdir "%dirTemp%\previous"
  97. MOVE "%dirTemp%\"*.* "%dirTemp%\previous"
  98. echo # Video: %1 >> "%dirTemp%\avs.avs"
  99.  
  100. :batcut
  101. REM ## Create bat_cut ##
  102. echo. & echo * * Attempting to create bat_cut%ext% using ffmpeg, please wait... & echo.
  103. timeout /t 1 /nobreak >nul
  104. IF "%range%" == "0" (
  105.   "%~dp0files\ffmpeg" -ss %starttime% -i %1 -y -vcodec copy -t 00:00:10.000 "%dirTemp%\bat_cut%ext%" -loglevel warning
  106.   echo # Start time: %starttime% >> "%dirTemp%\avs.avs"
  107.   goto :makewebm
  108. ) ELSE (
  109.   IF "%range%" == "full" (
  110.     echo full range
  111.    REM %~dp0files\ffmpeg -i %1 -y -vcodec copy "%dirTemp%\bat_cut%ext%" -loglevel warning
  112.     set input=%1
  113.     echo # Clipping full video. >> "%dirTemp%\avs.avs"
  114.     goto :avscut
  115.   ) ELSE (
  116.     "%~dp0files\ffmpeg" -ss %starttime% -i %1 -y -vcodec copy -t %rangeduration% "%dirTemp%\bat_cut%ext%" -loglevel warning
  117.     echo # Time frame: %starttime% to %endtime% >> "%dirTemp%\avs.avs"
  118.     goto :makewebm
  119.   )
  120. )
  121.  
  122. :makewebm
  123. REM ## Create bat_cut webm ##
  124. echo. & echo. & echo ==========================================================================
  125. echo. & echo * * Attempting to create bat_cut.webm for resizer.html please wait... * * & echo.
  126. echo ==========================================================================
  127. timeout /t 1 /nobreak >nul
  128.  
  129. IF "%range%" == "0" (
  130.   "%~dp0files\ffmpeg" -ss %starttime% -i %1 -y -c:v libvpx -crf 4 -b:v 4M -vf scale=640:-1 -an -t 00:00:10.000 "%dirTemp%\bat_cut.webm"
  131. ) ELSE (
  132.   IF "%range%" == "full" (
  133.     goto :avscut
  134.   ) ELSE (
  135.    REM "%~dp0files\ffmpeg" -ss %starttime% -i %1 -to %endtime% -y -c:v libvpx -crf 4 -b:v 4M -vf scale=640:-1 -an -copyts "%dirTemp%\bat_cut.webm"
  136.     "%~dp0files\ffmpeg" -ss %starttime% -i %1 -y -c:v libvpx -crf 4 -b:v 4M -vf scale=640:-1 -an -t %rangeduration% "%dirTemp%\bat_cut.webm"
  137.    
  138.   )
  139.   )
  140. )
  141. echo. & echo. & echo ================================  bat_cut.webm finished  ========================================== & echo.
  142.  
  143. :avscut
  144. REM ## dgindex or ffmsindex ##
  145. timeout /t 1 /nobreak >nul
  146. IF "%errorcheck%" == "1" goto :errorboy
  147. IF "%ext%" == ".ts" (
  148.   goto :checkformat
  149. ) ELSE (
  150.   echo. & echo * * Video identified as a %ext% file. Attempting to index clip using ffmsindex, please wait... & echo.
  151.   "%plugindir%ffmsindex" -f "%input%"
  152.   echo FFmpegSource2^("%input%"^) >> "%dirTemp%\avs.avs"
  153.   goto :finish
  154. )
  155.  
  156. :checkformat
  157. echo. & echo * * Checking video format... * * & echo.
  158. "%!!%%Format%% %1 > "%dirTemp%\formatinfo.txt"
  159. set /p videoformat=<"%dirTemp%\formatinfo.txt"
  160. if "%videoformat%" == "MPEG Video" goto :mpegcodec
  161. if "%videoformat%" == "AVC" goto :avccodec
  162. echo. & echo ! ! Something went wrong. Unknown video format %videoformat%. Please run and tell Dr. brandinator.sexy ! ! & echo.
  163. goto :end
  164.  
  165. :mpegcodec
  166. echo. & echo * * Video formatidentified as MPEG. Attempting to index clip using dgindex, please wait... & echo.
  167. echo * * NOTE: If dgindex pops an error and does not close automatically, manually close dgindex window to attempt lossless cut * * & echo.
  168. "%plugindir%dgindex" -IF=[%input%] -OF=[%output%] -EXIT
  169. IF NOT exist "%output%.d2v" (
  170.   set errorcheck=1
  171.   goto :errorboy
  172. )
  173. echo DGDecode_mpeg2source^("%output%.d2v",info=3^) >> "%dirTemp%\avs.avs"
  174. goto :finish
  175.  
  176. :avccodec
  177. echo. & echo * * Video format identified as AVC. Attempting to index clip using dgavcindex, please wait... & echo.
  178. "%plugindir%dgavcindex" -i "%input%" -o "%output%.dga" -h
  179. echo AVCSource^("%output%.dga") >> "%dirTemp%\avs.avs"
  180. goto :finish
  181.  
  182. :errorboy
  183. REM ## attempt lossless cut ##
  184. timeout /t 1 /nobreak >nul
  185. IF "%errorcheck%" == "1" (
  186.   echo. & echo * * Normal method failed, attempting lossless cut, please wait... & echo.
  187.   IF "%range%" == "0" (
  188.     "%~dp0files\ffmpeg" -ss %starttime% -i %1 -y -c:v libx264 -preset ultrafast -qp 0 -t 00:00:10.000 "%dirTemp%\bat_cut.mkv" -loglevel warning
  189.   ) ELSE (
  190.       IF "%range%" == "full" (
  191.         "%~dp0files\ffmpeg" -i %1 -y -c:v libx264 -preset ultrafast -qp 0 "%dirTemp%\bat_cut.mkv" -loglevel warning
  192.       ) ELSE (
  193.           "%~dp0files\ffmpeg" -ss %starttime% -i %1 -y -c:v libx264 -preset ultrafast -qp 0 -t %rangeduration% "%dirTemp%\bat_cut.mkv" -loglevel warning
  194.         )
  195.   )
  196.   "%plugindir%ffmsindex" -f "%dirTemp%\bat_cut.mkv"
  197.   echo FFmpegSource2("%dirTemp%\bat_cut.mkv"^) >> "%dirTemp%\avs.avs"
  198. )
  199.  
  200. :finish
  201. timeout /t 1 /nobreak >nul
  202. echo. & echo * * Opening resizer.html and AvsPmod & echo.
  203. "%~dp0files\resizer\index.html"
  204. type "%~dp0files\template.txt" >> "%dirTemp%\avs.avs"
  205. IF not exist "%~dp0output" mkdir "%~dp0output"
  206. "%~dp0files\AvsPmod\AvsPmod.exe" "%dirTemp%\avs.avs"
  207. "%~dp0files\vdub\vdub.exe" /i "%~dp0files\save_as_avi.vcf" "%dirTemp%\avs.avs" "%~dp0output\%fullstamp%.avi"
  208.  
  209. :repeat
  210. echo.
  211. choice /C YN /T 10 /D N /M "Would you like to make another cut from this video?"
  212. IF %ERRORLEVEL% EQU 1 goto :datetime
  213. IF %ERRORLEVEL% EQU 2 echo. & echo All done. & echo.
  214.  
  215. :end
  216. echo. & echo All done. Bye. & echo.
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top