Advertisement
RyzaJr

[BATCH] WebM Converter (Uses FFmpeg)

Nov 7th, 2016
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 2.30 KB | None | 0 0
  1. @echo off
  2.  
  3. set "DIR_FFMPEG=C:\Misc\Programs\FFmpeg"
  4.  
  5. ::==============================================================================================
  6.  
  7. :start
  8. cls
  9. echo Drag ^& drop the file to convert below.
  10. echo.
  11. set /p "INPUT_FILE=File: "
  12. call :checkerror
  13.  
  14. :next_1
  15. cls
  16. echo Bitrate (Kb/s) to convert with?
  17. echo (Note: Try a number anywhere from around 2000 to 5000)
  18. echo.
  19. set /p "BITRATE=Bitrate: "
  20.  
  21. :choice
  22. cls
  23. echo Would you like to trim the file?
  24. echo.
  25. echo 1) Yes
  26. echo 2) No
  27. echo.
  28. set /p "CHOICE=Choice: "
  29. if "%CHOICE%" == "1" (goto trim)
  30. if "%CHOICE%" == "2" (set "TRIM_START=" & set "TRIM_TIME=" & goto convert) ^
  31. else cls & echo Not a valid choice!
  32. echo.
  33. echo Restarting...
  34. timeout /t 5 /nobreak > nul
  35. goto :start
  36.  
  37. :trim
  38. cls
  39. echo Time from the beginning to start trimming?
  40. echo (Note: Time can be in the form HH:MM:SS, MM:SS, or S)
  41. echo (Note: Leave blank to start at the beginning of the video)
  42. echo.
  43. set /p "TRIM_START=Time: "
  44.  
  45. if errorlevel 1 (
  46.     set "TRIM_START=-ss 0"
  47. ) else (
  48.     set "TRIM_START=-ss %TRIM_START%"
  49. )
  50. VERIFY > nul
  51.  
  52. cls
  53. echo Amount of time from starting trim point?
  54. echo (Note: Time can be in the form HH:MM:SS, MM:SS, or S)
  55. echo (Note: Leave blank to go to the end of the video)
  56. echo.
  57. set /p "TRIM_TIME=Time: "
  58.  
  59. if errorlevel 1 (
  60.     set "TRIM_TIME="
  61. ) else (
  62.     set "TRIM_TIME=-t %TRIM_TIME%"
  63. )
  64. VERIFY > nul
  65.  
  66. ::==============================================================================================
  67.  
  68. :convert
  69.  
  70. set "OUTPUT_FILE=%INPUT_FILE:~0,-4%"
  71.  
  72. cls
  73. cd "%DIR_FFMPEG%"
  74. ffmpeg %TRIM_START% %TRIM_TIME% -i "%INPUT_FILE%" -an -c:v libvpx -crf 32 -b:v %BITRATE%K -vf scale=-1:480  -threads 4 -fs 2.90M -quality best -lag-in-frames 16 -pass 1 -auto-alt-ref 1 -f webm -y nul
  75. ffmpeg %TRIM_START% %TRIM_TIME% -i "%INPUT_FILE%" -an -c:v libvpx -crf 32 -b:v %BITRATE%K -vf scale=-1:480  -threads 4 -fs 2.90M -quality best -lag-in-frames 16 -pass 2 -auto-alt-ref 1 -f webm -y "%OUTPUT_FILE%.webm"
  76.  
  77. echo.
  78. echo Task completed!
  79. pause
  80. exit
  81.  
  82. ::==============================================================================================
  83.  
  84. :checkerror
  85. if errorlevel 1 (
  86.     goto none
  87. ) else (
  88.     set INPUT_FILE=%INPUT_FILE:"=%
  89.     goto next_1
  90. )
  91. exit /b
  92.  
  93. :none
  94. cls
  95. echo No file selected.
  96. echo.
  97. echo Restarting...
  98. timeout /t 3 /nobreak > nul
  99. cls
  100. goto start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement