2016-08-16 80 views
1

我需要使用gstreamer来广播mpeg-ts视频文件,而无需对其进行转码。 视频在编码:H264 - MPEG-4 AVC(第10部分)(H264)使用gstreamer将本地mpeg-ts文件流式传输到udp

我试着

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 

但玩我对receaver一方的视频已经损坏(但它仍然与原始视频有点类似): enter image description here

而且它是很多wa在接收器的控制台上:

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 

我在做什么错?我猜,问题出在udpsrc元素的caps参数中,因为我刚刚从网上的一些示例中复制了它。如果是这个问题,我怎么才能找到caps参数的propper值?

回答

2

你不能直接从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集时间戳它可能无法正常工作,因为时间戳信息可能不会出现在您的TS文件 - 你必须检查是否有合适的PCR框架 - 也许用一些MPEG分析器。

和调试输出 - 你行采取帽谈论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 

注意,您不必添加“围绕帽其已经逃脱了..

+0

非常感谢!你的神奇管道工作正常! 但是,我收到的视频有一些故障,直到我添加了一个'queue'元素在播放器的管道 – Paboka

+0

@Paboka确定我编辑了答案..它的好处是在有意义的地方有队列......但我认为decodebin已经在内部使用了一些队列。 – nayana

相关问题