Check if a file or extension is a video type, and iterate over 36 known video file formats including mp4, mov, avi, mkv, and more. Python port of video-extensions npm package.
- Immutable collection of 36 known video file extensions
- Fast membership checks using
frozenset - Case-insensitive and dot-aware checks
- Works for both extensions and full file paths
- Supports dotfiles (e.g.,
.mov) - Zero dependencies, minimal overhead
pip install video-extensionsOr using uv:
uv add video-extensionsfrom video_extensions import is_video_extension
is_video_extension("mp4") # True
is_video_extension(".mov") # True (dot-aware)
is_video_extension("AVI") # True (case-insensitive)
is_video_extension("txt") # Falsefrom video_extensions import is_video_path
is_video_path("movie.mp4") # True
is_video_path("/path/to/video.MOV") # True (case-insensitive)
is_video_path("presentation.avi") # True
is_video_path("document.txt") # False
is_video_path(".mov") # True (dotfile support)from video_extensions import VIDEO_EXTENSIONS, VIDEO_EXTENSIONS_LOWER
# VIDEO_EXTENSIONS is a frozenset of all known video extensions
print(len(VIDEO_EXTENSIONS)) # 36
"mp4" in VIDEO_EXTENSIONS # True
"txt" in VIDEO_EXTENSIONS # False
# VIDEO_EXTENSIONS_LOWER contains all extensions in lowercase
# Useful for case-insensitive lookups without calling .lower() repeatedly
"MP4" in VIDEO_EXTENSIONS_LOWER # True (case-insensitive)
# Iterate over all extensions
for ext in sorted(VIDEO_EXTENSIONS):
print(ext)The package includes support for 36 video file extensions:
- Common formats: mp4, mov, avi, mkv, webm, flv, wmv, mpg, mpeg
- Streaming: m3u8, m4v, m4p, ogv, ogg
- Professional: mxf, drc, aaf, roq
- Legacy: 3gp, 3g2, asf, vob, rm, rmvb, qt
- Specialized: avchd, m2v, mp2, mpe, mpv, mng, nsv, svi, yuv, wmv
Contributions are welcome! Please read our Contributing Guide for details on our code of conduct, development setup, and the process for submitting pull requests.
If you find this library helpful:
- ⭐ Star the repository
- 🐛 Report issues
- 🔀 Submit pull requests
- 💝 Sponsor on GitHub
This package is a Python port of the video-extensions npm package by Sindre Sorhus.
MIT © Y. Siva Sai Krishna - see LICENSE for details.
Author's GitHub • Author's LinkedIn • Package on PyPI • GitHub Repository • Report Issues • Changelog • Release History