pymp4v2 - Python Bindings for mp4v2
Alpha. Python bindings for a subset of the mp4v2 C API (v2.1.3). This is not a complete wrap of mp4v2: hint/streaming, generic iTMF, and most profile-level APIs are out of scope for Alpha.
pymp4v2.MP4File— open withmode"r"/"w"/"a"("r+"), context manager,.tracks/Track,.tags/Tags,duration/timescale,get_info(),optimize(),save(),close()pymp4v2.raw— file I/O (MP4CreateExfor ftyp brands / iods; no I/O callbacks), tracks, file/track properties (named + generic get/set), sample read/write/copy (bytes, including lookup by time), iTMF tags (string + numeric setters, artwork asbytes), chapters (MP4GetChapters/MP4SetChapters/ Qt + Nero)pymp4v2.MP4Error— raised on C failures (false/MP4_INVALID_*); subclass ofRuntimeError- PEP 561 type stubs (
.pyi+py.typed) ship in the wheel
Not bound (Alpha, out of scope): iTMF generic atoms, hint/streaming, custom I/O callbacks, MP4ReadProvider, MPEG-4 profile-level setters.
- Python 3.9+
- C++17 compatible compiler
- CMake 3.28+ (pulled in by the build backend if missing)
- Ninja (optional; pulled in by the build backend)
The extension is built with scikit-build-core. mp4v2 v2.1.3 is fetched by CMake FetchContent and statically linked.
- scikit-build-core >= 0.10
- pybind11 >= 2.12
See the Installation file.
See the Usage file.
Scripts in examples/ (dump_info.py, retag.py, extract_samples.py) exercise the same APIs against a real file.
See the API file.
Tests generate a tiny MP4 with MP4Create; they do not need tests/sample.mp4.
pip install -e .[dev]
pytest tests/See the CONTRIBUTING.md file.
The pymp4v2 bindings are MIT.
The native extension statically links mp4v2 v2.1.3, which is MPL 1.1. See NOTICE for the pinned tarball URL and SHA256. The corresponding mp4v2 source is the official v2.1.3 release.
- mp4v2 library authors for the underlying C++ library
- Pybind11 team for the excellent binding infrastructure
If you encounter any issues or have questions, please file an issue on the GitHub issue tracker.
See the CHANGELOG.md file for a history of changes to the project.