gmzorz

prorec.bat (prerec converter)

Feb 10th, 2019
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 2.82 KB | None | 0 0
  1. @echo off
  2. setlocal enabledelayedexpansion
  3.     REM enable batch extensions
  4.    
  5. pushd %~dp0
  6.     REM change current dir to where this batch file resides (eg running as admin will change default dir to sys32, this will prevent that from happening)
  7. if [%1]==[] goto scan
  8.     REM this checks if there is a file being dropped onto the batch file itself, if %1 (dropped file) is non existant, goto :scan
  9.  
  10.     REM ----- Drag & drop -----
  11. set file=%1
  12. set name=%~n1
  13.     REM set variables !file! and !name! to current file, %1 prints file + filepath, %~n1 will print just the name
  14.    
  15. for %%a in (%1) do ( pushd %%~da%%~pa )
  16.     REM this checks the variable %1 (which may look like C:\Users\Jim\media\clips\clip.mp4)
  17.     REM %%a in this case would be the full filepath + file, but we can shorten this using the D(drive) and p(path) so we can properly change dir to path
  18.    
  19. set /p format=convert to [tga, png, xvid, prores]: %=%
  20.     REM ask for format, !format! will return prompt input
  21.    
  22. call :settings
  23.     REM see :settings, presets are called after !file! and !name! are set
  24.    
  25. if not exist "converted_!format!" ( mkdir "converted_!format!" )
  26.     REM check if output dir exists, if not, make one
  27. !%format%!
  28.     REM tricky one, we can use both !! and %% to call variables, if prompt input (!format!) is xvid, this line will be seen as !xvid! and will execute the variable !xvid!
  29. goto end
  30.  
  31. :scan
  32.     REM ----- Scan for files -----
  33. echo convertable files found:
  34. echo.
  35. for %%a in (*.mp4, *.avi, *.wmv, *.mov) do ( echo   %%a )
  36.     REM list all files ending with suffix in current directory (for each file ending with *.mp4, print, or echo to cmd.exe)
  37. echo.
  38.     REM side note, echo. means blank line :)
  39.    
  40. set /p format=convert to [tga, png, xvid, prores]: %=%
  41. for %%a in (*.mp4, *.avi, *.wmv, *.mov) do (
  42.     set file=%%a
  43.     set name=%%~na
  44.     call :settings
  45.     if not exist "converted_!format!" ( mkdir "converted_!format!" )
  46.     !%format%!
  47. )
  48.     REM for every file ending with suffix, set the the variables !file! and !name! to the current file
  49.     REM load presets again using !file! and !name!
  50.     REM check for existing dir, if not, create one
  51.     REM if prompted input equals xvid, %format% will display: xvid, !%format%! will be seen as !xvid!, and the variable !xvid! will be executed
  52.    
  53. :end
  54. exit
  55. :settings
  56. set "tga=ffmpeg -i ^"!file!^" -y ^"converted_!format!^"/^"!name!^"-%%05d.tga"
  57. set "png=ffmpeg -i ^"!file!^" -y ^"converted_!format!^"/^"!name!^"-%%05d.png"
  58. set "xvid=ffmpeg -i ^"!file!^" -c:v mpeg4 -vtag xvid -qscale:v 1 -qscale:a 1 -g 32 -vsync 1 -y ^"converted_!format!^"/^"!name!^".avi"
  59. set "prores=ffmpeg -i ^"!file!^" -c:v prores_ks -profile:v 3 -c:a pcm_s16le -y ^"converted_!format!^"/^"!name!^".mov"
  60. rem set "h264=ffmpeg -i ^"!file!^" -c:v libx264 -crf 1 -y ^"converted_!format!^"/^"!name!^".mp4" (barely compatible)
  61.  
  62.     REM presets as seen above, using ffmpeg.exe and it's parameters
Add Comment
Please, Sign In to add comment