简体   繁体   English

ffmpeg 在 RTP 上解码 h264 stream 真的很慢

[英]ffmpeg is really slow at decoding h264 stream over RTP

I need some help getting ffplay to receive and decode a Real Time stream encoded in h264.我需要一些帮助让ffplay接收和解码以 h264 编码的实时 stream。

I'm trying to make a point-to-point stream between computer A receiving video frames from a Kinect and computer B running ffplay to show the livestream.我正在尝试在从 Kinect 接收视频帧的计算机 A 和运行 ffplay 的计算机 B 之间建立点对点 stream 以显示直播。

These are the commands I'm running on both computers.这些是我在两台计算机上运行的命令。

Computer A (RPI 3)计算机 A (RPI 3)

ffmpeg -f rawvideo -vcodec rawvideo -pix_fmt rgb24 -s 640x480 -i - -threads 4 -preset ultrafast -codec:v libx2 64 -an -f rtp rtp://192.168.0.100:2000

This is what ffmpeg outputs:这是ffmpeg输出:

fps= 14 q=12.0 size=856kB time=00:00:05.56 bitrate=1261.4kbits/s speed=0.54x

The out stream runs in between 10-20 frames.输出 stream 运行在 10-20 帧之间。 It's not good, but I can work with that.这不好,但我可以用它。

Computer B电脑B

ffplay -protocol_whitelist "file,udp,rtp" -probesize 32 -sync ext -i streaming.sdp

streaming.sdp流媒体.sdp

v=0
0=- 0 0 IN IP4 127.0.0.1
s=No Name
c=IN IP4 192.168.0.100
t=0 0
a=tool:libavformat 57.56.100
m=video 2000 RTP/AVP 96
a=rtpmap:96 H264/90000
a=fmtp:96 packetization-mode=1

I'm getting the stream, but at about 0.0001fps which is clearly bad.我得到的是 stream,但速度约为 0.0001fps,这显然很糟糕。 My guess is I'm missing something on the ffplay command, since ffmpeg shows a more stable and fast stream, but I can't seem to find what I'm missing.我的猜测是我在ffplay命令上遗漏了一些东西,因为ffmpeg显示出更稳定和快速的 stream,但我似乎找不到我遗漏的东西。

The problem wasn't on ffmpeg, but on the code I wrote that was grabbing the data from the device.问题不在 ffmpeg 上,而是在我编写的从设备中获取数据的代码上。 I was receiving the same frame multiple times, and blocking the thread capturing data, making most of the frames a duplicate of the first one.我多次收到相同的帧,并阻止线程捕获数据,使大多数帧与第一个帧重复。

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

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