以 VP9、VP8 或 H.264 数据流式传输数据,但将其以 .mov 格式存储在 AWS 上的 s3 存储桶中

问题描述

我可以使用以下代码从 RTSP 相机收集帧。但是需要帮助将数据作为视频文件存储在 S3 存储桶中。但是存储帧会占用大量存储空间。

youtube 等平台如何存储流媒体数据?如何以 VP9、VP8 或 H.264 数据流式传输数据,但以 .mov 格式将其存储在 AWS 上?

需要减少网络使用和存储使用。

        def __init__(self,src=0):
        # Set camera config object to 'src' variable

        # Create CV2 stream object
        self.camera = src['rtsp_link']
        self.capture = cv.VideoCapture(self.camera)

        # Queue created
        self.q = queue.Queue(maxsize=1)

        # Camera id that maps to sqlite table name
        self.cam_id = src['cam_id']

        # Lower Frames per second reduces network usage and cpu/Memory
        self.resize = (int(self.capture.get(3)/src['resize_factor']),int(self.capture.get(4)/src['resize_factor']))

        # Start the thread to read frames from the video stream
        self.thread = Thread(target=self.update,args=())
        self.thread.daemon = True
        self.thread.start()

        self.msgBody = {}

        print("Program initialized")
        self.debug_flag = 0

    def update(self):
        # Read the next frame from the stream in a different thread
        while True:
            if self.capture.isOpened():
                (self.status,self.frame) = self.capture.read()
                while not self.status:
                    print("Video Stream Could not read at: {}".format(time.time()))
                    self.capture.release()
                    time.sleep(5)
                    try:
                        self.capture = cv.VideoCapture(self.camera)
                        if self.capture.isOpened():
                            print("Video stream reconnected")
                            (self.status,self.frame) = self.capture.read()
                    except:
                        print("Unable to reconnect to camera stream. Alert!")

                    pass
                if not self.q.empty():
                    try:
                        # discard prevIoUs (unprocessed) frame
                        self.q.get_Nowait()
                    except queue.Empty:
                        print("No frames in queue.")
                        pass
                self.q.put(self.frame)
                if self.debug_flag:
                    print("Queue updated.")

想知道这是否有帮助

cv2.VideoWriter_fourcc(‘H’,’2′,’6′,’4′)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)