简体   繁体   English

如何通过UDP从GStreamer 1.0到VLC传输视频

[英]How to Stream Video over UDP from GStreamer 1.0 to VLC

I am planning to use GStreamer as the new video-streaming library for my application, but I am trying to test the basic capabilities first. 我打算将GStreamer用作应用程序的新视频流库,但是我尝试首先测试其基本功能。 Unfortunately there is a documentation problem, particularly re: Windows and v1.x 不幸的是存在文档问题,尤其是关于:Windows和v1.x

I can play a local video file in GStreamer. 我可以在GStreamer中播放本地视频文件。 I can play a video in GStreamer that is being streamed over UDP or RTP by VLC. 我可以在VStream通过UDP或RTP流式传输的GStreamer中播放视频。 I can stream the videotestsrc from GStreamer to VLC. 我可以将videotestsrc从GStreamer传输到VLC。

I cannot stream a local saved video from GStreamer to VLC. 我无法将本地保存的视频从GStreamer流式传输到VLC。 How do I do that? 我怎么做?

Video format .mp4 影片格式.mp4

VLC version 3.0.4 VLC版本3.0.4

Gstreamer version 1.16 Gstreamer 1.16版


(Some of the ) Tested commands (一些)经过测试的命令

gst-launch-1.0 filesrc location=C:/Users/me/Desktop/big_buck_bunny.mp4 ! queue ! udpsink port=1234 
New clock: GstSystemClock
Got EOS from element "pipeline0".
Execution ended after 0:00:00.027096112
gst-launch-1.0 filesrc location=C:/Users/me/Desktop/big_buck_bunny.mp4 ! decodebin ! x264enc ! rtph264pay ! udpsink port=1234

New clock: GstSystemClock
Got EOS from element "pipeline0".
Execution ended after 0:00:00.027096112

No explicit errors from the previous commands but VLC received nothing and Wireshark saw nothing 先前命令没有明显错误,但VLC却什么也没收到,而Wireshark却什么也没看到

gst-launch-1.0 -v filesrc location=C:/Users/me/Desktop/big_buck_bunny.mp4 ! decodebin ! x264enc ! rtph264pay ! udpsink port=1234

Many lines, lots of conflicting information about cap formats. 很多行,关于上限格式的信息很多。

Pastebin output . Pastebin输出

I've tried a lot of caps combinations but nothing has worked so far. 我尝试了很多大写字母组合,但到目前为止没有任何效果。 One that I tried: 我尝试过的一个:

gst-launch-1.0 -v filesrc location=C:/Users/1137824/Desktop/big_buck_bunny.mp4 ! videoconvert ! videoscale ! video/x-raw,width=800,height=600 ! avenc_mpeg4 ! rtpmp4vpay config-interval=3 ! udpsink port=1234
Pipeline is PREROLLING ...
ERROR: from element /GstPipeline:pipeline0/GstFileSrc:filesrc0: Internal data stream error.
Additional debug info:
../libs/gst/base/gstbasesrc.c(3072): gst_base_src_loop (): /GstPipeline:pipeline0/GstFileSrc:filesrc0:
streaming stopped, reason not-negotiated (-4)
ERROR: pipeline doesn't want to preroll.

Trying streaming from VLC to Gstreamer to VLC (thought maybe GStreamer was sending the entire video in one packet instead of frame-by-frame) 尝试从VLC到Gstreamer到VLC进行流传输(可能是GStreamer是以一个数据包而不是逐帧发送整个视频)

gst-launch-1.0 udpsrc port=1234 ! rtph264pay ! udpsink port=1212

ERROR: from element /GstPipeline:pipeline0/GstRtpH264Pay:rtph264pay0: GStreamer error: negotiation problem.
Additional debug info:
../gst-libs/gst/rtp/gstrtpbasepayload.c(714): gst_rtp_base_payload_chain (): /GstPipeline:pipeline0/GstRtpH264Pay:rtph264pay0:
No input format was negotiated, i.e. no caps event was received. Perhaps you need a parser or typefind element before the payloader

gst-launch-1.0 udpsrc port=1234 ! videoconvert ! x264enc ! rtph264pay ! udpsink port=1212

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

To be able to receive from VLC you need to transmit your config from your rtph264pay element. 为了能够从VLC接收,您需要从rtph264pay元素传输配置。 This is done with config-interval value of the element. 这是通过元素的config-interval值完成的。 For example: 例如:

gst-launch-1.0 filesrc location=C:/Users/me/Desktop/big_buck_bunny.mp4 ! decodebin ! x264enc ! rtph264pay config-interval=1 pt=96 ! udpsink port=1234

For the receiving side. 对于接收方。 VLC needs a .sdp file for the description of network stream. VLC需要一个.sdp文件来描述网络流。 You can create a simple text file with a text editor, and write the contents into the file. 您可以使用文本编辑器创建一个简单的文本文件,然后将内容写入文件中。 An Example sdp file will be like follows: 一个示例sdp文件将如下所示:

v=0
m=video 1234 RTP/AVP 96
c=IN IP4 127.0.0.1
a=rtpmap:96 H264/90000

Here you, describe to VLC that you will receive a H264 video stream from port 1234 , and it is in RTP packets with payload of 96 . 在这里,向VLC描述您将从端口1234接收H264视频流,并且该视频流位于有效载荷为96 RTP数据包中。 You tell it to listen from IP4 == 127.0.0.1 . 您告诉它从IP4 == 127.0.0.1监听。

Feel free to modify this to your needs. 随时根据您的需要进行修改。

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

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