简体   繁体   English

将其他数据嵌入UDP视频流Python OPENCV

[英]Embedding other data into a UDP video stream Python OPENCV

I am trying to stream video to be anaylised on clients from a server. 我正在尝试将视频流式传输到服务器上的客户端上。

I am using vidgears to create a ffmpeg UDP stream for the clients to connect to. 我正在使用vidgears为客户端连接创建一个ffmpeg UDP流。

However, I need to have a centeralised frame count to be able to sync up all the data the clients give. 但是,我需要有一个集中的帧数,以便能够同步客户端提供的所有数据。

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? 

Server: 服务器:

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)

class WriteGearStream(WriteGear): class 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

Does anyone know how to get a frame count that is synced with the server? 有谁知道如何获得与服务器同步的帧数?

Thanks! 谢谢!

I'm the author of VidGear Video Processing python library. 我是VidGear视频处理python库的作者。 This isn't the right way to use the WriteGear API, nor it is designed for this purpose and therefore I'm afraid will not work. 这不是使用WriteGear API的正确方法,也不是为此目的而设计的,因此我担心它不起作用。

Kindly use VidGear's new NetGear API which is exclusively designed to transfer video frames synchronously between interconnecting systems over the network in real-time. 请使用VidGear的新NetGear API ,该API专门用于通过网络实时在互连系统之间同步传输视频帧。 This new API implements a high-level wrapper around PyZmQ python library that contains python bindings for ZeroMQ - a high-performance asynchronous distributed messaging library that aims to be used in distributed or concurrent applications. 这个新的API实现了PyZmQ python库的高级包装,它包含ZeroMQ的python绑定 - ZeroMQ是一个高性能的异步分布式消息库,旨在用于分布式或并发应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM