A buffered and threaded wrapper for the OpenCV VideoCapture object. Can speed up video decoding significantly. Supports "with"-syntax.
Go to file
Askill ec9a48670c . 2020-12-29 10:55:45 +01:00
README.md initial 2020-12-29 10:54:52 +01:00
VideoReader.py initial 2020-12-29 10:54:52 +01:00
test.py initial 2020-12-29 10:54:52 +01:00

README.md

CV2 Threaded Video Capture

Not much to say here, it enables you to read an entire video or a number of frames from a video in an extra thread with some nice syntax.

This project was initially part of my video synopsis project, wich is why the config dict() is required.

Full video

from VideoReader import VideoReader
import os

fileName = "out.mp4"
dirName = os.path.join(os.path.dirname(__file__), "generate test footage")

config = {}
config["inputPath"] = os.path.join(dirName, fileName)
config["videoBufferLength"] = 100

with VideoReader(config) as reader:
    while not reader.videoEnded():
        framenumber, frame = reader.pop()
        print(framenumber)

Selection of Frames

from VideoReader import VideoReader
import os

fileName = "out.mp4"
dirName = os.path.join(os.path.dirname(__file__), "generate test footage")

config = {}
config["inputPath"] = os.path.join(dirName, fileName)
config["videoBufferLength"] = 100

frameList = list(range(100, 500))

with VideoReader(config, frameList) as reader:
    while not reader.videoEnded():
        framenumber, frame = reader.pop()
        print(framenumber)