VideoToWebMConverter
A lightweight and efficient tool for converting video files to the WebM format with ease. This project provides a simple interface for high-quality video compression, supporting various input formats and customizable conversion settings. Ideal for web developers, content creators, and anyone looking to optimize videos for web delivery.
VideosToWebMConverter
This Python utility scans a directory for supported video files and converts them to WebM format. Converted assets are stored in a WebM_Videos subfolder and encoded with VP9 + Opus via ffmpeg.
Features
- Batch converts every supported video in a directory.
- Handles
.mp4,.avi,.mov,.mkv,.flv, and.wmvfiles. - Requests the target video bitrate from the user (defaults to
1Mif omitted). - Prints original and converted file sizes when each conversion completes.
Requirements
- Python 3.7+ (only standard library modules are used).
- An
ffmpeginstallation accessible on your systemPATH.
# verify ffmpeg availability
ffmpeg -version
Installation
- Clone or download the repository:
git clone <repo-url> cd VideoToWebMConverter - (Optional) create and activate a virtual environment.
- Make sure
ffmpegis installed.
Usage
Run the script from a terminal:
python VideosToWebMConverter.py
The script prompts you for:
- The directory containing the videos you want to convert.
- A target video bitrate (press Enter to keep the default
1M).
For each video, progress and file-size information appears in the console. Converted files are saved under WebM_Videos inside the input directory.
Importing the module
You can also call convert_videos_to_webm from another Python module:
from VideosToWebMConverter import convert_videos_to_webm
convert_videos_to_webm(
directory_path="/path/to/videos",
video_bitrate="2M", # optional override
)
How It Works
- Creates (or reuses) a
WebM_Videosfolder inside the source directory. - Checks file extensions and skips unsupported items with a short message.
- Executes
ffmpegwith thelibvpx-vp9video codec andlibopusaudio codec. - Reports original and converted sizes in MB once each conversion finishes.
Troubleshooting
Error: FFmpeg bulunamadΔ±...:ffmpegis missing from thePATH. Install it or add the executable path to your environment variables.CalledProcessError:ffmpegencountered an error. Inspect the console output; you may have an unsupported codec, a corrupted file, or a permissions issue.- Conversions for very large files taking too long? Try a lower bitrate such as
800K.
License
No license file has been provided yet. Contact the repository owner to clarify permitted usage.