Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- cls
- title Encode Video
- rem "C:\Users\<Your Username>\OneDrive\System Tools\InPath\cmdow" @ /MOV 22 15 /SIZ 823 644
- rem https://gist.github.com/nico-lab/c2d192cbb793dfd241c1eafeb52a21c3
- mode con: cols=100 lines=35
- SETLOCAL ENABLEEXTENSIONS
- IF NOT [%2]==[] SET 2=%2
- IF NOT [%3]==[] SET 3=%3
- IF NOT [%4]==[] SET 4=%4
- IF NOT [%5]==[] SET 5=%5
- IF NOT [%6]==[] SET 6=%6
- rem To add an embedded cover/thumbnail:
- rem ffmpeg -i in.mkv -i IMAGE -map 0 -map 1 -c copy -c:v:1 png -disposition:v:1 attached_pic out.mkv
- IF [%1]==[] ( GOTO EOF )
- IF /I [%1]==[false] ( SET "DEF_COICE=(Y/n)" & SET "ANSWER=n" & SHIFT ) ELSE ( SET "DEF_COICE=(y/N)" & SET "ANSWER=y" )
- SET /P "VIEWVLC=View in VLC? %DEF_COICE% : "
- IF [%DEF_COICE%]==[y] START "" "C:\Program Files\VideoLAN\VLC\vlc.exe" "%~f1" & pause
- IF [%ANSWER%]==[n] ( IF /I "%VIEWVLC%" NEQ "n" START "" "C:\Program Files\VideoLAN\VLC\vlc.exe" "%~f1" & pause )
- rem SHIFT & SET /P "VIEWVLC=View in VLC? (y/N) : " & IF [%VIEWVLC%]==[y] START "" "C:\Program Files\VideoLAN\VLC\vlc.exe" "%~f1" & pause
- rem SET /P "VIEWVLC=View in VLC? (Y/n) : & IF /I "%VIEWVLC%" NEQ "n" (START "" "C:\Program Files\VideoLAN\VLC\vlc.exe" "%~f1" & pause
- rem :NOCHOICE
- SET "THREADS=4"
- c:
- cd C:\vc\autobuild\local64\bin-video
- title %~n1 in Recoding Que
- echo ...............................................................................
- echo %1
- ffprobe -v error -pretty -select_streams v:0 -show_entries stream=width,height,duration,bit_rate -of default=noprint_wrappers=1 %1
- rem reprobe -v error -pretty -select_streams v:0 -show_entries stream=r_frame_rate -of default=noprint_wrappers=1 %1 > frate.txt
- ffprobe -v error -pretty -select_streams v:0 -show_entries stream=width,height,duration,bit_rate -of default=noprint_wrappers=1 %1 > probe.txt
- findstr /B height probe.txt > probefind.txt
- SET /P height=<probefind.txt
- SET /P duration=<probefind.txt
- SET %height%
- SET %duration%
- echo ...............................................................................
- rem ----------------------------------------------------------------------------------------------------------------> Quick Picks ---- todo BATCH
- SET /P QUICKP=Quick Picks? (Y/n) :
- IF /I "%QUICKP%" EQU "n" (GOTO FULLCHOICE) ELSE ( echo..... )
- :QUICKPICK
- IF NOT [%height%]==[2160] ( echo 69 - SBS 2160 20k )
- IF NOT [%height%]==[2160] ( echo 68 - SBS 2160 15k )
- IF NOT [%height%]==[2160] ( echo 0 - SBS 2160 10k )
- IF NOT [%height%]==[2160] ( echo 1 - SBS 2160 9k )
- IF NOT [%height%]==[2160] ( echo 2 - SBS 2160 8k* )
- IF NOT [%height%]==[1440] ( echo 25 - SBS 1440 8k )
- IF NOT [%height%]==[1440] ( echo 3 - SBS 1440 7k )
- IF NOT [%height%]==[1440] ( echo 4 - SBS 1440 6k* )
- IF NOT [%height%]==[1440] ( echo 5 - SBS 1440 5k )
- IF NOT [%height%]==[1440] ( echo 6 - SBS 1440 xk )
- echo ..................
- echo 67 - Same Size 30k
- echo 66 - Same Size 25k
- echo 65 - Same Size 20k
- echo 64 - Same Size 15k
- echo 7 - Same Size 10k
- echo 8 - Same Size 9k
- echo 9 - Same Size 8k*
- echo 10 - Same Size 7k
- echo 11 - Same Size 6k*
- echo 12 - Same Size 5k
- echo ..................
- echo 13 - Remux to MP4
- echo 14 - Official FFMPEG
- echo 15 - scale_cuda
- echo ..................
- echo 16 - Give me the Choices
- echo ..................
- SET /P QUICKP=Choice :
- IF %QUICKP%==69 (SET "Y=2160" & SET "K=20000" & SET "M=7")
- IF %QUICKP%==68 (SET "Y=2160" & SET "K=15000" & SET "M=7")
- IF %QUICKP%==0 (SET "Y=2160" & SET "K=10000" & SET "M=7")
- IF %QUICKP%==1 (SET "Y=2160" & SET "K=9000" & SET "M=7")
- IF %QUICKP%==2 (SET "Y=2160" & SET "K=8000" & SET "M=7")
- IF %QUICKP%==25 (SET "Y=1440" & SET "K=8000" & SET "M=7")
- IF %QUICKP%==3 (SET "Y=1440" & SET "K=7000" & SET "M=7")
- IF %QUICKP%==4 (SET "Y=1440" & SET "K=6000" & SET "M=7")
- IF %QUICKP%==5 (SET "Y=1440" & SET "K=5000" & SET "M=7")
- IF %QUICKP%==6 (SET "Y=1440"
- SET /P K=k:
- SET /A K*=1000
- SET "M=7")
- IF %QUICKP%==67 (SET "K=30000" & SET "M=8" & GOTO JUMP_SCALE)
- IF %QUICKP%==66 (SET "K=25000" & SET "M=8" & GOTO JUMP_SCALE)
- IF %QUICKP%==65 (SET "K=20000" & SET "M=8" & GOTO JUMP_SCALE)
- IF %QUICKP%==64 (SET "K=15000" & SET "M=8" & GOTO JUMP_SCALE)
- IF %QUICKP%==7 (SET "K=10000" & SET "M=8" & GOTO JUMP_SCALE)
- IF %QUICKP%==8 (SET "K=9000" & SET "M=8" & GOTO JUMP_SCALE)
- IF %QUICKP%==9 (SET "K=8000" & SET "M=8" & GOTO JUMP_SCALE)
- IF %QUICKP%==10 (SET "K=7000" & SET "M=8" & GOTO JUMP_SCALE)
- IF %QUICKP%==11 (SET "K=6000" & SET "M=8" & GOTO JUMP_SCALE)
- IF %QUICKP%==12 (SET "K=5000" & SET "M=8" & GOTO JUMP_SCALE)
- IF %QUICKP%==13 (SET "M=13" & GOTO JUMP_SCALE)
- IF %QUICKP%==14 (echo "Set to retail ffmpeg" & cd "C:\Users\<Your Username>\OneDrive\System Tools\Utils\ffmpeg\bin" & SET "SCALE=scale" & SET "RFILTER= " & GOTO QUICKPICK )
- IF %QUICKP%==15 (echo "Set to Scale CUDA" & SET "SCALE=scale_cuda" & GOTO QUICKPICK)
- IF %QUICKP%==16 (GOTO FULLCHOICE)
- IF [%Y%]==[%height%] ( echo Can't encode to same height as source use Same Size & GOTO QUICKPICK )
- echo.....
- IF NOT DEFINED SCALE ( IF [%Y%] LSS [%height%] ( SET "DOWNFILTER=:interp_algo=super" ) ELSE ( SET "DOWNFILTER=" ) ) ELSE ( SET "DOWNFILTER=" )
- IF NOT DEFINED SCALE SET "SCALE=scale_npp"
- :JUMP_SCALE
- IF DEFINED Y (echo "%DATE%%TIME% %~n1 size:%Y% K:%K%" >> G:\Temp\jobs.log) ELSE (echo "%DATE%%TIME% %~n1 Same Size K:%K%" >> G:\Temp\jobs.log)
- rem sendkeys to desktop manager to resize all encoding windows
- "C:\Users\<Your Username>\OneDrive\System Tools\Batches\send-keys.vbs" "" "^+M"
- SET FORMAT=mp4
- SET AUDIO=n
- SET SUBTITLE=n
- SET APPEND_FN=y
- SET SECTION=N
- GOTO SETK
- IF [%2]==[] GOTO FULLCHOICE
- SET BATCH=FALSE
- IF DEFINED 2 IF %2 GTR 0 IF %2 LSS 15 (SET BATCH=TRUE)
- rem echo 1=%1 2=%2 3=%3 4=%4 5=%5 6=%6 Batch=%BATCH%
- rem pause
- IF [%BATCH%]==[TRUE] SET "M=%2" & SET "K=%3" & SET "AUDIO=%4" & SET "APPEND_FN=%5" & SET "NO_LOOP=TRUE" & SET "SUBTITLE=n" & GOTO SETK
- :FULLCHOICE
- echo .
- SET /P FORMAT=Choose Format (mkv/MP4)
- IF /I "%FORMAT%" NEQ "mkv" ( SET "FORMAT=mp4" ) ELSE ( SET "SUBTITLE=mkv" )
- echo .
- echo Recode using h265 NVENC %FORMAT%
- echo ....
- echo 1 - Video Wall (640x540 500k to 2000k)
- echo 2 - Home Video (Same Size, 1800k)
- echo 3 - Low (800x600 1000k to 2000k)
- echo 4 - Med (960x540 1500k to 3000k)
- echo 5 - High (1280×720 2000k to 4000k)
- echo 6 - HD (1920x1080 3???k to ????k)
- echo 7 - VR SBS (1440/2160) (5000k to ?k)
- echo 8 - Recode. Same size. (5??k to ????k)
- echo 9 - Recode. Different Size. ?(2300k)
- echo 10 - Add MP3 Audio, Copy Video.
- echo 11 - Convert Audio to MP3, Copy Video.
- echo 12 - Add Subtitles to Video.
- echo 13 - ReMux to mp4
- echo 14 - Recode GIF.
- echo 15 - GameTripe Cutscene.
- echo 16 - H264 recode.
- echo 17 - Video test for Vegas.
- echo 18 - Blank Audio Stream.
- echo 19 - Try Fix Corrupt Film.
- echo 20 - Use FFMPEG Official Release.
- echo ....
- SET /P M=Type 1 to 19:
- IF %M%==1 SET /P K=Enter bitrate in k:
- IF %M%==3 SET /P K=Enter bitrate in k:
- IF %M%==4 SET /P K=Enter bitrate in k:
- IF %M%==5 SET /P K=Enter bitrate in k:
- IF %M%==6 SET /P K=Enter bitrate in k:
- IF %M%==7 (echo ... & SET /P Y=Enter [1440 or 2160] 1440p 6000k is default: )
- IF %M%==7 (IF /I "%Y%" NEQ "2160" (IF /I "%Y%" NEQ "1440" ( SET "Y=1440" )))
- IF %M%==7 SET /P K=Enter Bitrate [5 to ?]000k:
- IF %M%==7 IF /I "%K%" EQU "" SET "K=6"
- IF %M%==7 SET /A "K=K*1000"
- IF %M%==8 SET /P K=Enter bitrate in k:
- IF %M%==9 SET /P K=Enter bitrate in k: & SET /P X=Width in Pixels: & SET /P Y=Height in Pixels:
- IF %M%==10 GOTO ADDMP3
- IF %M%==12 GOTO SUBTITLE
- IF %M%==13 GOTO REMUX
- IF %M%==14 GOTO RECODE_GIF
- IF %M%==19 GOTO FIXFILM
- IF %M%==20 ( cd "C:\Users\<Your Username>\OneDrive\System Tools\Utils\ffmpeg\bin" & SET "SCALE=scale" & SET "RFILTER= " & GOTO FULLCHOICE )
- IF %M% GTR 9 (SET AUDIO=Y) & (SET TWOPASS=N) & GOTO JUMP_K
- :SETK
- SET /A "VBUFF = K * 2"
- SET /A "MAXRATE = K + 10000
- IF NOT DEFINED AUDIO SET /P AUDIO=Recode Audio? (y/N):
- :JUMP_K
- IF /I "%AUDIO%" EQU "y" (SET AUDIO_STRING=a libmp3lame -ar 48000 -ab 192k -ac 2) ELSE ( SET "AUDIO_STRING=a copy" )
- IF NOT DEFINED SUBTITLE SET /P SUBTITLE=Copy Subtitle? (y/N):
- IF /I "%SUBTITLE%" EQU "y" ( SET "SUBTITLE=-c:s mov_text" ) ELSE ( SET "SUBTITLE=" )
- IF NOT DEFINED APPEND_FN SET /P APPEND_FN=Append to Filename? (Y/n):
- IF /I "%APPEND_FN%" EQU "n" ( SET "APPEND_FILENAME=" ) ELSE ( SET "APPEND_FILENAME=_ffmeg" )
- IF NOT DEFINED SECTION SET /P SECTION=Only Encode a Section? (y/N)
- IF [%SECTION%]==[y] (
- echo Media Duration: %duration%
- SET /P SEC_START=Start @:
- SET /P SEC_END=End @:
- SET SECTION = -ss %SEC_START% -to %SEC_END%
- ) ELSE ( SET "SECTION=" )
- mode con: cols=110 lines=8
- :LOOP
- echo File = %1
- echo Waiting for encoding to complete...
- :CHECKFORFILE
- echo | SET /p=.
- IF DEFINED LOOPING ( GOTO SKIPTEST )
- IF NOT EXIST "%~dp1Encoding.txt" (GOTO NOTTHERE)
- TIMEOUT /T 60 > nul
- GOTO CHECKFORFILE
- :NOTTHERE
- echo %~n1 > "%~dp1Encoding.txt"
- IF [%M%]==[13] GOTO JUMP_SLEEP
- SET /A "SLEEP_RND=%RANDOM% * 10 / 32768 + 1"
- echo Sleeping for %SLEEP_RND%
- TIMEOUT /T %SLEEP_RND%
- :JUMP_SLEEP
- SET /p FILE_TEST=<"%~dp1Encoding.txt"
- rem echo Testing "%~n1 " equals "%FILE_TEST%" not going back to check file
- IF "%~n1 " NEQ "%FILE_TEST%" (del "%~dp1Encoding.txt" GOTO CHECKFORFILE)
- :SKIPTEST
- title %~n1 - Encoding
- "C:\Users\<Your Username>\OneDrive\System Tools\InPath\cmdow" @ /TOP
- "C:\Users\<Your Username>\OneDrive\System Tools\InPath\cmdow" @ /NOT
- IF %M%==1 GOTO VIDEOWALL
- IF %M%==2 GOTO HOMEVIDEO
- IF %M%==3 GOTO LOW
- IF %M%==4 GOTO MED
- IF %M%==5 GOTO HIGH
- IF %M%==6 GOTO HD
- IF %M%==7 GOTO VRSBS
- IF %M%==8 GOTO RECODE
- IF %M%==9 GOTO RECODE_RESIZE
- IF %M%==10 GOTO ADDMP3
- IF %M%==11 GOTO MP3
- IF %M%==12 GOTO SUBTITLE
- IF %M%==13 GOTO REMUX
- IF %M%==14 GOTO RECODE_GIF
- IF %M%==15 GOTO WITCHERCS
- IF %M%==16 GOTO H264
- IF %M%==17 GOTO VEGAS
- IF %M%==18 GOTO BLANKAUDIO
- IF %M%==19 GOTO FIXFILM
- GOTO EOF
- rem ---------------------------------------------------------------------------------------------------------------------------------> Work Items
- :VIDEOWALL
- echo VideoWall
- ffmpeg -i %1 -vcodec hevc_nvenc -vf scale=w=640:h=540:force_original_aspect_ratio=decrease -preset:v slow -profile:v main -rc vbr -tune 1 -rc-lookahead:v 256 -qmin:v 1 -qmax:v 50 -b:v %K%k -c:%AUDIO_STRING% -map_metadata 0:s:0 "%~dpn1%APPEND_FILENAME%.%FORMAT%"
- GOTO NEXT
- :HOMEVIDEO
- echo Home Video
- ffmpeg -threads %THREADS% -hwaccel_output_format cuda -i %1 -map_metadata 0 -c:v hevc_nvenc -preset:v slow -profile:v main -rc vbr -tune 1 -rc-lookahead:v 256 -qmin:v 15 -qmax:v 52 -b:v 1800k -bufsize:v 3600k -maxrate:v 2800k -spatial_aq:v 1 -aq-strength:v 15 -c:a libmp3lame -ar 48000 -ab 192k -ac 2 "%~dpn1_enc.mp4"
- if errorlevel 1 goto ERRORNEXT
- Recycle -f %1
- move "%~dpn1_enc.mp4" "%~dpn1.mp4"
- echo .
- echo ** Success **
- echo .
- rem @echo %1>> "C:\Users\<Your Username>\OneDrive\System Tools\Utils\ffmpeg\bin\homevideo_log.txt"
- :ERRORNEXT
- if exist "%~dpn1_enc.mp4" del "%~dpn1_enc.mp4"
- GOTO NEXT
- :LOW
- echo Quality Low
- ffmpeg -i %1 -vcodec hevc_nvenc -vf scale=w=800:h=600:force_original_aspect_ratio=decrease -preset:v slow -profile:v main -rc vbr -tune 1 -rc-lookahead:v 256 -qmin:v 1 -qmax:v 50 -b:v %K%k -c:%AUDIO_STRING% -map_metadata 0:s:0 "%~dpn1%APPEND_FILENAME%.%FORMAT%"
- GOTO NEXT
- :MED
- echo Quality Medium
- ffmpeg -i %1 -vcodec hevc_nvenc -vf scale=w=960:h=540:force_original_aspect_ratio=decrease -preset:v slow -profile:v main -rc vbr -tune 1 -rc-lookahead:v 256 -qmin:v 1 -qmax:v 50 -b:v %K%k -c:%AUDIO_STRING% -map_metadata 0:s:0 "%~dpn1%APPEND_FILENAME%.%FORMAT%"
- GOTO NEXT
- :HIGH
- echo Quality High
- ffmpeg -i %1 -vcodec hevc_nvenc -vf scale=w=1280:h=720:force_original_aspect_ratio=decrease -preset:v slow -profile:v main -rc vbr -tune 1 -rc-lookahead:v 256 -qmin:v 1 -qmax:v 50 -b:v %K%k -c:%AUDIO_STRING% -map_metadata 0:s:0 "%~dpn1%APPEND_FILENAME%.%FORMAT%"
- GOTO NEXT
- :HD
- echo Quality High Defination
- ffmpeg -i %1 -vcodec hevc_nvenc -vf scale=w=1920:h=1080:force_original_aspect_ratio=decrease -preset:v slow -profile:v main -rc vbr -tune 1 -rc-lookahead:v 256 -qmin:v 1 -qmax:v 50 -b:v %K%k -c:%AUDIO_STRING% -map_metadata 0:s:0 "%~dpn1%APPEND_FILENAME%.%FORMAT%"
- GOTO NEXT
- :VRSBS
- rem 2 VR Standards so far ****************************************************************************************VR ENCODE
- echo .........................................................................
- echo Quality VR Film High Def Varable Bitrate
- IF [%Y%]==[1080] SET "X=2160" ELSE IF [%Y%]==[1440] SET "X=2880" & SET "Y=%Y% ELSE IF [%Y%]==[2160] SET "X=4320"
- echo K=%K% X=%X% Y=%Y% VBUFF=%VBUFF% MAXRATE=%MAXRATE%
- echo .........................................................................
- IF NOT DEFINED SCALE ( SET "SCALE=scale_npp" )
- IF NOT DEFINED RFILTER ( SET "RFILTER=hwupload_cuda," )
- IF NOT DEFINED DOWNFILTER ( SET "DOWNFILTER=" )
- SET "RESIZE=%SCALE%=w=-1:h=%Y%%DOWNFILTER%"
- REM NVIDIA BUG WORKAROUND -extra_sei 0 (placed before SUBTITLE)
- echo ffmpeg -hwaccel_output_format cuda -vsync 0 -y %SECTION% -i %1 -threads %THREADS% -vf "%RFILTER%%RESIZE%" -vcodec hevc_nvenc -preset:v slow -profile:v main -rc vbr -tune 1 -rc-lookahead 1024 -qmin:v 15 -qmax:v 52 -bf 3 -b_ref_mode middle -temporal-aq 1 -vsync 0 -refs:v 16 -b:v %K%k -bufsize %VBUFF%k -maxrate %MAXRATE%k -extra_sei 0 %SUBTITLE% -c:%AUDIO_STRING% -map_metadata 0:s:0 "%~dpn1%APPEND_FILENAME%.%FORMAT%"
- echo .........................................................................
- ffmpeg -hwaccel_output_format cuda -vsync 0 -y %SECTION% -i %1 -threads %THREADS% -vf "%RFILTER%%RESIZE%" -vcodec hevc_nvenc -preset:v slow -profile:v main -rc vbr -tune 1 -rc-lookahead 1024 -qmin:v 15 -qmax:v 52 -bf 3 -b_ref_mode middle -temporal-aq 1 -vsync 0 -refs:v 16 -b:v %K%k -bufsize %VBUFF%k -maxrate %MAXRATE%k -extra_sei 0 %SUBTITLE% -c:%AUDIO_STRING% -map_metadata 0:s:0 "%~dpn1%APPEND_FILENAME%.%FORMAT%"
- SET ERR_PAUSE=%ERRORLEVEL%
- set filename="path\to\file.txt"
- set file_size=""
- for /F %%A in (%filename%) do set "file_size=%%~zA"
- GOTO NEXT
- :RECODE
- rem recode no size
- echo Recode,Same Size. Varable Bitrate. k=%k% maxrate=%MAXRATE% buffer=%VBUFF%
- echo .........................................................................
- echo ffmpeg -threads %THREADS% -hwaccel_output_format cuda %SECTION% -i %1 -map_metadata 0 -c:v hevc_nvenc -preset slow -profile:v main -rc vbr -tune 1 -rc-lookahead 1024 -qmin 15 -qmax 52 -bf 3 -b_ref_mode middle -temporal-aq 1 -vsync 0 -refs 16 -b:v %K%k -bufsize:v %VBUFF%k -maxrate:v %MAXRATE%k %SUBTITLE% -c:%AUDIO_STRING% "%~dpn1%APPEND_FILENAME%.%FORMAT%"
- ffmpeg -threads %THREADS% -hwaccel_output_format cuda %SECTION% -i %1 -map_metadata 0 -c:v hevc_nvenc -preset slow -profile:v main -rc vbr -tune 1 -rc-lookahead 1024 -qmin 15 -qmax 52 -bf 3 -b_ref_mode middle -temporal-aq 1 -vsync 0 -refs 16 -b:v %K%k -bufsize:v %VBUFF%k -maxrate:v %MAXRATE%k %SUBTITLE% -c:%AUDIO_STRING% "%~dpn1%APPEND_FILENAME%.%FORMAT%"
- SET ERR_PAUSE=%ERRORLEVEL%
- IF [%ERR_PAUSE%]==[1] (del "%~dpn1%APPEND_FILENAME%.%FORMAT%")
- :RECODE_RESIZE
- rem recode with size
- IF NOT DEFINED SCALE ( SET "SCALE=scale_npp" )
- echo Recode,Different Size. Varable Bitrate.
- echo ffmpeg -threads %THREADS% -hwaccel_output_format cuda %SECTION% -i %1 -map_metadata 0 -vcodec hevc_nvenc -vf %SCALE%=w=%X%:h=%Y%:force_original_aspect_ratio=decrease -preset:v slow -profile:v main -rc vbr -tune 1 -rc-lookahead:v 256 -qmin:v 15 -qmax:v 52 -b:v %K%k -bufsize:v %VBUFF%k -maxrate:v %MAXRATE%k -spatial_aq:v 1 -aq-strength:v 15 -c:%AUDIO_STRING% -map_metadata 0:s:0 "%~dpn1%APPEND_FILENAME%.%FORMAT%"
- ffmpeg -threads %THREADS% -hwaccel_output_format cuda %SECTION% -i %1 -map_metadata 0 -vcodec hevc_nvenc -vf %SCALE%=w=%X%:h=%Y%:force_original_aspect_ratio=decrease -preset:v slow -profile:v main -rc vbr -tune 1 -rc-lookahead:v 256 -qmin:v 15 -qmax:v 52 -b:v %K%k -bufsize:v %VBUFF%k -maxrate:v %MAXRATE%k -spatial_aq:v 1 -aq-strength:v 15 -c:%AUDIO_STRING% -map_metadata 0:s:0 "%~dpn1%APPEND_FILENAME%.%FORMAT%"
- SET ERR_PAUSE=%ERRORLEVEL%
- IF [%ERR_PAUSE%]==[1] (del "%~dpn1%APPEND_FILENAME%.%FORMAT%")
- GOTO NEXT
- :DEBLOCK
- rem recode & deblock
- echo Recode with Deblock.
- echo ffmpeg -threads %THREADS% -hwaccel_output_format cuda %SECTION% -i %1 -map_metadata 0 -vcodec hevc_nvenc -preset:v slow -profile:v main -rc vbr -tune 1 -rc-lookahead:v 256 -qmin:v 1 -qmax:v 50 -b:v %K%k -vf deblock=filter=weak:block=4 -c:%AUDIO_STRING% -map_metadata 0:s:0 "%~dpn1%APPEND_FILENAME%.%FORMAT%"
- ffmpeg -threads %THREADS% -hwaccel_output_format cuda %SECTION% -i %1 -map_metadata 0 -vcodec hevc_nvenc -preset:v slow -profile:v main -rc vbr -tune 1 -rc-lookahead:v 256 -qmin:v 1 -qmax:v 50 -b:v %K%k -vf deblock=filter=weak:block=4 -c:%AUDIO_STRING% -map_metadata 0:s:0 "%~dpn1%APPEND_FILENAME%.%FORMAT%"
- GOTO NEXT
- :ADDMP3
- echo ReMux with MP3 audio track stream 2, preserving existing audio stream.
- ffmpeg -threads %THREADS% -hwaccel_output_format cuda -i %1 -b:a libmp3lame -ar 48000 -ab 192k -ac 2 -vn "%~dpn1.audio.mp3"
- ffmpeg -threads %THREADS% -hwaccel_output_format cuda -i %1 -map_metadata 0 -i "%~dpn1.audio.mp3" -map 0:0 -c copy -map 1:0 -c copy -map 0:1 -c copy -map 0:2? -c copy -map 0:3? -c copy "%~dpn1.edit.%FORMAT%"
- del "%~dpn1.audio.mp3"
- GOTO NEXT
- :MP3
- echo Same Video, Recode audio to MP3
- ffmpeg -threads %THREADS% -hwaccel_output_format cuda -i %1 -map_metadata 0 -c:v copy -c:%AUDIO_STRING% "%~dpn1%APPEND_FILENAME%.%FORMAT%"
- GOTO NEXT
- :SUBTITLE
- echo Add subtitle to Video
- SET /P SUB_FILE=Drag Drop Subtitle File:
- echo ffmpeg -threads %THREADS% -hwaccel_output_format cuda -i %1 -i %SUB_FILE% -map 0 -map 1:0 -c:s mov_text "%~dpn1.subtitle.%FORMAT%"
- ffmpeg -threads %THREADS% -hwaccel_output_format cuda -i %1 -i %SUB_FILE% -map 0 -map 1:0 -c:s mov_text "%~dpn1.subtitle.%FORMAT%"
- SET "SUB_FILE="
- GOTO NEXT
- :REMUX
- IF NOT DEFINED DESTINATION ( CHOICE /T 3 /C sr /CS /D s /M "Destination - Same Folder (S) or Ram Disk (r) (S/r): " )
- IF [%ERRORLEVEL%]==[2] ( SET "DESTINATION=R:\%~n1.mp4" ) ELSE ( SET "DESTINATION=%~dpn1.remux.mp4" )
- SET "ERRORLEVEL="
- rem TODO: Following does not work, crashes batch file with no error
- rem IF EXIST %DESTINATION% ( SET "DESTINATION=%DESTINATION%~dpn1.dup.mp4" )
- echo ffmpeg -threads %THREADS% -i %1 -sn -map 0 -c copy "%DESTINATION%"
- ffmpeg -threads %THREADS% -i %1 -sn -map 0 -c copy "%DESTINATION%"
- SET ERR_PAUSE=%ERRORLEVEL%
- GOTO NEXT
- :RECODE_GIF
- echo ffmpeg -strict -1 -i %1 -vcodec hevc_nvenc -preset:v slow -profile:v main -rc vbr -tune 1 -rc-lookahead:v 256 -qmin:v 15 -qmax:v 50 -b:v 2000k -bufsize:v 4000k -maxrate:v 4000k -c:a aac -shortest 0 "%~dpn1_enc.mp4"
- ffmpeg -strict -1 -f lavfi -i anullsrc=channel_layout=stereo:sample_rate=44100 -i %1 -vcodec hevc_nvenc -preset:v slow -profile:v main -rc vbr -tune 1 -rc-lookahead:v 256 -qmin:v 15 -qmax:v 50 -b:v 2000k -bufsize:v 4000k -maxrate:v 4000k -c:a aac -shortest 0 "%~dpn1_enc.mp4"
- GOTO NEXT
- :WITCHERCS
- echo Super Compressed for Witcher Shortlist
- ffmpeg -i %1 -vcodec hevc_nvenc -vf scale=w=640:h=480:force_original_aspect_ratio=decrease -profile:v main -rc vbr -tune 1 -rc-lookahead:v 256 -qmin:v 1 -qmax:v 50 -b:v 400k -c:%AUDIO_STRING% -map_metadata 0:s:0 "%~dpn1_e%APPEND_FILENAME%.%FORMAT%"
- del %1
- GOTO NEXT
- :H264
- echo Recoding into H264
- ffmpeg -i %1 -vcodec libx264 -preset slow -crf 22 -c:%AUDIO_STRING% "%~dpn1%APPEND_FILENAME%.%FORMAT%"
- GOTO NEXT
- :VEGAS
- echo Video for VEGAS.
- ffmpeg -threads %THREADS% -hwaccel_output_format cuda -i %1 -vcodec libx264 -vf scale=w=640:h=480:force_original_aspect_ratio=decrease -profile:v main -rc vbr -tune 1 -rc-lookahead:v 256 -qmin:v 1 -qmax:v 50 -b:v 400k -c:%AUDIO_STRING% -map_metadata 0:s:0 "%~dpn1_v%APPEND_FILENAME%.%FORMAT%"
- GOTO NEXT
- :BLANKAUDIO
- echo Add a black Audio track to Video.
- ffmpeg -f lavfi -i anullsrc=channel_layout=stereo:sample_rate=44100 -i %1 -c:v copy -c:a aac -shortest -map_metadata 0:s:0 "%~dpn1_v.blank-audio.%FORMAT%"
- GOTO NEXT
- :FIXFILM
- echo attempt fix video
- echo ffmpeg -i %1 -c:v copy -c:a copy "%~dpn1_v.fixed.%FORMAT%"
- ffmpeg -i %1 -c:v copy -c:a copy "%~dpn1_v.fixed.%FORMAT%"
- GOTO NEXT
- rem --------------------------------------------------------------------------------------------------------------------------------> END OR LOOP
- :NEXT
- del "%~dp1Encoding.txt"
- IF DEFINED NO_LOOP GOTO EOF
- echo Encoded %1 >> "C:\Users\<Your Username>\OneDrive\System Tools\Utils\ffmpeg\bin\log.txt"
- SHIFT
- IF NOT [%1]==[] ( SET "LOOPING=true" & GOTO LOOP )
- :EOF
- IF DEFINED SLEEP (IF [%SLEEP%] == [y] (START "" "C:/Users/<Your Username>/OneDrive/System Tools/System/SysInternals/psshutdown.exe" -d -t 0))
- IF [%ERR_PAUSE%]==[1] (PAUSE) ELSE (ECHO Complete)
- rem PAUSE
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement