美文网首页
视频流读取

视频流读取

作者: 草帽lufei | 来源:发表于2019-10-12 19:24 被阅读0次

    写入 rtsp 视频流

    # 从本地设备获取视频
    ffmpeg -i /dev/video0 -rtsp_transport tcp -f rtsp rtsp://192.168.xxx.xxx:xxx/test
    # 从视频文件获取
    ffmpeg -re -i ./1.mp4 -vcodec copy -rtsp_transport tcp -f rtsp rtsp://192.168.xxx.xxx:xxx/test
    

    rtsp 读取视频流

    # coding=utf-8
    
    import time
    VIDEO_PATH = "rtsp://192.168.xxx.xxx:xxx/test"
    def extract_frames(video_path):
        import cv2
        video = cv2.VideoCapture(video_path)
        while True:
            _, frame = video.read()
            if frame is None:
                time.sleep(0.5)
                print("wait 0.5 second to retry...")
            else:
                cv2.imshow("Frame", frame)
                if cv2.waitKey(1) & 0xFF == ord('q'):
                    break
    if __name__ == '__main__':
        extract_frames(VIDEO_PATH)
    

    相关文章

      网友评论

          本文标题:视频流读取

          本文链接:https://www.haomeiwen.com/subject/zpqvcqtx.html