This script allows you to compress all video files in a directory using the FFmpeg tool.
-
Install prerequisites:
-
Download the script:
git clone https://github.com/MoeeinAali/FFmpeg-Video-Compressor.git cd FFmpeg-Video-Compressor.git
-
Run the script:
python Video-Compressor.py <Frame Rate> <directory_path>
<Frame Rate>
: Desired Frame Rate for the videos (from 10 to 30)<directory_path>
: Path to the directory containing videos
Example:
python compress_videos.py 20 /path/to/videos
-
Output:
- Compressed videos with the
_compressed.mp4
extension will be saved in the same directory.
- Compressed videos with the
- Make sure FFmpeg is installed.
- Make sure Python is installed.
- If you encounter an error, ensure that the directory path and input resolution are correct.
- If needed, you can modify the ffmpeg parameters in the Python code.
Note: This script is suitable for video files only and requires ffmpeg installation.
For more information about using ffmpeg, visit the official ffmpeg website.
-
Download FFmpeg:
- Click on this link to download the
FFmpeg-git-full.7z
file. You may need a VPN or a proxy if the website is blocked in your region.
- Click on this link to download the
-
Extract the downloaded file:
- Unzip the downloaded file and rename the extracted folder to
FFmpeg
.
- Unzip the downloaded file and rename the extracted folder to
-
Move the folder to C drive:
- Move the
FFmpeg
folder to theC:\
drive.
- Move the
-
Run Command Prompt as an Administrator:
- Open the Command Prompt with administrative privileges.
-
Set the PATH environment variable:
- Run the following command in the Command Prompt:
setx /m PATH "C:\FFmpeg\bin;%PATH%"
- Run the following command in the Command Prompt:
-
Restart your computer:
- Restart your computer to apply the changes.
After completing these steps, FFmpeg should be installed on your system. You can use it in the Command Prompt for various video processing tasks.
To install FFmpeg on Linux, you can use the package manager specific to your Linux distribution.
-
Open a terminal.
-
Update the package list:
sudo apt-get update
-
Install FFmpeg:
sudo apt-get install FFmpeg
-
Open a terminal.
-
Enable the EPEL repository:
sudo yum install epel-release
-
Install FFmpeg:
sudo yum install FFmpeg
-
Open a terminal.
-
Install FFmpeg:
sudo dnf install FFmpeg
-
Open a terminal.
-
Install FFmpeg:
sudo pacman -S FFmpeg
If your distribution doesn't have FFmpeg in its default repositories, you can download a static build:
-
Download the static build from the official FFmpeg website or use a package manager like snap or flatpak.
-
Extract the downloaded file and move the
FFmpeg
binary to a directory in your system's PATH. -
Confirm the installation by running:
FFmpeg -version
These instructions should help you install FFmpeg on various Linux distributions.