Advertisement
Guest User

handbrakeCLI windows batch wrapper

a guest
Apr 29th, 2014
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. :: Coded by Nightsanity Copyright (c) 2014
  2. @echo off
  3. ::SET TO CURRENT CODE PAGE:::::::::::::::::::::::::::
  4. FOR /F "tokens=4 delims= " %%G in ('chcp') DO (
  5. chcp %%G >nul
  6. )
  7. :::::::::::::::::::::::::::::::::::::::::::::::::::::
  8. setlocal EnableExtensions
  9. title AniCoder v2.5 by Nightsanity
  10. color 0a
  11. cd "%~d0%~p0"
  12.  
  13. ::PREVENT MULTIPLE HANDBRAKE PROCESSES::::::::::::::::
  14. set ignore=INFO:
  15. for /f "usebackq" %%A in (`tasklist /nh /fi "imagename eq HandBrakeCLI.exe"`) do if not %%A==%ignore% (
  16. exit
  17. )
  18. ::::::::::::::::::::::::::::::::::::::::::::::::::::::
  19.  
  20. ::PREREQUISITES CHECK:::::::::::::::::::::::::::::::::
  21. if not exist "HandBrakeCLI.exe" (
  22. echo HandBrakeCLI is missing!
  23. pause
  24. exit
  25. )
  26. if exist "Jobs.txt" del "Jobs.txt"
  27. if not exist "ToConvert" mkdir "ToConvert"
  28. if not exist "Converted" mkdir "Converted"
  29. :::::::::::::::::::::::::::::::::::::::::::::::::::::::
  30.  
  31. ::CREATE A LIST OF VIDEOS TO CONVERT:::::::::::::::::::
  32. for /F %%i in ('dir /s /b "ToConvert\*.*"') do (
  33. dir/s/b "ToConvert\*" >> "Jobs.txt"
  34. goto MAIN
  35. )
  36. goto NOFILES
  37. :::::::::::::::::::::::::::::::::::::::::::::::::::::::
  38.  
  39. ::LOOP THROUGH JOBS LIST AND CONVERT FILES:::::::::::::
  40. :MAIN
  41. for /f "tokens=* delims= " %%a in (Jobs.txt) do (
  42. HandBrakeCLI -i "./ToConvert/%%~nxa" -f mp4 -o "./Converted/%%~na.mp4" -q 22 -e x264 -x cabac=0:ref=2:me=hex:bframes=0:weightp=0:subme=6:8x8dct=0:trellis=0 -E faac --mixdown mono -B 64 -X 480 -l 272 -s 1 --subtitle-burn -a 1
  43. )
  44. :::::::::::::::::::::::::::::::::::::::::::::::::::::::
  45.  
  46. ::CLEAN UP FILES:::::::::::::::::::::::::::::::::::::::
  47. if exist "Jobs.txt" del "Jobs.txt"
  48. :Question
  49. cls
  50. echo Encode Done!
  51. echo.
  52. set DELFILES=
  53. set /p DELFILES="Do you want to delete original files (Y/N)?:"
  54. if "%DELFILES%" == "y" goto DELNOW
  55. if "%DELFILES%" == "Y" goto DELNOW
  56. if "%DELFILES%" == "n" goto ENDNOW
  57. if "%DELFILES%" == "N" goto ENDNOW
  58. goto Question
  59. :DELNOW
  60. if exist "ToConvert\*.*" del /Q "ToConvert\*.*"
  61. :ENDNOW
  62. endlocal
  63. exit
  64. :::::::::::::::::::::::::::::::::::::::::::::::::::::::
  65.  
  66. ::WHEN NO FILES ARE INSIDE TOCONVERT FOLDER::::::::::::
  67. :NOFILES
  68. echo No video files found in:
  69. echo ToConvert folder
  70. echo.
  71. pause
  72. :::::::::::::::::::::::::::::::::::::::::::::::::::::::
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement