Simple command line tool to compress videos from a local folder using FFmpeg.
git clone https://github.com/dmitsuo/ffmpeg-video-compressor.git
Optionnaly, you can change the conversion parameters of FFmpeg inside video-compressor.sh file (Linux) or video-compressor.bat file (Windows) to fit your needs or just accept the default values.
We recommend that you stay with the default parameter values and only change them if the results are not acceptable.
Those parameters are shown below:
- Linux: around line 50 of video-compressor.sh file
## ... rest of the code ommited
### Parameters that you can change to fit your needs - BEGIN
SOURCE_EXTENSIONS=("ts" "avi" "mkv" "mov" "webm" "mp4")
CPU_USED="12"
VIDEO_CONSTANT_RATE_FACTOR="26"
AUDIO_BITRATE="32k"
AUDIO_SAMPLING_RATE="32000"
AUDIO_CHANNELS="1"
### Parameters that you can change to fit your needs - END
## ... rest of the code ommited
- Windows: around line 51 of video-compressor.bat file
REM ... rest of the code ommited
REM Parameters that you can change to fit your needs - BEGIN
set "SOURCE_EXTENSIONS=webm ts mp4 mkv avi mov"
set "CPU_USED=12"
set "VIDEO_CONSTANT_RATE_FACTOR=26"
set "AUDIO_BITRATE=32k"
set "AUDIO_SAMPLING_RATE=32000"
set "AUDIO_CHANNELS=1"
REM Parameters that you can change to fit your needs - END
REM ... rest of the code ommited
To get more details about FFmpeg parameters, please go to its documentation website: https://ffmpeg.org/ffmpeg.html
To compress all video files in a given local folder, call the video-compressor.sh script (Linux) or the video-compressor.bat file (Windows) via the command line, passing the full path to the videos folder you want to compress, for example:
- Linux
./video-compressor.sh "/path/to/my/videos/folder"
- Windows
video-compressor.bat "C:\Users\myusername\Videos"
These scripts can be called without arguments, in which case they will prompt the user for the full path of the videos folder.
The compressed video files will be saved in a folder called “converted_videos”, which will be created in the same source folder as the video files.
If you need this tool to compress video files uninterruptedly, as the files are created/copied in the source folder, run the loop.sh script (Linux) or the loop.bat file (Windows), as shown in the example below:
- Linux
./loop.sh "/path/to/my/videos/folder"
- Windows
loop.bat "C:\Users\myusername\Videos"