CV2.VideoWriter没有编码/未写入原始视频?

时间:2020-07-20 17:08:44

标签: python opencv video-streaming video-processing codec

我正在使用python从IP摄像机录制视频。这是一台HIKVISION相机,并且拥有自己的H264编码器。因此,当视频流到达我的PC时,它已经被解码和压缩,因此可以使用CV2保存视频。VideoWriter将权重分配给我的CPU,因为视频再次被编码了。整个过程变慢了,结果是滞后的图像,而不是我不写图像时没有的延迟。 那么,有什么方法可以编写视频(使用CV)而不进行编码吗?只是写我从网络摄像机获得的数据?

def PTZRecord():
    print('PTZ Record')
    filename = GetFileName()
    fullfilename = filename + '.PTZ.avi'
    fourcc = cv2.VideoWriter_fourcc(*'XVID')
    out = cv2.VideoWriter(fullfilename, fourcc, RecordFPS, (PTZHigth, PTZWidth))
    PTZStream = cv2.VideoCapture(PTZURL)

    while True:
        ret, frame = PTZStream.read()
        cv2.imshow("PTZ Frame", frame)
        out.write(frame)
        if cv2.waitKey(1) & 0xFF == ord('q'):
            break

    out.release()
    PTZStream.release()
    cv2.destroyAllWindows()

感谢分配。

0 个答案:

没有答案