video-streaming - 使用 gstreamer 将本地 mpeg-ts 文件流式传输到 udp

标签 video-streaming gstreamer

我需要使用 gstreamer 广播一个 mpeg-ts 视频文件而不对其进行转码。视频编码为:H264 - MPEG-4 AVC(第 10 部分)(h264)

我试过流式传输

gst-launch-1.0 filesrc location=my_video.ts ! h264parse ! rtph264pay ! udpsink host=127.0.0.1 port=49444

和玩
gst-launch-1.0 udpsrc caps=" application/x-rtp,media=(string)video,clock-rate=(int)90000,encoding-name=(string)H264,payload=(int)96,ssrc=(uint)2674837201,clock-base=(uint)2959668548,seqnum-base=(uint)14300" port=49444 ! rtph264depay ! decodebin ! autovideosink

但是我在接收器端的视频已损坏(但它仍然与原始视频有点相似):

enter image description here

并且接收器的控制台中有很多警告:
WARNING: from element /GstPipeline:pipeline0/GstRtpH264Depay:rtph264depay0: Could not decode stream.
Additional debug info:
gstrtph264depay.c(1205): gst_rtp_h264_depay_process (): /GstPipeline:pipeline0/GstRtpH264Depay:rtph264depay0:
Undefined packet type

我究竟做错了什么?我猜问题出在 caps udpsrc的参数元素,因为我刚刚从网络上的一些示例中复制粘贴了它。如果这是问题所在,我怎样才能找到 caps 的正确值?范围?

最佳答案

您不能直接从 ts 文件转到 h264parse,您需要先对 ts 流进行解复用 - 这是通过 tsdemux 完成的。

这是魔管:

gst-launch-1.0 filesrc location=dummy_h264.ts ! tsparse set-timestamps=true ! video/mpegts ! tsdemux ! video/x-h264 ! h264parse disable-passthrough=true ! rtph264pay ! udpsink -v host=127.0.0.1 port=9999

如果没有 tsparse set-timestamp,它可能无法工作,因为时间戳信息可能不存在于您的 ts 文件中 - 您必须检查是否有正确的 PCR 帧 - 也许使用一些 mpeg ts 分析器。

