FFMPEG Command Collection
Just a collection of FFMPEG commands for encoding
Link to download FFMPEG: https://ffmpeg.org/download.html
Note
First and foremost, make sure to add FFMPEG to your PATH.
By adding FFmpeg to your PATH, you can use FFmpeg commands directly from the command line without having to specify the full path to the executable.
Steps to add FFmpeg to the PATH:
-
Locate the FFmpeg folder:
- Find the directory where you extracted FFMPEG. (Folder that contains ffmpeg.exe)
-
Open Environment Variables:
- Search for “Environment Variables” in the Windows search bar.
- Select “Edit the system environment variables”.
- Click on “Environment Variables” at the bottom.
-
Edit the PATH variable:
- Under “System variables”, find “Path” variable, select it and then click “Edit”.
- Click “New”.
- Enter the full path to the FFMPEG folder (e.g., C:\ffmpeg).
- Click “OK” on all open dialog boxes to save the changes.
-
Verify it works:
- Open a new command prompt or PowerShell window.
- Type
ffmpeg -version
and press Enter. - If it was correctly added to the PATH, you should see the FFmpeg version information.
Batch commands:
Batch compress all MP4 files in the same folder
Put this .bat file in the same folder as .MP4 files and have them all be compressed to a CRF rate of 24. Resulting in a smaller filesize. All compressed files will be saved in a new subfolder called “done”.
@echo off
echo === MP4 Batch Compressor ===
echo.
echo This BAT script will compress all the .mp4 files that are in the same folder as this script.
echo All original files will remain untouched.
echo The compressed versions will be placed in a subfolder called "done".
echo.
set /p ):
if /i not "%confirm%"=="Y"
mkdir "done" 2>nul
for %%f in do
echo.
echo All done.
pause
Batch convert all MKV into MP4
Converts all MKV files in the same folder as the .bat file into MP4.
@echo off
echo === MKV to MP4 Batch Converter ===
set i = 1
for %%f in do ffmpeg -i "%%f" -map 0 -vcodec copy -acodec copy "%%~nf.mp4"
pause
Batch convert all MP4 into MKV
I would recommend using MKVToolNix instead for this, but if needed. Converts all MKV files in the same folder as the .bat file into MP4.
@echo off
echo === MP4 to MKV Batch Converter ===
set i = 1
for %%f in do ffmpeg -i "%%f" -map 0 -vcodec copy -acodec copy "%%~nf.mkv"
pause
Batch convert MP4 to WEBM
Converts all MKV files in the same folder as the .bat file into MP4.
@echo off
echo === MP4 to WEBM Batch Converter ===
set i = 1
for %%f in do ffmpeg -i "%%f" -c:v libvpx-vp9 -c:a libopus "%%~nf.webm"
pause
Batch convert MOV with Alpha to WEBM and keep transparency
Converts MOV files that have alpha channel to WEBM and keeps the transparency.
@echo off
echo === MOV to WEBM Batch Converter ===
for %%i in do echo\Encoding: "%%~nxi" "%%~ni.webm" &&
pause
Single file commands
Merge SUBS (soft) into VIDEO file
ffmpeg -i VIDEO.EXT -i SUBS.EXT -c copy -c:s mov_text OUTPUT.MP4
Merge VIDEO and AUDIO into one MP4
ffmpeg -i VIDEO.EXT -i AUDIO.EXT -c:v copy -c:a copy OUTPUT.MP4
@echo off
:START
cls
echo === Merge MP4 and M4A ===
set /p ):
set /p ):
set /p ):
echo.
echo You entered:
echo Video file : %video_file%
echo Audio file : %audio_file%
echo Output file: %output_file%
echo.
set /p ):
if /I "%confirm%"=="Y" goto
if /I "%confirm%"=="N" goto
echo Invalid choice. Please type Y or N.
pause
goto
:PROCESS
ffmpeg -i "%video_file%" -i "%audio_file%" -c:v copy -c:a copy "%output_file%"
echo.
echo Done!
pause