【问题标题】:Embedding other data into a UDP video stream Python OPENCV将其他数据嵌入到 UDP 视频流中 Python OPENCV
【发布时间】:2019-05-19 11:38:09
【问题描述】:

我正在尝试从服务器流式传输视频以在客户端上进行分析。

我正在使用 vidgears 创建一个 ffmpeg UDP 流供客户端连接。

但是,我需要有一个集中的帧计数,以便能够同步客户端提供的所有数据。

Client:    
cap = cv2.VideoCapture('udp://localhost:23000')   
while cap.isOpened(): 
    print(cap.get(cv2.CAP_PROP_FRAME_COUNT))

Will only get me the frame count from the time the client connected. 

Is there a way to embed a timecode or frame count when I am stream out the video so I can sync them all up? 

服务器:

i = 0
output_params = {"-vcodec": "mpeg4", '-f': 'mpegts'}
streamer = WriteGearStream(output_filename='udp://localhost:23000', compression_mode=True, logging=True, **output_params)
cap = cv2.VideoCapture(0)
while cap1.isOpened():
   i+=1
   ret, frame = cap.read()
   cap.set(cv2.CAP_PROP_POS_FRAMES, i)
   streamer.write(vis)

类 WriteGearStream(WriteGear):

def __init__(self, output_filename='', compression_mode=True, custom_ffmpeg='', logging=False, **output_params):
    super(WriteGearStream, self).__init__(output_filename='temp.pm4', compression_mode=compression_mode, custom_ffmpeg=custom_ffmpeg, logging=logging, **output_params)
    self.out_file = output_filename

有谁知道如何获取与服务器同步的帧数?

谢谢!

【问题讨论】:

    标签: python opencv server udp video-streaming


    【解决方案1】:

    我是VidGear Video Processing python 库的作者。 这不是使用 WriteGear API 的正确方法,也不是为此目的而设计的,因此恐怕行不通。

    请使用 VidGear 的新 NetGear API,它专门用于通过网络在互连系统之间实时同步传输视频帧。 这个新 API 实现了 PyZmQ python 库的高级包装器包含 ZeroMQ 的 python 绑定 - 一个高性能异步分布式消息传递库,旨在用于分布式或并发应用程序。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-06-11
    • 2020-08-09
    • 2013-02-07
    • 1970-01-01
    • 2012-06-20
    • 2014-11-29
    • 2014-01-11
    • 1970-01-01
    相关资源
    最近更新 更多