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

[Question]: most performant way to decode many small videos #43

Closed KDeser closed 11 months ago

KDeser commented 11 months ago

Issue guidelines

Issue Checklist

Describe your Question

Is there a way to reuse a decoder for multiple videos to reduce the delay between each video? It's actually taking longer to instantiate the decoder object for each video than it does to generate and analyze the frames. There are many thousands of these videos and they are individually only ~100 frames in length.

Here's a (simplified) version of my code.

Thanks!

Terminal log output(Optional)

No response

Python Code(Optional)

from deffcode import FFdecoder
for video_path in video_paths:
    # ~0.4 seconds
    decoder = FFdecoder(
            video_path, frame_format="bgr24"
        ).formulate()
    # ~0.2 seconds
    frames = [f for f in decoder.generateFrame()]
    # ~0.1 seconds
    analyze_frames(frames)

DeFFcode Version

0.2.5

Python version

3.9

Operating System version

Windows 10

Any other Relevant Information?

No response

abhiTronix commented 11 months ago

@KDeser Thank you for you issue. Right now, the current structuring of DeFFcode library is more focused on sanitizing the input parameters and source provide for error-free pipeline, and goes through series of methods to check them on initialization. So the performance will not be great for short videos but rather more tuned for longer duration videos. I'll recommend using other options such as Pillow or OpenCV for this purpose.