deffcode

abhiTronixApache-2.0活跃维护

纯 Python 实现的跨平台高性能 FFmpeg 实时视频帧解码器,为计算机视觉和视频处理提供低延迟的帧读取能力。

A cross-platform High-performance FFmpeg based Real-time Video Frames Decoder in Pure Python 🎞️⚡

v0.2.9发布于 2026-11-01 06:31 UTC221star7fork同步于 2026-11-10 12:04 UTC

怎么上手

README 里没有找到可直接复制的安装命令

README 里没有找到可直接复制的安装命令,请到 README 或官方文档查看安装方式。

硬件要求按 README 关键词推断
需要 CUDA
下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

这个项目的说明还在生成中,先参考下面「最近发版」和 README。

最近发版

5 个版本v0.2.9
  1. v0.2.9最新正式版2026-11-01 · 2026-11-01 06:31 UTC

    Summary:

    This release introduces powerful new capabilities to FFdecoder, including native support for multiple FFmpeg outputs (-extra_outputs) and comprehensive stderr capture (-capture_stderr) for pipeline diagnostics. It also includes hardened subprocess termination handling, a major documentation engine migration to Zensical, and CI/CD infrastructure upgrades.

    Full Changelog : https://abhitronix.github.io/deffcode/latest/changelog/#v029-2026-11-01

    What's Changed

    ✨ New Features

    • FFdecoder: Added multiple FFmpeg outputs support via the new -extra_outputs parameter to generate additional outputs (files, streams) alongside decoded frames.
    • FFdecoder: Added FFmpeg stderr capture via the new -capture_stderr parameter to record diagnostic lines, exposing them via the new stderr_tail and returncode properties.
    • Docs: Added new Multi-Outputs Configurations recipes, including recording while decoding and encoding once to duplicate to file and stream.

    ⚡️ Updates/Improvements

    • FFdecoder: Hardened terminate() to gracefully wait for -extra_outputs to finalize and escalate signals to SIGKILL if unresponsive, while returning the proper FFmpeg exit code.
    • FFhelper: Updated check_sp_output to no longer inherit the parent's stdin (now defaults to subprocess.DEVNULL).
    • Sourcer: Dropped -clones from multi-input per-source probes.
    • Docs: Migrated the documentation engine from MkDocs to Zensical and adapted relative links to Zensical path resolution.
    • CI/CD: Pinned Linux runners to ubuntu-24.04 and added relative docs links checks before deployment.

    💥 Breaking Updates/Changes

    • None in this release.

    🐛 Bug-fixes

    • FFdecoder: Fixed terminate() skipping cleanup and losing the exit code when the FFmpeg process had already exited.
    • FFdecoder: Fixed the exit code reported on a clean stream end (now correctly returns 0 instead of the terminate signal code).
    • FFdecoder: Fixed a formatting bug in the metadata setter warning where .format() was called on the logger return value instead of the message.
    • Docs: Fixed pre-existing broken internal links for live feed devices and FFmpeg auto-installation.

    You can become a sponsor via GitHub Sponsors by clicking the button below:

    Thanks a million! 😊

  2. v0.2.82026-10-18 · 2026-10-18 05:15 UTC
    查看更新说明

    Summary:

    This release introduces crucial stability enhancements, including configurable subprocess timeouts to prevent hangs on frozen FFmpeg streams, and brings official support for Python 3.14.x. It also includes major bug fixes for multi-input filtergraphs and raises the minimum required Python version to 3.11+.

    Full Changelog: https://abhitronix.github.io/deffcode/latest/changelog/#v028-2026-10-18


    What's Changed

    ✨ New Features

    • FFhelper: Added configurable subprocess timeout support to check_sp_output to prevent indefinite hangs on frozen FFmpeg streams, featuring a graceful two-step shutdown (SIGTERM then SIGKILL).
    • Core: Added official support for Python 3.14.x.
    • Docs: Added new multi-input -filter_complex recipes, including 2x2 video grids (mosaic) via xstack and crossfade transitions via xfade.

    ⚡️ Updates/Improvements

    • FFhelper: Applied the new subprocess timeout logic to all internal FFmpeg subprocess calls and download adapters.
    • Packaging: Modernized packaging by adding Poetry fields and poetry.lock to pyproject.toml.
    • Core: Bumped Ruff target-version to py311 and modernized internal typing using typing.Self.

    💥 Breaking Updates/Changes

    • Core: Minimum Python version raised to 3.11+. Python 3.10 has reached EOL and is officially dropped.
    • FFhelper: The DEFAULT_TIMEOUT constant has been renamed to DEFAULT_TIMEOUT_REQUESTS.

    🐛 Bug-fixes

    • Sourcer: Fixed multi-input filtergraph metadata probing that previously caused composite outputs (like hstack, xstack) to report incorrect frame resolutions and yield corrupted frames.
    • FFdecoder: Fixed multi-input pipelines (e.g., xfade) truncating to the first input's frame count; they now correctly decode until EOF.
    • FFhelper: Fixed an issue where check_sp_output would hang indefinitely on frozen FFmpeg streams.

    You can become a sponsor via GitHub Sponsors by clicking the button below:

    Thanks a million! 😊

  3. v0.2.72026-04-20 · 2026-04-20 05:56 UTC
    查看更新说明

    Summary: Multi-input FFdecoder support, async per-frame metadata extraction, and high-performance luma-only YUV decoding. 🎉

    Full Changelog: https://abhitronix.github.io/deffcode/latest/changelog/#v027-2026-04-20


    What's Changed

    ✨ New Features

    • Added multi-input source list support in FFdecoder and Sourcer, enabling simultaneous decoding from multiple input streams (e.g., multiple RTSP sources).
    • Added async per-frame metadata extraction via FFmpeg's showinfo filter in FFdecoder, exposing frame number, PTS time, and keyframe info per decoded frame.
    • Added fast luma-only (-extract_luma) YUV decoding in FFdecoder — slices the Y-plane directly from YUV/NV bytestreams into a 2D uint8 ndarray, bypassing FFmpeg colorspace conversion for significant speed gains over frame_format="gray".

    ⚡️ Updates/Improvements

    • Migrated packaging from setup.py to pyproject.toml with Python 3.12/3.13 classifier support.
    • Adopted Ruff project-wide for linting and formatting, replacing flake8/black.
    • Added new documentation recipes for multi-input sources, per-frame metadata, YUV grayscale fast-path.
    • Restructured installation guide with dedicated Poetry support.

    💥 Breaking Updates/Changes

    • ☠️ Minimum supported Python version raised to 3.10+; Python 3.8 and 3.9 are no longer supported.

    🐛 Bug-fixes

    • Fixed StopIteration crash in get_supported_demuxers when FFmpeg -demuxers output lacks the expected -- separator — now returns an empty list with a warning.
    • Fixed regex expression bugs in FFhelper.get_supported_demuxers affecting multi-line output and demuxer names containing commas.

    You can become a sponsor via GitHub Sponsors by clicking the button below:

    Thanks a million! 😊

  4. v0.2.62024-07-08 · 2024-07-08 17:28 UTC
    查看更新说明

    Summary: New Parameters, Support for SRTP/RTSPS protocol, and Enhanced Video Orientation Handling and Process Termination 🎉

    📓 Complete Release Notes can be found here ↗️


    It is something I am doing with my own free time. But so much more needs to be done, and I need your help to do this. For just the price of a cup of coffee, you can make a difference 🙂

    What's Changed

    ✨ New Features

    • FFdecoder:
      • Introduced a new optional -disable_ffmpeg_window boolean parameter.
        • 💬 Prevents the FFmpeg command line window from appearing by applying the DETACHED_PROCESS flag to the subprocess FFmpeg pipeline when building .exe files on Windows in silent (verbose=False) mode.
    • Sourcer:
      • Added new parameters to metadata to accurately display video orientation.
        • Added source_video_orientation parameter (default 0.0).
        • Added output_orientation parameter (default 0.0).
    • FFHelper:
      • Added support for SRTP/RTSPS in is_valid_url function.
        • Enhanced is_valid_url method to support both RTP/RTSP and SRTP/RTSPS protocols.
        • 💬 SRTP/RTSPS extends RTSP/RTP to encrypt video/audio data using ciphers like AES with a 128-bit key.
    • Core:
      • Added official support for Python 3.11.x legacies.
    • Docs:
      • Added context and detailed instructions for Input and Output Seeking methods.
      • Added documentation for the new optional -disable_ffmpeg_window boolean parameter.

    ⚡️Updates/Improvements

    • FFdecoder:
      • Changed process termination from kill() to terminate() if the process is still running, to ensure graceful shutdown.
        • 💬 The terminate() method sends the SIGTERM signal to a process, which typically allows for a graceful shutdown. On Unix, this uses the SIGTERM signal, while on Windows, it uses TerminateProcess().
    • FFhelper:
      • Improved regex pattern in get_supported_demuxers method.
    • Sourcer:
      • Updated extract_resolution_framerate method to also return video orientation.
    • Docs:
      • Included GitHub sponsors in FUNDING.yml.
      • Removed deprecated Gitter community chat sidecard.

    💥 Breaking Updates/Changes

    • Core:
      • ☠️ Ended support for Python 3.7.x legacies.

    🐛 Bug-fixes

    • FFdecoder API:
      • Fixed regex expression bugs in get_supported_demuxers method.
  5. v0.2.52023-01-11 · 2023-01-11 05:57 UTC
    查看更新说明

    📓 Complete Release Notes can be found here ↗️


    Summary: New patch for handling YUV pixel-formats and Looping Video support 🎉

    ✨ New Features

    • FFdecoder:
      • Implemented new patch for handling YUV pixel-formats(such as YUV420p, yuv444p, NV12, NV21 etc.) for exclusive compatibility with OpenCV APIs.
        • Note: Only YUV pixel-formats starting with YUV and NV are currently supported.
      • Added new -enforce_cv_patch boolean attribute for enabling OpenCV compatibility patch.
    • Sourcer:
      • Added Looping Video support.
        • Now raw-frame numbers revert to null(None) whenever any looping is defined through filter(such as -filter_complex "loop=loop=3:size=75:start=25") or prefix("-ffprefixes":["-stream_loop", "3"]).
    • Docs:
      • Added YUV frames example code for Capturing and Previewing BGR frames from a video file recipe.
      • Added YUV frames example code for Transcoding video using OpenCV VideoWriter API recipe.
      • Added YUV frames example code for Transcoding lossless video using WriteGear API recipe.
      • Added new CUVID-accelerated Hardware-based Video Decoding and Previewing recipe.
      • Added new CUDA-accelerated Hardware-based Video Decoding and Previewing recipe.
      • Added new CUDA-accelerated Video Transcoding with OpenCV`s VideoWriter API recipe.
      • Added new CUDA-NVENC-accelerated Video Transcoding with WriteGear API recipe both for consuming BGR and NV12 frames.
      • Added new Capturing and Previewing frames from a Looping Video recipe using -stream_loop option and loop filter.
      • Added new content.code.copy and content.code.link features.

    ⚡️Updates/Improvements

    • FFhelper:
      • Replaced depreciating Retry API from requests.packages with requests.adapters.
    • Maintenance:
      • Replaced raw.github.com links with GitLab and GH links.

    🐛 Bug-fixes

    • FFdecoder API:
      • Fixed Zero division bug while calculating raw_bit_per_component.
    • FFhelper:

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    DeFFcode DeFFcode

    Build Status Codecov branch Azure DevOps builds (branch)

    Glitter chat Build Status PyPi version

    Code Style


    Releases   |   Recipes   |   Documentation   |   Installation   |   License


    DeFFcode - A cross-platform High-performance Video Frames Decoder that flexibly executes FFmpeg pipeline inside a subprocess pipe for generating real-time, low-overhead, lightning fast video frames with robust error-handling in just a few lines of python code ⚡

     

    Highly Adaptive - DeFFcode APIs implements a standalone highly-extensible wrapper around FFmpeg multimedia framework. These APIs supports a wide-ranging media streams as input source such as live USB/Virtual/IP camera feeds, regular multimedia files, screen recordings, image sequences, network URL schemes (such as HTTP(s), RTP/RSTP, etc.), so on and so forth.

    Highly Flexible - DeFFcode APIs gains an edge over other FFmpeg Wrappers by providing complete control over the underline pipeline including access to almost any FFmpeg specification thinkable such as specifying framerate, resolution, hardware decoder(s), filtergraph(s), and pixel-format(s) that are readily supported by all well known Computer Vision libraries.

    Highly Convenient - FFmpeg has a steep learning curve especially for users unfamiliar with a command line interface. DeFFcode helps users by providing similar to OpenCV, Index based Camera Device Capturing and the same standard OpenCV-Python (Python API for OpenCV) coding syntax for its APIs, thereby making it even easier to learn, create, and develop FFmpeg based apps in Python.

     

    Key features of DeFFcode

    Here are some key features that stand out:

    • High-performance, low-overhead video frames decoding with robust error-handling.
    • Flexible API with access to almost any FFmpeg specification thinkable.
    • Supports a wide-range of media streams/devices/protocols as input source.
    • Curated list of well-documented recipes ranging from Basic to Advanced skill levels.
    • Hands down the easiest Index based Camera Device Capturing, similar to OpenCV.
    • Easy to code Real-time Simple & Complex Filtergraphs. (Yes, You read it correctly "Real-time"!)
    • Native Multi-Input Source Configurations support for decoding complex topologies.
    • Native Multi-Outputs Configurations support for recording/streaming while decoding, in a single FFmpeg pipeline.
    • Lightning fast dedicated GPU-Accelerated Video Decoding & Transcoding.
    • Enables precise FFmpeg Key-frame Seeking with pinpoint accuracy.
    • Effortless Metadata Extraction from all streams available in the source.
    • Maintains the standard easy to learn OpenCV-Python coding syntax.
    • Out-of-the-box support for all prominent Computer Vision libraries.
    • Cross-platform, runs on Python 3.11+, and easy to install.

     

     

    Getting Started


    📚 Documentation: https://abhitronix.github.io/deffcode


    Installation:

    If this is your first time using DeFFcode, head straight to the Installation Notes to install DeFFcode on your machine.

    Recipes a.k.a Examples:

    Once you have DeFFcode installed, checkout our Well-Documented Recipes 🍱 for usage examples:

    Note In case you're run into any problems, consult our Help section.

    A. Basic Recipes 🍰: Recipes for beginners of any skill level to get started.

    B. Advanced Recipes 🥐: Recipes to take your skills to the next level.

    API in a nutshell:

    As a user, you just have to remember only two DeFFcode APIs, namely:

    A. FFdecoder API

    The primary function of FFdecoder API is to decode 24-bit RGB video frames from the given source:

    Note See API Reference for more in-depth information.

    # import the necessary packages
    from deffcode import FFdecoder
    
    # formulate the decoder with suitable source
    decoder = FFdecoder("https://abhitronix.github.io/html/Big_Buck_Bunny_1080_10s_1MB.mp4").formulate()
    
    # grab RGB24(default) 3D frames from decoder
    for frame in decoder.generateFrame():
        # lets print its shape
        print(frame.shape)  # (1080, 1920, 3)
    
    # terminate the decoder
    decoder.terminate()
    

    B. Sourcer API

    The primary function of Sourcer API is to gather metadata information from all multimedia streams available in the given source:

    # import the necessary packages
    from deffcode import Sourcer
    
    # initialize and formulate the decoder using suitable source
    sourcer = Sourcer(
        "https://abhitronix.github.io/html/Big_Buck_Bunny_1080_10s_1MB.mp4"
    ).probe_stream()
    
    # print metadata as `json.dump`
    print(sourcer.retrieve_metadata(pretty_json=True))
    
    {
      "ffmpeg_binary_path": "C:\\Users\\foo\\AppData\\Local\\Temp\\ffmpeg-static-win64-gpl/bin/ffmpeg.exe",
      "source": "https://abhitronix.github.io/html/Big_Buck_Bunny_1080_10s_1MB.mp4",
      "source_extension": ".mp4",
      "source_video_resolution": [1920, 1080],
      "source_video_framerate": 60.0,
      "source_video_pixfmt": "yuv420p",
      "source_video_decoder": "h264",
      "source_duration_sec": 10.0,
      "approx_video_nframes": 600,
      "source_video_bitrate": "832k",
      "source_audio_bitrate": "",
      "source_audio_samplerate": "",
      "source_has_video": true,
      "source_has_audio": false,
      "source_has_image_sequence": false
    }
    

     

     

    Contributions

    We're happy to meet new contributors💗

    We welcome your contributions to help us improve and extend this project. If you want to get involved with DeFFcode development, checkout the Contribution Guidelines ▶️

    We're offering support for DeFFcode on Gitter Community Channel. Come and join the conversation over there!

     

     

    Donations

    It is something I am doing with my own free time. But so much more needs to be done, and I need your help to do this. For just the price of a cup of coffee, you can make a difference 🙂

     

     

    Citation

    Here is a Bibtex entry you can use to cite this project in a publication:

    DOI

    @software{deffcode,
      author       = {Abhishek Thakur},
      title        = {abhiTronix/deffcode: v0.2.8},
      month        = oct,
      year         = 2026,
      publisher    = {Zenodo},
      version      = {v0.2.8},
      doi          = {10.5281/zenodo.23446604},
      url          = {https://doi.org/10.5281/zenodo.23446604},
    }
    

     

     

    Copyright

    Copyright © abhiTronix 2021

    This library is released under the Apache 2.0 License.