和调试输出 - 您从谈论 udpsink 的行中获取大写:
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
/GstPipeline:pipeline0/MpegTSParse2:mpegtsparse2-0.GstPad:src: caps = "video/mpegts\,\ systemstream\=\(boolean\)true\,\ packetsize\=\(int\)188"
/GstPipeline:pipeline0/GstCapsFilter:capsfilter0.GstPad:src: caps = "video/mpegts\,\ systemstream\=\(boolean\)true\,\ packetsize\=\(int\)188"
/GstPipeline:pipeline0/GstTSDemux:tsdemux0.GstPad:sink: caps = "video/mpegts\,\ systemstream\=\(boolean\)true\,\ packetsize\=\(int\)188"
/GstPipeline:pipeline0/GstCapsFilter:capsfilter0.GstPad:sink: caps = "video/mpegts\,\ systemstream\=\(boolean\)true\,\ packetsize\=\(int\)188"
/GstPipeline:pipeline0/GstCapsFilter:capsfilter2: caps = video/x-h264
/GstPipeline:pipeline0/GstCapsFilter:capsfilter2.GstPad:src: caps = "video/x-h264\,\ stream-format\=\(string\)byte-stream\,\ alignment\=\(string\)nal"
/GstPipeline:pipeline0/GstH264Parse:h264parse0.GstPad:sink: caps = "video/x-h264\,\ stream-format\=\(string\)byte-stream\,\ alignment\=\(string\)nal"
/GstPipeline:pipeline0/GstCapsFilter:capsfilter2.GstPad:sink: caps = "video/x-h264\,\ stream-format\=\(string\)byte-stream\,\ alignment\=\(string\)nal"
/GstPipeline:pipeline0/GstH264Parse:h264parse0.GstPad:src: caps = "video/x-h264\,\ stream-format\=\(string\)avc\,\ alignment\=\(string\)au\,\ pixel-aspect-ratio\=\(fraction\)1/1\,\ width\=\(int\)320\,\ height\=\(int\)240\,\ framerate\=\(fraction\)30/1\,\ parsed\=\(boolean\)true\,\ profile\=\(string\)high\,\ level\=\(string\)2\,\ codec_data\=\(buffer\)01640014ffe1001967640014acd94141fb0110000003001000000303c8f142996001000568ebecb22c"
/GstPipeline:pipeline0/GstRtpH264Pay:rtph264pay0.GstPad:src: caps = "application/x-rtp\,\ media\=\(string\)video\,\ clock-rate\=\(int\)90000\,\ encoding-name\=\(string\)H264\,\ packetization-mode\=\(string\)1\,\ profile-level-id\=\(string\)640014\,\ sprop-parameter-sets\=\(string\)\"Z2QAFKzZQUH7ARAAAAMAEAAAAwPI8UKZYA\\\=\\\=\\\,aOvssiw\\\=\"\,\ payload\=\(int\)96\,\ ssrc\=\(uint\)3030226714\,\ timestamp-offset\=\(uint\)3947899684\,\ seqnum-offset\=\(uint\)32736"
------------TAKE THIS ONE:--------------
/GstPipeline:pipeline0/GstUDPSink:udpsink0.GstPad:sink: caps = "application/x-rtp\,\ media\=\(string\)video\,\ clock-rate\=\(int\)90000\,\ encoding-name\=\(string\)H264\,\ packetization-mode\=\(string\)1\,\ profile-level-id\=\(string\)640014\,\ sprop-parameter-sets\=\(string\)\"Z2QAFKzZQUH7ARAAAAMAEAAAAwPI8UKZYA\\\=\\\=\\\,aOvssiw\\\=\"\,\ payload\=\(int\)96\,\ ssrc\=\(uint\)3030226714\,\ timestamp-offset\=\(uint\)3947899684\,\ seqnum-offset\=\(uint\)32736"
/GstPipeline:pipeline0/GstRtpH264Pay:rtph264pay0.GstPad:sink: caps = "video/x-h264\,\ stream-format\=\(string\)avc\,\ alignment\=\(string\)au\,\ pixel-aspect-ratio\=\(fraction\)1/1\,\ width\=\(int\)320\,\ height\=\(int\)240\,\ framerate\=\(fraction\)30/1\,\ parsed\=\(boolean\)true\,\ profile\=\(string\)high\,\ level\=\(string\)2\,\ codec_data\=\(buffer\)01640014ffe1001967640014acd94141fb0110000003001000000303c8f142996001000568ebecb22c"
/GstPipeline:pipeline0/GstRtpH264Pay:rtph264pay0: timestamp = 3947910934
/GstPipeline:pipeline0/GstRtpH264Pay:rtph264pay0: seqnum = 32736
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
^Chandling interrupt.
Interrupt: Stopping pipeline ...
Execution ended after 0:00:03.631302966
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...

然后像这样播放:
gst-launch-1.0 udpsrc port=9999 ! application/x-rtp\,\ media\=\... ! queue ! rtph264depay ! decodebin ! videoconvert ! glimagesink

请注意,您不必在已经转义的大写字母周围添加 "..

关于video-streaming - 使用 gstreamer 将本地 mpeg-ts 文件流式传输到 udp,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38968396/

相关文章:

video - 通过浏览器在 VLC Player 上打开视频流

c - 需要明确 OpenCV 中 cvCaptureFromFile 的用法

ios - 移动应用程序的视频流

c++ - qt 创建 gst-launch 进程

python - Opencv 在我的笔记本电脑上为我的项目工作,但停止在树莓派上工作

ffmpeg - 如何同时编码和分段?

c - libgstvideo 共享库尝试流视频时出现段错误

ffmpeg - GStreamer:使用类型查找

c++ - Qt5 中的 GStreamer 错误

ubuntu-12.04 - 使用 gstreamer 流式传输 h.264 视频