mkv

x265ify.bat

mkv
Jan 16th, 2020
487
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 2.46 KB | None | 0 0
  1. @echo off
  2.  
  3. rem # notes:
  4. 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 -
  5.  
  6. if "%~1"=="" (
  7.     echo "drop one or more video files onto this batch-file"
  8.     pause
  9.     goto :eof
  10. )
  11. :loop
  12.  
  13. rem
  14. rem # config begin // last assignment wins
  15. rem # ---------------
  16.  
  17. set "crf=28"
  18.  
  19. set "preset=slower"
  20. set "preset=medium"
  21. set "preset=veryslow"
  22.  
  23. set "filters=pp7=3,vaguedenoiser=4"
  24. set "filters=pp7=3"
  25. set "filters=copy"
  26. set "filters=pp7=3,fftdnoiz=10:prev=1:next=1"
  27.  
  28. rem # backslash-terminated output path; %~dp1 is the source folder
  29. set "outdir=%~dp1"
  30. set "outdir=%userprofile%\enc\"
  31.  
  32. rem # ---------------
  33. rem # config end
  34. rem
  35.  
  36. rem output file
  37. rem set "ofn=%~dpn1.h265.mkv"
  38. rem set "ofn=%~f1.h265-%preset%%crf%.mkv"
  39. set "ofn=%outdir%%~nx1.h265-%preset%%crf%.mkv"
  40.  
  41. rem don't overwrite
  42. if exist "%ofn%" goto nextfile
  43. mkdir "%ofn%.lock" || goto nextfile
  44.  
  45. echo "processing [%~1]"
  46. echo "writing to [%ofn%]"
  47.  
  48. rem escape : and \ for ffmpeg
  49. set "fp=%ofn%.log"
  50. set "fp=%fp:\=\\%"
  51. set "fp=%fp::=\:%"
  52. set "FFREPORT=level=32:file=%fp%"
  53.  
  54. rem escape \ for wmic
  55. set "wp=%~f1"
  56. set "wp=%wp:\=\\%"
  57.  
  58. for /f %%a in (
  59.     'wmic DataFile where "Name='%wp%'" get LastModified ^| find "."'
  60. ) do set "lastmod=%%a"
  61.  
  62. rem debug
  63. rem echo %FFREPORT%
  64. rem echo %lastmod%
  65. rem goto :eof
  66.  
  67. rem -vf scale=1280:-4
  68. 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%"
  69.  
  70. echo( >> "%ofn%.log"
  71. echo x265ify.bat: original file last-modified %lastmod% (%~t1), size %~z1 >> "%ofn%.log"
  72.  
  73. rmdir "%ofn%.lock"
  74.  
  75. :nextfile
  76. shift
  77. if not "%~1"=="" goto loop
  78. rem pause
  79.  
  80. REM %~f1 c:\foo\bar\baz.qux  # abspath == %~dpnx1
  81. REM %~d1 c:                  # drive
  82. REM %~p1   \foo\bar\         # path
  83. REM %~n1            baz      # name
  84. REM %~x1               .qux  # ext
  85. REM %~t1 # last-modified-timestamp
  86. REM %~z1 # file-size
  87. REM %~a1 # file-attributes
  88. REM %~sn1 # 8.3
  89. REM
  90. REM foo.bar > foo_new.bar > %~dpn1_new%~x1
  91. REM
  92. REM quotes around entire argument to 'set' is best practice (prevents whitespace memes)
  93. REM
  94. REM always escape ^ & < > | \ ! with ^
  95. REM also end a batch-file with a ^ to cause memory leaks lol
  96. REM
  97. REM if [%1]==[]   works on " but fails on whitespace
  98. REM if "%1"==""   fails on " but works on whitespace
  99. REM if "%~1"==""  works? i think
Advertisement
Add Comment
Please, Sign In to add comment