Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- COLOR 03
- echo ========================================================================
- echo = WELCOME TO SUPER GIFMAKER 5000 EX ALPHA TURBO ARCADE EDITION v0.6.01 =
- echo ========================================================================
- REM ## Variables & Information %%
- set ext=%~x1
- set ext=%ext:tp=ts%
- set ext=%ext:m2ts=ts%
- set ext=%ext:m2t=ts%
- set dirFiles=%~dp0files
- set dirTemp=%~dp0temp
- set input=%dirTemp%\bat_cut%ext%
- set output=%dirTemp%\export
- set range=full
- set rangeduration=0
- set startsec=0
- set endsec=0
- set errorcheck=0
- echo Working in: "%~dp0" & echo.
- echo Working with: %1 & echo.
- :avisynthcheck
- IF not exist "%dirFiles%\plugindir.txt" (
- goto :avisynthfind
- ) ELSE (
- goto :avisynthfound
- )
- :avisynthfind
- echo * * * First time running. Checking for Avisynth plugin directory * * * & echo.
- for /f "tokens=2*" %%a in ('REG QUERY HKLM\SOFTWARE\WOW6432Node\AviSynth /v plugindir2_5') do set "plugindir=%%~b"
- IF NOT "%plugindir%" == "" goto :avisynthsave
- for /f "tokens=2*" %%a in ('REG QUERY HKCU\SOFTWARE\WOW6432Node\AviSynth /v plugindir2_5') do set "plugindir=%%~b"
- IF NOT "%plugindir%" == "" goto :avisynthsave
- for /f "tokens=2*" %%a in ('REG QUERY HKLM\SOFTWARE\AviSynth /v plugindir2_5') do set "plugindir=%%~b"
- IF NOT "%plugindir%" == "" goto :avisynthsave
- for /f "tokens=2*" %%a in ('REG QUERY HKCU\SOFTWARE\AviSynth /v plugindir2_5') do set "plugindir=%%~b"
- IF NOT "%plugindir%" == "" goto :avisynthsave
- echo. & echo ERROR: Could not locate avisynth plugin folder. Please make sure Avisynth 2.5 is installed. & echo.
- pause
- goto :end
- :avisynthsave
- <nul set /p ".=%plugindir%\" > "%dirFiles%\plugindir.txt
- :avisynthfound
- set /p plugindir=<"%dirFiles%\plugindir.txt"
- echo. & echo AviSynth plugin directory: %plugindir% & echo ----- & echo.
- :datetime
- for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a"
- set "YY=%dt:~2,2%" & set "YYYY=%dt:~0,4%" & set "MM=%dt:~4,2%" & set "DD=%dt:~6,2%"
- set "HH=%dt:~8,2%" & set "Min=%dt:~10,2%" & set "Sec=%dt:~12,2%"
- set "fullstamp=%YYYY%-%MM%-%DD%_%HH%-%Min%-%Sec%"
- :timestamps
- REM ## Timestamps ##
- set endtime=
- echo.
- set /P "starttime=Please enter a starting timestamp in hh:mm:ss format: "
- IF "%starttime%" == "" goto :cleanup
- set /P "endtime=Please enter an ending timestamp in hh:mm:ss format (leave blank for default 10s cut): "
- set hours=%starttime:~0,2%
- set minutes=%starttime:~3,2%
- set seconds=%starttime:~6,2%
- IF "%hours:~0,1%" == "0" set hours="%hours:~1,1%"
- IF "%minutes:~0,1%" == "0" set minutes="%minutes:~1,1%"
- IF "%seconds:~0,1%" == "0" set seconds="%seconds:~1,1%"
- set /a "startsec=(%hours% * 3600) + (%minutes% * 60) + %seconds%"
- set hours=%endtime:~0,2%
- set minutes=%endtime:~3,2%
- set seconds=%endtime:~6,2%
- IF "%hours:~0,1%" == "0" set hours="%hours:~1,1%"
- IF "%minutes:~0,1%" == "0" set minutes="%minutes:~1,1%"
- IF "%seconds:~0,1%" == "0" set seconds="%seconds:~1,1%"
- set /a "endsec=(%hours% * 3600) + (%minutes% * 60) + %seconds%"
- set /a rangeduration=%endsec% - %startsec%
- IF "%endtime%" == "" (
- echo. & echo * * Creating 10s video clip starting at %starttime% & echo.
- set range=0
- ) ELSE (
- echo. & echo * * Clipping video from %starttime% to %endtime% & echo.
- set range=1
- )
- )
- :cleanup
- REM ## Temp folder cleanup ##
- echo. & echo * * Cleaning up temp files & echo.
- timeout /t 1 /nobreak >nul
- IF not exist "%dirTemp%" mkdir "%dirTemp%"
- IF exist "%dirTemp%\previous" rd "%dirTemp%\previous" /s /q
- mkdir "%dirTemp%\previous"
- MOVE "%dirTemp%\"*.* "%dirTemp%\previous"
- echo # Video: %1 >> "%dirTemp%\avs.avs"
- :batcut
- REM ## Create bat_cut ##
- echo. & echo * * Attempting to create bat_cut%ext% using ffmpeg, please wait... & echo.
- timeout /t 1 /nobreak >nul
- IF "%range%" == "0" (
- "%~dp0files\ffmpeg" -ss %starttime% -i %1 -y -vcodec copy -t 00:00:10.000 "%dirTemp%\bat_cut%ext%" -loglevel warning
- echo # Start time: %starttime% >> "%dirTemp%\avs.avs"
- goto :makewebm
- ) ELSE (
- IF "%range%" == "full" (
- echo full range
- REM %~dp0files\ffmpeg -i %1 -y -vcodec copy "%dirTemp%\bat_cut%ext%" -loglevel warning
- set input=%1
- echo # Clipping full video. >> "%dirTemp%\avs.avs"
- goto :avscut
- ) ELSE (
- "%~dp0files\ffmpeg" -ss %starttime% -i %1 -y -vcodec copy -t %rangeduration% "%dirTemp%\bat_cut%ext%" -loglevel warning
- echo # Time frame: %starttime% to %endtime% >> "%dirTemp%\avs.avs"
- goto :makewebm
- )
- )
- :makewebm
- REM ## Create bat_cut webm ##
- echo. & echo. & echo ==========================================================================
- echo. & echo * * Attempting to create bat_cut.webm for resizer.html please wait... * * & echo.
- echo ==========================================================================
- timeout /t 1 /nobreak >nul
- IF "%range%" == "0" (
- "%~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"
- ) ELSE (
- IF "%range%" == "full" (
- goto :avscut
- ) ELSE (
- 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"
- "%~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"
- )
- )
- )
- echo. & echo. & echo ================================ bat_cut.webm finished ========================================== & echo.
- :avscut
- REM ## dgindex or ffmsindex ##
- timeout /t 1 /nobreak >nul
- IF "%errorcheck%" == "1" goto :errorboy
- IF "%ext%" == ".ts" (
- goto :checkformat
- ) ELSE (
- echo. & echo * * Video identified as a %ext% file. Attempting to index clip using ffmsindex, please wait... & echo.
- "%plugindir%ffmsindex" -f "%input%"
- echo FFmpegSource2^("%input%"^) >> "%dirTemp%\avs.avs"
- goto :finish
- )
- :checkformat
- echo. & echo * * Checking video format... * * & echo.
- "%!!%%Format%% %1 > "%dirTemp%\formatinfo.txt"
- set /p videoformat=<"%dirTemp%\formatinfo.txt"
- if "%videoformat%" == "MPEG Video" goto :mpegcodec
- if "%videoformat%" == "AVC" goto :avccodec
- echo. & echo ! ! Something went wrong. Unknown video format %videoformat%. Please run and tell Dr. brandinator.sexy ! ! & echo.
- goto :end
- :mpegcodec
- echo. & echo * * Video formatidentified as MPEG. Attempting to index clip using dgindex, please wait... & echo.
- echo * * NOTE: If dgindex pops an error and does not close automatically, manually close dgindex window to attempt lossless cut * * & echo.
- "%plugindir%dgindex" -IF=[%input%] -OF=[%output%] -EXIT
- IF NOT exist "%output%.d2v" (
- set errorcheck=1
- goto :errorboy
- )
- echo DGDecode_mpeg2source^("%output%.d2v",info=3^) >> "%dirTemp%\avs.avs"
- goto :finish
- :avccodec
- echo. & echo * * Video format identified as AVC. Attempting to index clip using dgavcindex, please wait... & echo.
- "%plugindir%dgavcindex" -i "%input%" -o "%output%.dga" -h
- echo AVCSource^("%output%.dga") >> "%dirTemp%\avs.avs"
- goto :finish
- :errorboy
- REM ## attempt lossless cut ##
- timeout /t 1 /nobreak >nul
- IF "%errorcheck%" == "1" (
- echo. & echo * * Normal method failed, attempting lossless cut, please wait... & echo.
- IF "%range%" == "0" (
- "%~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
- ) ELSE (
- IF "%range%" == "full" (
- "%~dp0files\ffmpeg" -i %1 -y -c:v libx264 -preset ultrafast -qp 0 "%dirTemp%\bat_cut.mkv" -loglevel warning
- ) ELSE (
- "%~dp0files\ffmpeg" -ss %starttime% -i %1 -y -c:v libx264 -preset ultrafast -qp 0 -t %rangeduration% "%dirTemp%\bat_cut.mkv" -loglevel warning
- )
- )
- "%plugindir%ffmsindex" -f "%dirTemp%\bat_cut.mkv"
- echo FFmpegSource2("%dirTemp%\bat_cut.mkv"^) >> "%dirTemp%\avs.avs"
- )
- :finish
- timeout /t 1 /nobreak >nul
- echo. & echo * * Opening resizer.html and AvsPmod & echo.
- "%~dp0files\resizer\index.html"
- type "%~dp0files\template.txt" >> "%dirTemp%\avs.avs"
- IF not exist "%~dp0output" mkdir "%~dp0output"
- "%~dp0files\AvsPmod\AvsPmod.exe" "%dirTemp%\avs.avs"
- "%~dp0files\vdub\vdub.exe" /i "%~dp0files\save_as_avi.vcf" "%dirTemp%\avs.avs" "%~dp0output\%fullstamp%.avi"
- :repeat
- echo.
- choice /C YN /T 10 /D N /M "Would you like to make another cut from this video?"
- IF %ERRORLEVEL% EQU 1 goto :datetime
- IF %ERRORLEVEL% EQU 2 echo. & echo All done. & echo.
- :end
- echo. & echo All done. Bye. & echo.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement