Skip to content

A place where one can get guidance on which Python video decoder is best suited for their project based on performance benchmarks.

License

Notifications You must be signed in to change notification settings

NevermindNilas/python-decoders-benchmarks

Repository files navigation

python-decoders-benchmarks

License: BSD 3-Clause

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.

Overview

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.

Features

  • 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

Benchmark Results Example

Benchmark Chart (Results generated by the benchmark script. Actual performance will vary based on your system hardware and the video file.)

Installation

  1. Clone the repository:
    git clone https://github.com/NevermindNilas/python-decoders-benchmarks.git
    cd python-decoders-benchmarks
  2. Create a virtual environment (recommended):
    python -m venv venv
    source venv/bin/activate  # On Windows use `venv\Scripts\activate`
  3. Install dependencies:
    pip install -r requirements.txt
    Note: Ensure you have FFmpeg installed and accessible in your system's PATH, as several backends depend on it.

Usage

Run the main benchmark script (main.py) from the root directory:

python main.py

Contributing

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.

License

This project is licensed under the BSD 3-Clause License - see the LICENSE file for details.

Plans

  • 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.

About

A place where one can get guidance on which Python video decoder is best suited for their project based on performance benchmarks.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages