Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- rem # notes:
- rem ffmpeg -ss 626.5 -i HDPVR2_20191014_0321.mkv -acodec copy -vf pp7=3,fftdnoiz=10:prev=1:next=1 -vcodec rawvideo -f nut - | mpv -profile=low-latency -really-quiet -fs -
- if "%~1"=="" (
- echo "drop one or more video files onto this batch-file"
- pause
- goto :eof
- )
- :loop
- rem
- rem # config begin // last assignment wins
- rem # ---------------
- set "crf=28"
- set "preset=slower"
- set "preset=medium"
- set "preset=veryslow"
- set "filters=pp7=3,vaguedenoiser=4"
- set "filters=pp7=3"
- set "filters=copy"
- set "filters=pp7=3,fftdnoiz=10:prev=1:next=1"
- rem # backslash-terminated output path; %~dp1 is the source folder
- set "outdir=%~dp1"
- set "outdir=%userprofile%\enc\"
- rem # ---------------
- rem # config end
- rem
- rem output file
- rem set "ofn=%~dpn1.h265.mkv"
- rem set "ofn=%~f1.h265-%preset%%crf%.mkv"
- set "ofn=%outdir%%~nx1.h265-%preset%%crf%.mkv"
- rem don't overwrite
- if exist "%ofn%" goto nextfile
- mkdir "%ofn%.lock" || goto nextfile
- echo "processing [%~1]"
- echo "writing to [%ofn%]"
- rem escape : and \ for ffmpeg
- set "fp=%ofn%.log"
- set "fp=%fp:\=\\%"
- set "fp=%fp::=\:%"
- set "FFREPORT=level=32:file=%fp%"
- rem escape \ for wmic
- set "wp=%~f1"
- set "wp=%wp:\=\\%"
- for /f %%a in (
- 'wmic DataFile where "Name='%wp%'" get LastModified ^| find "."'
- ) do set "lastmod=%%a"
- rem debug
- rem echo %FFREPORT%
- rem echo %lastmod%
- rem goto :eof
- rem -vf scale=1280:-4
- ffmpeg -hide_banner -vsync vfr -i "%1" -map 0:v -map 0:a -codec copy -vf "%filters%" -vcodec libx265 -crf %crf% -preset %preset% -pix_fmt yuv420p -max_muxing_queue_size 99999 "%ofn%"
- echo( >> "%ofn%.log"
- echo x265ify.bat: original file last-modified %lastmod% (%~t1), size %~z1 >> "%ofn%.log"
- rmdir "%ofn%.lock"
- :nextfile
- shift
- if not "%~1"=="" goto loop
- rem pause
- REM %~f1 c:\foo\bar\baz.qux # abspath == %~dpnx1
- REM %~d1 c: # drive
- REM %~p1 \foo\bar\ # path
- REM %~n1 baz # name
- REM %~x1 .qux # ext
- REM %~t1 # last-modified-timestamp
- REM %~z1 # file-size
- REM %~a1 # file-attributes
- REM %~sn1 # 8.3
- REM
- REM foo.bar > foo_new.bar > %~dpn1_new%~x1
- REM
- REM quotes around entire argument to 'set' is best practice (prevents whitespace memes)
- REM
- REM always escape ^ & < > | \ ! with ^
- REM also end a batch-file with a ^ to cause memory leaks lol
- REM
- REM if [%1]==[] works on " but fails on whitespace
- REM if "%1"=="" fails on " but works on whitespace
- REM if "%~1"=="" works? i think
Advertisement
Add Comment
Please, Sign In to add comment