video-concat.cmd 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. @echo off
  2. chcp 65001
  3. setlocal enableextensions enabledelayedexpansion
  4. set SRCPATH=%~1
  5. if not defined SRCPATH call :PRINT_USAGE
  6. set DESTPATH=%~2
  7. if not defined DESTPATH set DESTPATH=%cd%.
  8. set SRCFILEMASK=%~3
  9. if not defined SRCFILEMASK set SRCFILEMASK="\b*"
  10. set PROCS="%~dp0procs.cmd"
  11. if not exist "%SRCPATH%" call %PROCS% DIR_ERROR
  12. if not exist "%DESTPATH%" ( md "%DESTPATH%" || exit /b )
  13. for %%I in ( "%SRCPATH%." ) do set "FFCONCATFILENAME=%%~nxI.ffconcat"
  14. @echo.ffconcat version 1.0>"%DESTPATH%\%FFCONCATFILENAME%" &&^
  15. for /f "usebackq tokens=* delims=" %%I in ( `dir /b /s /a:-d "%SRCPATH%\*" 2^>NUL ^| find /I "%SRCFILEMASK%" 2^>NUL` ) do (
  16. set FN=%%I
  17. @echo.file !FN:\=\\!>>%DESTPATH%\%FFCONCATFILENAME%
  18. )
  19. echo.Ready. File "%DESTPATH%\%FFCONCATFILENAME%" saved.
  20. set OUTFILEPREFIX=%~3
  21. if not defined OUTFILEPREFIX for %%I in ( %SRCFILE% ) do set "OUTFILEPREFIX=%%~nI"
  22. for /f "usebackq tokens=* delims=" %%I in ( `call %PROCS% NEWDATENAME %OUTFILEPREFIX%` ) do set "OUTFILENAME=%%I.mp4"
  23. set "ffmpeg=e:\Work\video\bin\ffmpeg\ffmpeg.exe"
  24. set "x264opts=colorprim=bt709:transfer=bt709:colormatrix=bt709:fullrange=off:analyse=0x3,0x133"
  25. %ffmpeg% -y -fflags +genpts -f concat -safe 0 -i "%DESTPATH%\%FFCONCATFILENAME%" -map 0:0 -c:v libx264 -crf:v 21 -level:v 4.1 -profile:v high422 -tune:v film -preset:v fast ^
  26. -maxrate:v 1000k -bufsize:v 2000k -threads 0 -f mp4 -pix_fmt yuv422p -metadata title=%OUTFILEPREFIX% ^
  27. -map 0:1 -c:a aac -q:a 2 -ac 1 -ar 22050 ^
  28. -x264opts %x264opts% -x264-params %x264opts% %DESTPATH%\%OUTFILENAME%
  29. ::-map 0:1 -c:a libfdk_aac -profile:a aac_he_v2 -afterburner 1 -signaling explicit_sbr -vbr 5 -ac 2 -ar 44100 ^
  30. echo.Ready. File "%DESTPATH%\%OUTFILENAME%" saved.
  31. echo.&pause&goto:eof
  32. :PRINT_USAGE
  33. echo:
  34. echo USAGE:
  35. echo %~nx0 ^<source^> [destination] [outfile prefix title]
  36. exit /b !ERRORLEVEL!