2009-12-10 107 views
7

我正在開發一個GStreamer應用程序,併爲實現傳入RTP流的播放器而苦苦掙扎。我正在嘗試圍繞gstrtpbin元素構建管道。我試圖在管道中使用的GST-啓動建設模式:使用GStreamer播放傳入的RTP流

VIDEO_CAPS="application/x-rtp,media=(string)video,clock-rate=(int)90000,encoding-name=(string)H264" 

gst-launch -v udpsrc caps=$VIDEO_CAPS port=4444 \ 
       ! gstrtpbin .recv_rtp_sink_0 \ 
       ! rtph264depay ! ffdec_h264 ! xvimagesink 

當我啓動腳本的GStreamer報告這些錯誤:

Setting pipeline to PAUSED ... 
Pipeline is live and does not need PREROLL ... 
Setting pipeline to PLAYING ... 
/GstPipeline:pipeline0/GstRtpBin:rtpbin0/GstRtpSession:rtpsession0: ntp-ns-base = 3469468914024449000 
New clock: GstSystemClock 
/GstPipeline:pipeline0/GstRtpBin:rtpbin0/GstRtpSession:rtpsession0.GstPad:recv_rtp_sink: caps = application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264 
/GstPipeline:pipeline0/GstRtpBin:rtpbin0.GstGhostPad:recv_rtp_sink_0: caps = application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264 
/GstPipeline:pipeline0/GstRtpBin:rtpbin0.GstGhostPad:recv_rtp_sink_0.GstProxyPad:proxypad0: caps = application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264 
/GstPipeline:pipeline0/GstRtpBin:rtpbin0/GstRtpSession:rtpsession0.GstPad:recv_rtp_src: caps = application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264 
/GstPipeline:pipeline0/GstRtpBin:rtpbin0/GstRtpSsrcDemux:rtpssrcdemux0.GstPad:sink: caps = application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264 
/GstPipeline:pipeline0/GstRtpBin:rtpbin0/GstRtpJitterBuffer:rtpjitterbuffer0.GstPad:src: caps = application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264 
/GstPipeline:pipeline0/GstRtpBin:rtpbin0/GstRtpJitterBuffer:rtpjitterbuffer0.GstPad:sink: caps = application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264 
/GstPipeline:pipeline0/GstRtpBin:rtpbin0/GstRtpPtDemux:rtpptdemux0.GstPad:sink: caps = application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264 
/GstPipeline:pipeline0/GstRtpBin:rtpbin0.GstGhostPad:recv_rtp_src_0_960476599_33.GstProxyPad:proxypad1: caps = application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264, payload=(int)33 
ERROR: from element /GstPipeline:pipeline0/GstUDPSrc:udpsrc0: Internal data flow error. 
Additional debug info: 
gstbasesrc.c(2378): gst_base_src_loop(): /GstPipeline:pipeline0/GstUDPSrc:udpsrc0: 
streaming task paused, reason not-linked (-1) 
Execution ended after 209381685 ns. 
Setting pipeline to PAUSED ... 
Setting pipeline to READY ... 
/GstPipeline:pipeline0/GstRtpBin:rtpbin0.GstGhostPad:recv_rtp_src_0_960476599_33: caps = NULL 
/GstPipeline:pipeline0/GstRtpBin:rtpbin0/GstRtpPtDemux:rtpptdemux0.GstPad:src_33: caps = NULL 
/GstPipeline:pipeline0/GstRtpBin:rtpbin0/GstRtpPtDemux:rtpptdemux0.GstPad:sink: caps = NULL 
/GstPipeline:pipeline0/GstRtpBin:rtpbin0/GstRtpJitterBuffer:rtpjitterbuffer0.GstPad:sink: caps = NULL 
/GstPipeline:pipeline0/GstRtpBin:rtpbin0/GstRtpJitterBuffer:rtpjitterbuffer0.GstPad:src: caps = NULL 
/GstPipeline:pipeline0/GstRtpBin:rtpbin0/GstRtpSsrcDemux:rtpssrcdemux0.GstPad:src_960476599: caps = NULL 
/GstPipeline:pipeline0/GstRtpBin:rtpbin0/GstRtpSsrcDemux:rtpssrcdemux0.GstPad:sink: caps = NULL 
/GstPipeline:pipeline0/GstRtpBin:rtpbin0/GstRtpSession:rtpsession0.GstPad:recv_rtp_src: caps = NULL 
/GstPipeline:pipeline0/GstRtpBin:rtpbin0/GstRtpSession:rtpsession0.GstPad:recv_rtp_sink: caps = NULL 
/GstPipeline:pipeline0/GstRtpBin:rtpbin0.GstGhostPad:recv_rtp_sink_0: caps = NULL 
/GstPipeline:pipeline0/GstUDPSrc:udpsrc0.GstPad:src: caps = NULL 
Setting pipeline to NULL ... 
Freeing pipeline ... 

我應該指出,它的工作原理與playbin和SDP文件。例如本文件:

v=0 
o=- 1188340656180883 1 IN IP4 127.0.0.1 
s=Session streamed by GStreamer 
i=server.sh 
t=0 0 
a=tool:GStreamer 
a=type:broadcast 
m=video 4444 RTP/AVP 96 
c=IN IP4 127.0.0.1 
a=rtpmap:96 H264/90000 

可用於播放流是這樣的:

gst-launch -vvv playbin uri=file://`pwd`/stream.sdp 

爲了完整性:我使用VLC發送數據。這是命令:

