Here’s a small collection of scripts i’ve made, downloaded, modified, etc to compress, edit, add, remux video files as well as converting mkv files without the need of re-rendering.

Copy the code and save as a .bat file, save it on your ffmpeg bin folder or any command line if ffmpeg was installed with its environment path.

To use the scripts, just drag and drop your video file on the .bat file you created.

Download ffmpeg from here: https://www.gyan.dev/ffmpeg/builds/ffmpeg-release-full.7z

Add Frame Number to .mov

rem @echo off
:again

cd /D %~p1

ffmpeg ^
	-i "%~nx1" ^
	-vf "drawtext=fontfile=/Windows/Fonts/courbd.ttf: text='Frame \: %%{eif\:n\:d\:2}': start_number=1: x=(w-tw)/2: y=h-(2*lh): fontcolor=white: fontsize=40: box=1: boxcolor=black@0.4: boxborderw=8" ^
	-c:a copy ^
	"%~p1%~n1_framenumbered.mov"
	pause
if NOT ["%errorlevel%"]==["0"] goto:error
echo %~n1 Done!

shift
if "%~1" == "" goto:end
goto:again

:error

echo There was an error. Please check your input file or report an issue on github.com/L0Lock/FFmpeg-bat-collection/issues.
pause
exit 0

:end

cls
echo Encoding succesful. This window will close after 10 seconds.
timeout /t 10

Convert Any Video to a 100MB File

@echo off
:again

cd /D %~p0
SET output=%~p1%~n1_100MB.mp4
set cmd="ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 %1 "
FOR /F "tokens=*" %%i IN (' %cmd% ') DO SET seconds=%%i
echo aaaa
echo aaaa
SET /A "totalBitrate=500000/seconds"
SET overheadBitrate=100
SET audioBitrate=96
SET /A "videoBitrate=totalBitrate-audioBitrate-overheadBitrate"
ffmpeg ^
	-i %1 ^
	-c:v libx264 ^
	-b:v %videoBitrate%k ^
	-pass 1 -b:a %audioBitrate%k ^
	-f mp4 NUL && \
ffmpeg ^
	-i %1 ^
	-c:v libx264 ^
	-b:v %videoBitrate%k ^
	-pass 2 ^
	-b:a %audioBitrate%k "%output%"
del /q ffmpeg2pass-*.log ffmpeg2pass-*.mbtree
if NOT ["%errorlevel%"]==["0"] goto:error
echo %~n1 Done!

shift
if "%~1" == "" goto:end
goto:again

:error

echo There was an error. Please check your input file or report an issue on github.com/L0Lock/FFmpeg-bat-collection/issues.
pause
exit 0

:end

cls
echo Encoding succesful. This window will close after 10 seconds.
timeout /t 10

Convert Video to Discord File Size Limits

@echo off
:again

cd /D %~p0
SET output=%~p1%~n1_Discorded.mp4
set cmd="ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 %1 "
FOR /F "tokens=*" %%i IN (' %cmd% ') DO SET seconds=%%i
echo aaaa
echo aaaa
SET /A "totalBitrate=64000/seconds"
SET overheadBitrate=100
SET audioBitrate=96
SET /A "videoBitrate=totalBitrate-audioBitrate-overheadBitrate"
ffmpeg ^
	-i %1 ^
	-c:v libx264 ^
	-b:v %videoBitrate%k ^
	-pass 1 -b:a %audioBitrate%k ^
	-f mp4 NUL && \
ffmpeg ^
	-i %1 ^
	-c:v libx264 ^
	-b:v %videoBitrate%k ^
	-pass 2 ^
	-b:a %audioBitrate%k "%output%"
del /q ffmpeg2pass-*.log ffmpeg2pass-*.mbtree
if NOT ["%errorlevel%"]==["0"] goto:error
echo %~n1 Done!

shift
if "%~1" == "" goto:end
goto:again

:error

echo There was an error. Please check your input file or report an issue on github.com/L0Lock/FFmpeg-bat-collection/issues.
pause
exit 0

:end

cls
echo Encoding succesful. This window will close after 10 seconds.
timeout /t 10

Convert Video to Facebook File Size Limits

@echo off
:again

cd /D %~p0
SET output=%~p1%~n1_Messengered.mp4
set cmd="ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 %1 "
FOR /F "tokens=*" %%i IN (' %cmd% ') DO SET seconds=%%i
echo aaaa
echo aaaa
SET /A "totalBitrate=160000/seconds"
SET overheadBitrate=100
SET audioBitrate=96
SET /A "videoBitrate=totalBitrate-audioBitrate-overheadBitrate"
ffmpeg ^
	-i %1 ^
	-c:v libx264 ^
	-b:v %videoBitrate%k ^
	-pass 1 -b:a %audioBitrate%k ^
	-f mp4 NUL && \
ffmpeg ^
	-i %1 ^
	-c:v libx264 ^
	-b:v %videoBitrate%k ^
	-pass 2 ^
	-b:a %audioBitrate%k "%output%"
del /q ffmpeg2pass-*.log ffmpeg2pass-*.mbtree
if NOT ["%errorlevel%"]==["0"] goto:error
echo %~n1 Done!

shift
if "%~1" == "" goto:end
goto:again

:error

echo There was an error. Please check your input file or report an issue on github.com/L0Lock/FFmpeg-bat-collection/issues.
pause
exit 0

:end

cls
echo Encoding succesful. This window will close after 10 seconds.
timeout /t 10

Convert Video to Whatsapp File Size Limits

@echo off
:again

cd /D %~p0
SET output=%~p1%~n1_Whatsapped.mp4
set cmd="ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 %1 "
FOR /F "tokens=*" %%i IN (' %cmd% ') DO SET seconds=%%i
echo aaaa
echo aaaa
SET /A "totalBitrate=260000/seconds"
SET overheadBitrate=100
SET audioBitrate=96
SET /A "videoBitrate=totalBitrate-audioBitrate-overheadBitrate"
ffmpeg ^
	-i %1 ^
	-c:v libx264 ^
	-b:v %videoBitrate%k ^
	-pass 1 -b:a %audioBitrate%k ^
	-f mp4 NUL && \
ffmpeg ^
	-i %1 ^
	-c:v libx264 ^
	-b:v %videoBitrate%k ^
	-pass 2 ^
	-b:a %audioBitrate%k "%output%"
del /q ffmpeg2pass-*.log ffmpeg2pass-*.mbtree
if NOT ["%errorlevel%"]==["0"] goto:error
echo %~n1 Done!

shift
if "%~1" == "" goto:end
goto:again

:error

echo There was an error. Please check your input file or report an issue on github.com/L0Lock/FFmpeg-bat-collection/issues.
pause
exit 0

:end

cls
echo Encoding succesful. This window will close after 10 seconds.
timeout /t 10

MKV 5.1 audio to Stereo without rendering (Useful when source audio cannot be played on your TV)

@echo off

cd /D %~p0


echo Convert Audio to Stereo ... 
for %%i in (%*) do if not exist "%~p1%%~ni_Stereo.mkv" (
   ffmpeg.exe -i "%%~i" -map 0 -c copy -c:a aac -ac 2 "%~p1%%~ni_Stereo.mkv"
)
popd
echo Done..

Leave a comment / Déjanos un comentario