【发布时间】: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