abhiTronix / deffcode

A cross-platform High-performance FFmpeg based Real-time Video Frames Decoder in Pure Python 🎞️⚡
https://abhitronix.github.io/deffcode
Apache License 2.0
178 stars 3 forks source link

✨ [v0.2.1] Implement support for live input devices/sources. (Fixes #16) #17

Closed abhiTronix closed 2 years ago

abhiTronix commented 2 years ago

Brief Description

Added support for Live-Device Inputs such as Webcams, Screen-capture, virtual webcams will be added to DeFFcode.

PR Key features:

✨ New Features

⚡️ Updates/Improvements

💥 Updates/Changes

🐛 Bug-fixes

Requirements / Checklist

Related Issue

16

Context

The crucial VideoCapture support for live(realtime) device inputs(such as Webcams, Screen-capture, virtual webcams etc.) are still missing from Deffcode. This PR will implementation this functionality.

Types of changes

Miscellaneous (if available):

Example code for real-time screen-capturing on windows:

# import the necessary packages
from deffcode import FFdecoder
import cv2

# initialize and formulate the decoder for BGR24 output
decoder = FFdecoder("desktop", source_demuxer="gdigrab", frame_format="bgr24", verbose=True).formulate()

# grab the RGB24(default) frame from the decoder
for frame in decoder.generateFrame():

    # check if frame is None
    if frame is None:
        break

    # Show output window
    cv2.imshow("Output", frame)

    # check for 'q' key if pressed
    key = cv2.waitKey(1) & 0xFF
    if key == ord("q"):
        break

# close output window
cv2.destroyAllWindows()
# terminate the decoder
decoder.terminate()
codecov[bot] commented 2 years ago

Codecov Report

Merging #17 (a22465f) into master (f3a9e74) will decrease coverage by 0.13%. The diff coverage is 87.50%.

@@            Coverage Diff             @@
##           master      #17      +/-   ##
==========================================
- Coverage   96.21%   96.08%   -0.14%     
==========================================
  Files           6        6              
  Lines         582      587       +5     
==========================================
+ Hits          560      564       +4     
- Misses         22       23       +1     
Impacted Files Coverage Δ
deffcode/version.py 100.00% <ø> (ø)
deffcode/ffdecoder.py 90.90% <40.00%> (-0.97%) :arrow_down:
deffcode/ffhelper.py 100.00% <100.00%> (ø)
deffcode/sourcer.py 98.11% <100.00%> (+0.67%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update f3a9e74...a22465f. Read the comment docs.

abhiTronix commented 2 years ago

Finally it worked. FK U v4l2loopback. 🖕🏽