Browser view only. Use the download link if you want to save the file.
Back to Toolbox@echo off
set VAR_MP4=0
set VAR_X265=0
set VAR_MPEG1=0
set VAR_MP3=0
:: set all the commands to comments to start
set makeMP1=rem
set makeMP4=rem
set makeMP3=rem
set makeMKV=rem
set makeARC=rem
set makeJOE=rem
:: settings for MP4/MKV/MP1 generation
set quality=sameq
set MP4sizestring=720p
set MP4scale=-s 1280x720
set MP1scale=-s 720x480
set MP1sizestring=480p
set MKVscale=
set MKVsizestring=1080p
:: boost volume or add an audio fix
rem set voltweak=-af volume=1.50
set voltweak=
set afix=
:menu
cls
echo Toggle Environment Variables
echo ---------------------------
:: check if any are on, so we can quit if needed
set oneison=0
if %VAR_MP4%==1 set oneison=1
if %VAR_MP4%==2 set oneison=1
if %VAR_X265%==1 set oneison=1
if %VAR_MPEG1%==1 set oneison=1
if %VAR_MP3%==1 set oneison=1
if %VAR_MP4%==0 echo 4 - Toggle MP4 720p ( )
if %VAR_MP4%==1 echo 4 - Toggle MP4 720p (x)
if %VAR_MP4%==2 echo 4 - Toggle MP4 1080p (x)
if %VAR_X265%==0 echo X - Toggle x265 ( )
if %VAR_X265%==1 echo X - Toggle x265 (x)
if %VAR_MPEG1%==0 echo 1 - Toggle Mpeg1 ( )
if %VAR_MPEG1%==1 echo 1 - Toggle Mpeg1 (x)
if %VAR_MP3%==0 echo 3 - Toggle MP3 ( )
if %VAR_MP3%==1 echo 3 - Toggle MP3 (x)
echo.
echo G - GO / Start
echo Q - Quit
echo.
choice /c 41X3GQ /n /m "Choose an option: "
if errorlevel 6 goto :eof
if errorlevel 5 goto :startit
if errorlevel 4 goto :e4
if errorlevel 3 goto :e3
if errorlevel 2 goto :e2
if errorlevel 1 goto :e1
:e4
set currentval=%VAR_MP3%
set makeMP3=rem
if %currentval%==1 set VAR_MP3=0
if %currentval%==1 set makeMP3=rem
if %currentval%==0 set VAR_MP3=1
if %currentval%==0 set makeMP3=ffmpeg
goto menu
:e3
set currentval=%VAR_X265%
set makeARC=rem
if %currentval%==1 set VAR_X265=0
if %currentval%==1 set makeARC=rem
if %currentval%==0 set VAR_X265=1
if %currentval%==0 set makeARC=ffmpeg
goto menu
:e2
set currentval=%VAR_MPEG1%
set makeMP1=rem
if %currentval%==1 set VAR_MPEG1=0
if %currentval%==1 set makeMP1=rem
if %currentval%==0 set VAR_MPEG1=1
if %currentval%==0 set makeMP1=ffmpeg
goto menu
:e1
set currentval=%VAR_MP4%
set makeMP4=rem
if %currentval%==2 set VAR_MP4=0
if %currentval%==2 set makeMP4=rem
if %currentval%==1 set VAR_MP4=2
if %currentval%==1 set makeMP4=ffmpeg
if %currentval%==0 set VAR_MP4=1
if %currentval%==0 set makeMP4=ffmpeg
goto menu
goto :menu
:startit
if x%oneison%x == x0x echo Nothing to do. Exiting.
if x%oneison%x == x0x goto end2
echo Starting...
rem Add your code to execute when 'G' is selected (jumped to :startit)
echo.
SET /P witname=Witness name ?
echo.
echo. >mylist.txt
echo file '%~1'>>mylist.txt
IF NOT "%~2" == "" echo file '%~2'>>mylist.txt
IF NOT "%~3" == "" echo file '%~3'>>mylist.txt
IF NOT "%~4" == "" echo file '%~4'>>mylist.txt
IF NOT "%~5" == "" echo file '%~5'>>mylist.txt
IF NOT "%~6" == "" echo file '%~6'>>mylist.txt
IF NOT "%~7" == "" echo file '%~7'>>mylist.txt
IF NOT "%~8" == "" echo file '%~8'>>mylist.txt
IF NOT "%~9" == "" echo file '%~9'>>mylist.txt
::echo Joining these files:
::echo. DEBUG: showing mylist:
::type mylist.txt
::timeout /t 4
echo.
echo Joining these files:
echo.
echo %~nx1
IF NOT "%~2" == "" echo %~nx2
IF NOT "%~3" == "" echo %~nx3
IF NOT "%~4" == "" echo %~nx4
IF NOT "%~5" == "" echo %~nx5
IF NOT "%~6" == "" echo %~nx6
IF NOT "%~7" == "" echo %~nx7
IF NOT "%~8" == "" echo %~nx8
IF NOT "%~9" == "" echo %~nx9
echo.
set afterclean=0
if not exist cleanuptools.bat goto nocleanprompt
echo.
choice /c qyn /n /m "Want to clean off tools afterwards? "
if errorlevel 3 goto cleanNO
if errorlevel 2 goto cleanYES
if errorlevel 1 goto end2
goto cleanNO
:nocleanprompt
timeout /t 5
goto afterdelay
:cleanYES
set afterclean=1
:cleanNO
:afterdelay
set joinedfile=joined%~x1
if not exist %joinedfile% goto firstrun
echo.
echo. %joinedfile% exists. Trying next name...
echo.
timeout /t 4 >nul
set joinedfile=joined2%~x1
if not exist %joinedfile% goto firstrun
echo.
echo. %joinedfile% exists. Trying next name...
echo.
timeout /t 4 >nul
set joinedfile=joined3%~x1
if not exist %joinedfile% goto firstrun
echo.
echo. %joinedfile% exists. Aborting...
echo.
timeout /t 4 >nul
goto end
:firstrun
title Concatting files to %joinedfile% ...
ffmpeg -f concat -safe 0 -i "mylist.txt" -c copy %joinedfile%
set didsomething=1
if /I x%~x1x == x.mkvx set ext=MKV
if /I x%~x1x == x.mp4x set ext=MP4
if /I x%~x1x == x.mtsx set ext=MTS
if /I x%~x1x == x.movx set ext=MOV
title Moving originals to backup folder...
md "orig %ext% files"
move %1 "orig %ext% files"
move %2 "orig %ext% files"
move %3 "orig %ext% files"
move %4 "orig %ext% files"
move %5 "orig %ext% files"
move %6 "orig %ext% files"
move %7 "orig %ext% files"
move %8 "orig %ext% files"
move %9 "orig %ext% files"
del mylist.txt >nul
:: get duration for joined file
for /F "delims=" %%I in ('ffprobe.exe -v error -show_entries format^=duration -sexagesimal -of default^=noprint_wrappers^=1:nokey^=1 "%joinedfile%" 2^>^&1') do set "duration2=%%I"
rem echo Duration2 is: %duration2%
title Converting %witname% to MP3 format (len=%duration2%)...
%makeMP3% -i %joinedfile% -f mp3 -vn -ar 48000 -ac 2 -ab 96k %afix% %voltweak% "%witname%.mp3"
if [%VAR_MP4%] == [2] set MP4sizestring=1080p
if [%VAR_MP4%] == [2] set MP4scale=-s 1920x1080
title Converting %witname% to MP4 format (%MP4sizestring%) (len=%duration2%)...
%makeMP4% -i %joinedfile% %qstring% %MP4scale% -pix_fmt yuv420p %afix% %voltweak% "%witname%.%MP4sizestring%.%quality%.mp4"
title Converting %witname% to MPEG-1 format (%MP1sizestring%) (len=%duration2%)...
%makeMP1% -i %joinedfile% -f mpeg -r 29.97 -f mpeg -r 29.97 -write_tmcd 0 -pix_fmt yuv420p -s 720:480 %forceaspect% -b:v 1800k -maxrate 1800k -minrate 1800k -bufsize 1000k -sws_flags lanczos -g 15 -ab 128k %afix% %voltweak% "%witname%.mpg"
title Converting %witname% to MKV format (%MKVsizestring%) (len=%duration2%)...
%makeMKV% -i %joinedfile% -c:v libx265 -preset superfast -r 29.97 %qstring% %MKVscale% -ar 48000 -c:a aac -b:a 256k %afix% %voltweak% "%witname%.mkv"
title Converting %witname% to MKV format (Noscale) (len=%duration2%)...
%makeARC% -i %joinedfile% -c:v libx265 -preset superfast -r 29.97 -crf 18 -ar 48000 -c:a aac -b:a 256k %afix% %voltweak% "%witname%.noscale.crf18.mkv"
goto end
:error1
echo Usage: %~n0 [file1 file2 file3 ... ] for concat and convert
echo.
echo Spaces in filenames are now supported!
echo.
timeout /t 4
goto end2
:error2
echo Whoa! We need FFmpeg.exe and FFprobe.exe here!
echo.
echo.
timeout /t 4
goto end2
:error3
echo Whoa! We need FFprobe.exe here too!
echo.
echo.
timeout /t 4
goto end2
:error4
echo Whoa! This only works in Windows 10!
echo.
echo.
timeout /t 4
goto end2
:end
del "== MERGE CONVERT RUNNING ==" >nul
del %joinedfile%
if x%afterclean%x == x1x cleanuptools.bat
if x%didsomething%x == x0x goto end2
title %witname% done!
cls
echo.
echo.
echo. *******************
echo. *** ALL DONE!!! ***
echo. *******************
echo.
echo.
timeout /t 6
:end2