This is a video compression tool built using Python and the PyQt5 library. It allows users to compress videos in .mp4 and .gif formats. Additionally, users can select the compression size, trim the video, and specify custom options for GIF resolution and FPS.
In this mode, you can choose to compress an MP4 video to a selected size (e.g., 8MB, 10MB, 25MB). The tool will automatically calculate the required bitrate and compress the video using Nvidia GPU encoding.
In GIF mode, you can specify the frame rate and resolution for the output GIF. Additionally, the app will allow you to resize the video to match your resolution preferences, maintaining a 16:9 aspect ratio.
- Supports
.mp4and.gifoutput formats. - Compression size options for
.mp4(8MB, 10MB, 25MB, or custom). - Ability to trim the video by specifying start and end times.
- GIF-specific settings, such as frames per second (FPS) and resolution.
- Uses Nvidia GPU (if available) for fast
.mp4compression via theh264_nvenccodec. - The application opens the compressed file in Windows Explorer upon completion.
- Python 3.x
- PyQt5: For building the graphical interface
- MoviePy: For handling video processing
- FFmpeg: Must be installed and available in the system path
-
Clone the repository or download the script.
-
Install the necessary dependencies by running:
pip install -r requirements.txt
-
Make sure FFmpeg is installed and accessible through your system’s PATH.
To run the application, you can use one of the provided scripts:
Run the compressor.bat file:
compressor.batRun the compressor.sh file:
./compressor.shAlternatively, you can manually run the Python script:
python video_compressor.pyOnce the application is open, follow these steps:
- Select a video file: Click on "Choose video file" and load the desired video.
- Choose output format: Select either
.mp4or.gif. - Adjust settings:
- For
.mp4: Choose a target file size. - For
.gif: Specify the FPS and resolution.
- For
- Trim video (optional): Enter the start and end times to trim the video.
- Compress: Click "Compress" to start the process. The app will notify you when compression is complete and open the folder containing the compressed file.
You can specify a custom default directory for the file dialog by creating a .env file in the project directory.
DEFAULT_DIRECTORY=C:/Users/YourUsername/VideosIf the .env file is not provided or the DEFAULT_DIRECTORY variable is missing, the application will default to empty string and use the current working directory.
- Ensure FFmpeg is installed and properly set up in the system path.
- Check that Nvidia GPU drivers and CUDA are installed if using the
h264_nvenccodec.