vlc -I rc /usr/local/movies/sample.mp4 \ 
    --screen-fps=10 :screen-caching=100 \ 
    --sout='#transcode{vcodec=h264,venc=x264{bframes=0,keyint=40},vb=512}:\ 
        rtp{mux=ts,dst=127.0.0.1,port=4444}' 

有人能幫我理解爲什麼gst-launch腳本失敗嗎?錯誤「原因未鏈接」使我認爲gstrtpbin和rtph264depay元素之間的鏈接被破壞。但我不知道如何解決它。

編輯
遵循RAOF的建議我在我的命令中修正了一些錯誤。不過我使用ffdec_h264因爲autovideosink我的Windows系統上,我沒有安裝fluh264dec和xvimage沉插件的更多信息:

gst-launch-0.10 udpsrc port=4444 caps="application/x-rtp,media=(string)video,clock-rate=(int)90000,encoding-name=(string)H264" ! .recv_rtp_sink_0 gstrtpbin ! rtpmp2tdepay ! mpegtsdemux ! ffdec_h264 ! autovideosink 

這將導致新的錯誤:

0:00:00.743000000 516 024070A8 ERROR     ffmpeg .:0:: non-existing PPS referenced 
0:00:00.744000000 516 024070A8 ERROR     ffmpeg .:0:: non-existing PPS referenced 
0:00:00.745000000 516 024070A8 ERROR     ffmpeg .:0:: decode_slice_header error 
0:00:00.745000000 516 024070A8 ERROR     ffmpeg .:0:: no frame! 
0:00:00.812000000 516 024070A8 ERROR     ffmpeg .:0:: non-existing PPS referenced 
0:00:00.813000000 516 024070A8 ERROR     ffmpeg .:0:: non-existi 
... 
ERROR: from element /GstPipeline:pipeline0/GstUDPSrc:udpsrc0: Internal data flow 
error. 
Additional debug info: 
..\Source\gstreamer\libs\gst\base\gstbasesrc.c(2378): gst_base_src_loop(): /Gst 
Pipeline:pipeline0/GstUDPSrc:udpsrc0: 
streaming task paused, reason not-negotiated (-4) 
Execution ended after 4790000000 ns. 
Setting pipeline to PAUSED ... 
Setting pipeline to READY ... 
Setting pipeline to NULL ... 
Freeing pipeline ... 

我還在努力弄清楚如何解決這個問題。如果你能提供幫助,那麼可以隨時這樣做。

EDIT2
我測試再次使用SDP解決方案,並指出,「不存在PPS」,也會出現錯誤,但視頻則可以播放。另一方面,僅當使用定製流水線解決方案時纔會顯示致命的「內部數據流錯誤」。 我懷疑「不存在的PPS」錯誤是由x264編碼器引起的。 「內部數據流錯誤」必須由我的管道中的錯誤引起,或者可能是某個Windows插件中的錯誤。我會這樣一些進一步的研究...

回答

10

據我所知,你得有兩個問題:

首先,它似乎下沉規範的順序很重要:不是... ! gstrtpbin .recv_rtp_sink_0 ! ...你需要有... ! .recv_rtp_sink_0 gstrtpbin ! ...。其次,vlc正在發送一個MPEG2傳輸流 - 在rtp流式輸出描述符中你有mux=ts - 但是你想要depay一個原始的h264流。您需要depayload TS流,然後解複用它以獲取h264流數據。

所以,最後,管道

gst-launch-0.10 -v udpsrc port=4444 \ 
caps="application/x-rtp,media=(string)video,clock-rate=(int)90000,encoding-name=(string)H264" \ 
! .recv_rtp_sink_0 gstrtpbin ! rtpmp2tdepay \ 
! mpegtsdemux ! fluh264dec ! xvimagesink 

作品對我來說,使用TS解複用器(mpegtsdemux)和H264解碼器(fluh264dec)。

+1

感謝您的幫助。我現在更近一步了,看看我的編輯。 – StackedCrooked 2009-12-22 14:55:37

+0

我現在已經安裝了gstreamer-ffmpeg並使用ffdec_h264和autovideosink對其進行了嘗試。我的管道適用於這些元素,而不是fluh264dec和xvimagesink。現在我不確定你的問題在哪裏。 – RAOF 2009-12-22 22:54:28

+0

我懷疑這是一個Windows特定的問題,我會用我的Linux機器進行測試。如果您有興趣,我會在這篇文章中更新我的進度。 謝謝,你一直很有幫助。 – StackedCrooked 2009-12-23 09:32:59

1

gst-launch-0.10 -vvvv rtspsrc location = rtsp://192.168.250.100:554 latency = 100! application/x-rtp,media =「video」,payload = 99,clock-rate = 90000,encoding-name =「H264」! rtph264depay! ffdec_h264! ffmpegcolorspace! xvimagesink

這對我的作品有「Grandtec電子萬像素WIFI CAM」

0

你也可以試試這個。

gst-launch-0.10 -v rtspsrc location="rtsp://10.107.2.217/StreamingSetting?version=1.0&action=getRTSPStream&ChannelID=1&ChannelName=Channel1" user-id=admin user-pw=admin123 caps=" application/x-rtp,media=(string)video,clock-rate=(int)90000,encoding-name=(string)H264,payload=(int)96,ssrc=(uint)237526004,clock-base=(uint)1584170994,seqnum-base=(uint)42626" port=554 ! rtph264depay queue-delay=0 ! h264parse ! decodebin2 ! queue leaky=1 ! autovideosink

它也工作時,你對網絡數據流是安全的,其對

rtsp://10.107.2.217

RTSP Port : 554

Video Codec : H.264

希望工程,其有助於你們。