尝试使用 gstreamer 库连接到 rtsp 流

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

我正在尝试通过使用 ffmpeg 无限循环从静态 mp4 视频创建一个 rtsp 流,使用 cmd

ffmpeg  -flush_packets 1 -re -stream_loop -1 -i sample.mp4 -f rtsp rtsp://ip:8554/mystream

现在我想使用 gstreamer 库阅读它,但是当我尝试使用 cmd 阅读它时,

gst-launch-1.0 rtspsrc location=rtsp://ip:8554/mystream

gst-launch-1.0 rtspsrc location=rtsp://ip:8554/mystream ! avdec_h264 ! autovideoconvert ! queue ! rtph264depay ! h264parse ! autovideosink

我收到这个错误,

Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Progress: (open) Opening Stream
Progress: (connect) Connecting to rtsp://10.0.0.19:8554/mystream
Progress: (open) Retrieving server options
Progress: (open) Retrieving media info
Progress: (request) SETUP stream 0
Progress: (request) SETUP stream 1
Progress: (open) Opened Stream
Setting pipeline to PLAYING ...
New clock: GstSystemClock
Progress: (request) Sending PLAY request
Progress: (request) Sending PLAY request
Progress: (request) Sent PLAY request
WARNING: from element /GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0: Delayed linking failed.
Additional debug info:
./grammar.y(510): gst_parse_no_more_pads (): /GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0:
failed delayed linking some pad of GstRTSPSrc named rtspsrc0 to some pad of avdec_h264 named avdec_h264-0
ERROR: from element /GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0: Internal data stream error.
Additional debug info:
gstrtspsrc.c(5653): gst_rtspsrc_loop (): /GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0:
streaming stopped, reason not-linked (-1)
Execution ended after 0:00:01.552277296
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...

使用cmd后,

gst-launch-1.0 rtspsrc location=rtsp://ip:8554/mystream ! application/x-rtp,media=video,encoding-name=H264,clock-rate=90000 ! rtph264depay ! h264parse ! avdec_h264 ! videorate ! videoconvert ! queue! autovideosink

更新日志有错误,

Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Progress: (open) Opening Stream
Progress: (connect) Connecting to rtsp://10.0.0.19:8554/mystream
Progress: (open) Retrieving server options
Progress: (open) Retrieving media info
Progress: (request) SETUP stream 0
Progress: (request) SETUP stream 1
Progress: (open) Opened Stream
Setting pipeline to PLAYING ...
New clock: GstSystemClock
Progress: (request) Sending PLAY request
Progress: (request) Sending PLAY request
Progress: (request) Sent PLAY request
0:00:02.180429398  3554 0x7f1cdc04e230 WARN                 basesrc gstbasesrc.c:3055:gst_base_src_loop:<udpsrc0> error: Internal data stream error.
0:00:02.180465192  3554 0x7f1cdc04e230 WARN                 basesrc gstbasesrc.c:3055:gst_base_src_loop:<udpsrc0> error: streaming stopped, reason not-linked (-1)
0:00:03.316770515  3554 0x7f1cdc032b20 WARN                 default grammar.y:510:gst_parse_no_more_pads:<rtspsrc0> warning: Delayed linking failed.
0:00:03.316823812  3554 0x7f1cdc032b20 WARN                 default grammar.y:510:gst_parse_no_more_pads:<rtspsrc0> warning: failed delayed linking some pad of GstRTSPSrc named rtspsrc0 to some pad of GstRtpH264Depay named rtph264depay0
WARNING: from element /GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0: Delayed linking failed.
Additional debug info:
./grammar.y(510): gst_parse_no_more_pads (): /GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0:
failed delayed linking some pad of GstRTSPSrc named rtspsrc0 to some pad of GstRtpH264Depay named rtph264depay0
0:00:04.018867523  3554 0x7f1cdc04e280 WARN                 basesrc gstbasesrc.c:3055:gst_base_src_loop:<udpsrc3> error: Internal data stream error.
0:00:04.018937057  3554 0x7f1cdc04e280 WARN                 basesrc gstbasesrc.c:3055:gst_base_src_loop:<udpsrc3> error: streaming stopped, reason not-linked (-1)
ERROR: from element /GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstUDPSrc:udpsrc3: Internal data stream error.
Additional debug info:
gstbasesrc.c(3055): gst_base_src_loop (): /GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstUDPSrc:udpsrc3:
streaming stopped, reason not-linked (-1)
Execution ended after 0:00:01.908870388
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to N

任何帮助将不胜感激!

video-streaming gstreamer rtsp gstreamer-1.0
1个回答
0
投票

RTSP 通过 RTP 传输媒体,在解码视频流之前,需要进行 rtp 卸载。

gst-launch-1.0 rtspsrc location=rtsp://ip:8554/mystream !应用程序/x-rtp,媒体=视频,编码名称=H264,时钟速率=90000! rtph264depay ! h264解析! avdec_h264 !视频率!视频转换!队列!自动视频接收器

gst-play-1.0 rtsp://ip:8554/mystream 的点图可能会给你一个更好的画面

© www.soinside.com 2019 - 2024. All rights reserved.