A place where one can get guidance on which Python video decoder is best suited for their project based on performance benchmarks.
All benchmarks standardize on numpy
arrays in RGB24 (C, H, W) format as the final output. Performance measurements include any necessary color space conversions (e.g., BGR→RGB for OpenCV) to ensure fair comparison across all libraries.
This project benchmarks the performance (Frames Per Second - FPS) of various Python libraries used for video decoding. The goal is to provide developers with data to make informed decisions when choosing a video decoding backend for their applications.
- Benchmarks multiple popular Python video decoding libraries:
- PyAV
- OpenCV (via
opencv-python
) - FFmpeg (via
subprocess
) - ImageIO-FFmpeg
- FFmpegCV (with block and no-block)
- Decord ( not recommended due to OOM Issues)
- TorchAudio ( requires FFMPEG v6, I can't test it. )
- DeffCode
- BasswoodAV ( pyav continutation )
- Video-Reader-RS ( Base run uses pure rgb24 decode afaik whilst the "YuvToRGB" run decodes in yuv420p and then converts it to rgb24 on the rust side to speed things up, altho' I am not entirely sure how this would hold up if the input was in other color formats say yuv422, yuv444 or rgb48 )
- FFmpeg-Python ( Altho' in theory it serves the same purpose as the ffmpeg-subprocess run, I still decided to add it to see if it adds any extra overhead over your run of the mill ffmpeg subprocess pipe )
- Max Theoretical: Baseline performance using raw
ffmpeg
subprocess (decodeWithMaxTheoretical
) to estimate maximum hardware FPS with minimal overhead for both RGB24 and YUV420p
(Results generated by the benchmark script. Actual performance will vary based on your system hardware and the video file.)
- Clone the repository:
git clone https://github.com/NevermindNilas/python-decoders-benchmarks.git cd python-decoders-benchmarks
- Create a virtual environment (recommended):
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
- Install dependencies:
Note: Ensure you have FFmpeg installed and accessible in your system's PATH, as several backends depend on it.
pip install -r requirements.txt
Run the main benchmark script (main.py
) from the root directory:
python main.py
Contributions are welcome! If you want to add another decoder, improve the benchmarking methodology, or fix a bug, please feel free to open an issue or submit a pull request.
This project is licensed under the BSD 3-Clause License - see the LICENSE file for details.
- Add 1080p benchmarks
- Add a tracker to the GH Runner that keeps track of changes from week to week logging whether the performance of any library has improved or decreased.