Skip to content

Instantly share code, notes, and snippets.

@anzz1
Created March 15, 2023 21:25
Show Gist options
  • Save anzz1/81ca4c70c2de512fcda67aaa8f11ee24 to your computer and use it in GitHub Desktop.
Save anzz1/81ca4c70c2de512fcda67aaa8f11ee24 to your computer and use it in GitHub Desktop.
h264.bat
@echo off
if [%~1]==[] echo h264: No input file specified.&exit /b 1
:loop
if [%~x1]==[.mp4] (set "_outfile=%~n1_1.mp4") else (set "_outfile=%~n1.mp4")
ffmpeg -hide_banner -vsync 0 -hwaccel cuda -hwaccel_output_format cuda -i "%~1" -vf "hwupload,hwdownload,format=nv12" -c:v h264_nvenc -profile:v high -preset slow -pix_fmt yuv420p -rc vbr_hq -b:v 0 -c:a libfdk_aac -b:a 0 -ar 44100 -ac 2 -f mp4 "%_outfile%" || call :chksz "%_outfile%"
shift
if not [%~1]==[] goto loop
goto :eof
:chksz
if [%~z1]==[0] del "%~1"
exit /b 0
:eof
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment