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.
- 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.
- Python 3.7+ (only standard library modules are used).
- An
ffmpeginstallation accessible on your systemPATH.
# verify ffmpeg availability
ffmpeg -version- Clone or download the repository:
git clone <repo-url> cd VideoToWebMConverter
- (Optional) create and activate a virtual environment.
- Make sure
ffmpegis installed.
Run the script from a terminal:
python VideosToWebMConverter.pyThe 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.
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
)- 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.
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.
No license file has been provided yet. Contact the repository owner to clarify permitted usage.