Deffcode
A cross-platform High-performance FFmpeg based Real-time Video Frames Decoder in Pure Python 🎞️⚡
Install / Use
/learn @abhiTronix/DeffcodeREADME

[![Build Status][github-cli]][github-flow] [![Codecov branch][codecov]][code] [![Azure DevOps builds (branch)][azure-badge]][azure-pipeline]
[![Glitter chat][gitter-bagde]][gitter] [![Build Status][appveyor]][app] [![PyPi version][pypi-badge]][pypi]
[![Code Style][black-badge]][black]
[Releases][release] | [Recipes][recipes] | [Documentation][docs] | [Installation][installation-notes] | License
</div> <div align="center">
DeFFcode - A cross-platform High-performance Video Frames Decoder that flexibly executes <br>FFmpeg pipeline inside a subprocess pipe for generating real-time, low-overhead, <br>lightning fast video frames with robust error-handling <br>in just a few lines of python code ⚡
</div>
<ins>Highly Adaptive</ins> - DeFFcode APIs implements a standalone highly-extensible wrapper around [FFmpeg][ffmpeg] multimedia framework. These APIs supports a wide-ranging media streams as input source such as [live USB/Virtual/IP camera feeds][capturing-and-previewing-frames-from-a-webcam], [regular multimedia files][decoding-video-files], [screen recordings][capturing-and-previewing-frames-from-your-desktop], [image sequences][decoding-image-sequences], [network URL schemes][decoding-network-streams] (such as HTTP(s), RTP/RSTP, etc.), so on and so forth.
<ins>Highly Flexible</ins> - 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.
<ins>Highly Convenient</ins> - 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][decoding-camera-devices-using-indexes] 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][basic-recipes] to [Advanced][advanced-recipes] skill levels.
- Hands down the easiest [Index based Camera Device Capturing][decoding-camera-devices-using-indexes], similar to OpenCV.
- Easy to code Real-time [Simple][transcoding-live-simple-filtergraphs] & [Complex][transcoding-live-complex-filtergraphs] Filtergraphs. (Yes, You read it correctly "Real-time"!)
- Lightning fast dedicated GPU-Accelerated Video [Decoding][hardware-accelerated-video-decoding] & [Transcoding][hardware-accelerated-video-transcoding].
- Enables precise FFmpeg [Key-frame Seeking][extracting-key-frames-as-png-image] with pinpoint accuracy.
- Effortless [Metadata Extraction][extracting-video-metadata] 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.7+, 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][installation-notes] to install DeFFcode on your machine.
<br> <br>Recipes a.k.a Examples:
Once you have DeFFcode installed, checkout our Well-Documented [Recipes 🍱][basic-recipes] for usage examples:
Note In case you're run into any problems, consult our [Help section][help].
A. [Basic Recipes 🍰][basic-recipes]: Recipes for beginners of any skill level to get started.
<br> <div align="center"> <a href="https://abhitronix.github.io/deffcode/latest/recipes/basic/transcode-live-frames-simplegraphs/#transcoding-trimmed-and-reversed-video"><img src="https://user-images.githubusercontent.com/34266896/211499038-46cc246d-843b-4c89-8e9a-5536395da9e7.gif" title="Click to view source code" width="70%" /> </a> <br> <sub><i>Big Buck Bunny Reversed using Live Simple Filtergraph</i></sub> </div> <br> <details open> <summary><b>Basic Decoding Recipes</b></summary>- [Accessing RGB frames from a video file][accessing-rgb-frames-from-a-video-file]
- [Capturing and Previewing BGR frames from a video file][capturing-and-previewing-bgr-frames-from-a-video-file] (OpenCV Support)
- [Playing with any other FFmpeg pixel formats][playing-with-any-other-ffmpeg-pixel-formats]
- [Capturing and Previewing frames from a Looping Video][capturing-and-previewing-frames-from-a-looping-video]
- [Enumerating all Camera Devices with Indexes][enumerating-all-camera-devices-with-indexes]
- [Capturing and Previewing frames from a Camera using Indexes][capturing-and-previewing-frames-from-a-camera-using-indexes]
- [Capturing and Previewing frames from a HTTPs Stream][capturing-and-previewing-frames-from-a-https-stream]
- [Capturing and Previewing frames from a RTSP/RTP Stream][capturing-and-previewing-frames-from-a-rtsprtp-stream]
- [Capturing and Previewing frames from Sequence of images][capturing-and-previewing-frames-from-sequence-of-images]
- [Capturing and Previewing frames from Single looping image][capturing-and-previewing-frames-from-single-looping-image]
- [Transcoding video using OpenCV VideoWriter API][transcoding-video-using-opencv-videowriter-api]
- [Transcoding lossless video using WriteGear API][transcoding-lossless-video-using-writegear-api]
- [Transcoding Trimmed and Reversed video][transcoding-trimmed-and-reversed-video]
- [Transcoding Cropped video][transcoding-cropped-video]
- [Transcoding Rotated video (with
rotatefilter)][transcoding-rotated-video-with-rotate-filter] - [Transcoding Rotated video (with
transposefilter)][transcoding-rotated-video-with-transpose-filter] - [Transcoding Horizontally flipped and Scaled video][transcoding-horizontally-flipped-and-scaled-video]
- [Extracting Key-frames as PNG image][extracting-key-frames-as-png-image]
- [Generating Thumbnail with a Fancy filter][generating-thumbnail-with-a-fancy-filter]
- [Extracting video metadata using Sourcer API][extracting-video-metadata-using-sourcer-api]
- [Extracting video metadata using FFdecoder API][extracting-video-metadata-using-ffdecoder-api]
B. [Advanced Recipes 🥐][advanced-recipes]: Recipes to take your skills to the next level.
<br> <p align="center"> <a href="https://abhitronix.github.io/deffcode/latest/recipes/advanced/decode-live-virtual-sources/#generate-and-decode-frames-from-mandelbrot-test-pattern-with-vectorscope-waveforms"><img src="https://user-images.githubusercontent.com/34266896/211498819-13fe0487-e843-4315-b4f3-c881de6c8c4a.gif" alt="mandelbrot test pattern" title="Click to view source code" width="70%" /></a> <br> <sub><i>Live Mandelbrot pattern with a Vectorscope & two Waveforms</i></sub> </p> <br> <details open> <summary><b>Advanced Decoding Recipes</b></summary>- [Generate and Decode frames from Sierpinski pattern][generate-and-decode-frames-from-sierpinski-pattern]
- [Generate and Decode frames from Test Source pattern][generate-and-decode-frames-from-test-source-pattern]
- [Generate and Decode frames from Gradients with custom Text effect][generate-and-decode-frames-from-gradients-with-custom-text-effect]
- [Generate and Decode frames from Mandelbrot test pattern with vectorscope & waveforms][generate-and-decode-frames-from-mandelbrot-test-pattern-with-vectorscope-waveforms]
- [Generate and Decode frames from Game of Life Visualization][generate-and-decode-frames-from-game-of-life-visualization]
- [Capturing and Previewing frames from a Webcam using Custom Demuxer][capturing-and-previewing-frames-from-a-webcam-using-custom-demuxer]
- [Capturing and Previewing frames from your Desktop][capturing-and-previewing-frames-from-your-desktop] (Screen Recording)
- [CUVID-accelerated Hardware-based Video Decod
