使用 GStreamer 通过 UDP 发送 RAW 视频

问题描述 投票:0回答:1

我正在尝试使用

gst-launch-1.0
通过 UDP 将
.avi
文件中的 RAW 视频数据从网络上的一台计算机发送到另一台计算机,因此我最终可以将其保存为
.y4m
文件。源计算机上的管道不会返回错误,但接收器计算机上的管道会返回错误。

这是我用于源计算机的管道:

gst-launch-1.0 -v -e filesrc location=input.avi ! h264parse ! avdec_h264 ! rtpvrawpay ! \
udpsink host=192.168.1.167 port=7001

对于水槽电脑(

192.168.1.167
),我使用:

gst-launch-1.0 -v -e udpsrc uri=udp://0.0.0.0 port=7001 ! \
"application/x-rtp,media=(string)video,clock-rate=(int)90000,encoding-name=(string)RAW,\
sampling=(string)YCbCr-4:2:0,depth=(string)8,width=(string)1280,height=(string)720,\
colorimetry=(string)SMPTE240M,payload=(int)96,ssrc=(uint)878094790,\
timestamp-offset=(uint)1636480077,seqnum-offset=(uint)25415,a-framerate=(string)60,\
timestamp=(uint)1636480077,seqnum=(uint)25515" ! \
rtpvrawdepay ! videoconvert ! video/x-raw,framerate=60/1,format=I420 ! filesink location=output.y4m

此管道返回错误:

ERROR: from element /GstPipeline:pipeline0/GstUDPSrc:udpsrc0: Internal data stream error.
Additional debug info:
../gstreamer/subprojects/gstreamer/libs/gst/base/gstbasesrc.c(3132): gst_base_src_loop (): /GstPipeline:pipeline0/GstUDPSrc:udpsrc0:
streaming stopped, reason not-negotiated (-4)

我从源计算机上

application/x-rtp
的详细输出中获得了
gst-launch-1.0
的上限。我尝试了带有和不带有
{ssrc, timestamp-offset, seqnum-offset, timestamp, seqnum}
参数的上限,因为我注意到每次运行时这些都会发生变化,但它仍然不起作用。

更重要的是,通过 UDP 发送 H.264 视频的类似管道系统工作得很好;我将下面的源管道和接收管道作为示例:

来源
gst-launch-1.0 -v -e filesrc location=input.avi ! decodebin ! videoconvert ! \
x264enc key-int-max=30 ! h264parse config-interval=-1 ! rtph264pay ! \
udpsink host=192.168.1.167 port=7001
水槽
gst-launch-1.0 udpsrc uri=udp://0.0.0.0 port=7001 ! \
application/x-rtp,media=video,clock-rate=90000,encoding-name=H264,payload=96 ! \
rtph264depay ! avdec_h264 ! queue ! autovideosink sync=false

此组合可以在屏幕上显示视频,没有任何问题。

这里有什么问题?

udp gstreamer
1个回答
0
投票

首先确保您的 input.avi 源具有 H264 视频(decodebin 可以管理其他编解码器,但您的管道不会)。

gst-discoverer-1.0 input.avi

可能的原因是 RAW 视频可能会产生比 H264 压缩视频大得多的数据包。

您可以尝试增加内核套接字最大缓冲区大小(您需要发送方和接收方的 root 权限才能执行此操作):

# Increase max kernel socket buffer size to 1M or more on receiver side with:
sudo sysctl -w net.core.rmem_max=1000000

# Then use property buffer-size of udpsrc such as:
gst-launch-1.0 -v -e udpsrc uri=udp://0.0.0.0 port=7001 buffer-size=1000000 ! ...
# Increase max kernel socket buffer size to 1M or more on sender side with:
sudo sysctl -w net.core.wmem_max=1000000

# and use buffer-size property of udpsink as well:
gst-launch-1.0 ... ! udpsink host=192.168.1.167 port=7001 buffer-size=1000000
© www.soinside.com 2019 - 2024. All rights reserved.