Skip to content

ShyamSunder149/video-compressor-ffmpeg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

Video Compressor Tool

A Python script to compress video files using ffmpeg. It supports both single file compression and batch processing of entire directories.

Features

  • Smart Compression: Uses libx264 codec with a CRF of 28 for a good balance between quality and file size.
  • Batch Processing: Can process an entire folder of videos at once.
  • Safe Output:
    • For folders: Creates a new folder (e.g., videos_compressed) so original files are untouched.
    • For files: Creates a new file with _compressed suffix (e.g., video_compressed.mp4).
  • Reporting: Shows progress and calculates total space saved after compression.
  • Cross-Platform Checks: Automatically detects if ffmpeg is missing and provides OS-specific installation commands.

Prerequisites

  1. Python 3: Ensure you have Python 3 installed.
  2. FFmpeg: This tool requires ffmpeg to be installed on your system.

Installing FFmpeg

  • macOS:
    brew install ffmpeg
  • Linux (Debian/Ubuntu):
    sudo apt install ffmpeg
  • Windows/Other: Download from ffmpeg.org and add it to your system PATH.

Usage

1. Compress a Single File

To compress a single video file, provide the path using the -p flag:

python3 video_compressor.py -p /path/to/your/video.mp4

Output: Creates /path/to/your/video_compressed.mp4

2. Compress a Folder (Batch Mode)

To compress all videos in a folder, provide the folder path and add the -f (folder) flag:

python3 video_compressor.py -p /path/to/your/video_folder -f

Output: Creates a new folder /path/to/your/video_folder_compressed containing all the compressed videos.

Supported Formats

The tool automatically detects and processes the following video extensions: .mp4, .mov, .avi, .mkv, .flv, .wmv, .m4v, .webm

About

A Small video compressor made using ffmpeg for personal usage

Topics

Resources

Stars

Watchers

Forks

Contributors

Languages