本文介绍了通过TCP查看h264流的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个基于wifi的小型FPV无人机摄像头.我已经设法使其可以使用python下载和保存h264文件.

I have a small wifi based FPV camera for a drone. I've managed to get it to the point where I can download and save an h264 file using python.

TCP_IP = '193.168.0.1'
TCP_PORT = 6200
BUFFER_SIZE = 2056

f = open('stream.h264', 'wb')
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((TCP_IP,TCP_PORT))
while True:
    data = sock.recv(BUFFER_SIZE)
    f.write(data)
    print("Writing")
sock.close()
f.close()

我已经尝试了一段时间,现在正在播放视频流.我找到了流,可以下载并保存它,但是现在我想实时打开它.我曾尝试将VLC的开放式网络流"与各种选项结合使用,但似乎都不起作用.

What I've been trying to do for a while now is play the stream. I've found the stream, I can download it and save it, but now I want to open it live.I've tried using VLC's 'open network stream' with a variety of options, but none of them seemed to work.

推荐答案

我已成功使用

data = sock.recv(BUFFER_SIZE) sys.stdout.buffer.write(data)

data = sock.recv(BUFFER_SIZE) sys.stdout.buffer.write(data)

然后让mplayer通过管道传递输入

and then having mplayer pipe the input

python cam.py - | mplayer -fps 20 -nosound -vc ffh264 -noidx -mc 0 -

这篇关于通过TCP查看h264流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-13 21:16