import cv2 # from fHDHR.exceptions import TunerError class Plugin_OBJ(): def __init__(self, fhdhr, plugin_utils, stream_args, tuner): self.fhdhr = fhdhr self.plugin_utils = plugin_utils self.stream_args = stream_args self.tuner = tuner def get(self): def generate(): chunk_counter = 0 vid_cap = cv2.VideoCapture(self.stream_args["stream_info"]["url"]) try: while (vid_cap.isOpened()): chunk_counter += 1 self.fhdhr.logger.debug("Reading Chunk #%s" % chunk_counter) chunk = vid_cap.read() if not chunk: break yield chunk except Exception as err: self.fhdhr.logger.error("Chunk #%s unable to process: %s" % (chunk_counter, err)) return generate()