2016-10-12 148 views
1

私にビデオを提供するビデオサーバがあります。& rtsp以上のオーディオストリーム。私は、コマンドでのgstreamerツールgst-launchを使用して、それを見ることができます:rtspストリームをgstreamerでaviファイルに保存

gst-launch-1.0 uridecodebin uri=rtsp://path/to/source ! autovideosink 

今、私はすべての一般的なビデオプレーヤー(ようにVLCはWindows Media Playerと)で、その後の再生のためのファイルにそのビデオストリームを格納する必要があります。

autovideosinkfilesink location=file.aviに置き換えて、answerで推奨されているような-eオプションを追加しました。ファイルが作成されましたが、正しいビデオフォーマットではないと思います(VLCでは再生できません)。

はまた、私は最近参照答えからのコマンドを試してみました:それは私にエラーを与える

gst-launch-1.0 -e rtspsrc location=rtsp://path/to/source ! decodebin ! 
x264enc ! mp4mux ! filesink location=file.avi 

ERROR: from element /GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstUDPSrc:udpsrc0: Internal data flow error. 
Additional debug info: 
gstbasesrc.c(2865): gst_base_src_loop(): /GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstUDPSrc:udpsrc0: 
streaming task paused, reason not-linked (-1) 

理由は(私が考えるほど)x264enc ! mp4muxは、H.264コーデックのですが、my deviceですMPEG4 part2モード(MP4V-ES、すなわちH.263)でのみ動作します。だから私は私のデバイスの能力を満たすためにパイプラインのいくつかの要素を置き換える必要があります。しかし、gstreamer plugins listを見ると、MP4V-ES(H.263)には適していません。

これから私の質問は、gst-launchコマンドを修正して、若干古いデバイスのビデオをファイルに保存して再生する方法です。

冗長性を持つコマンドの完全なログ:

gst-launch-1.0 -e -v rtspsrc location=rtsp://192.168.101.44/moxa-cgi/multicaststream_ch1_stream1 ! decodebin ! avenc_mpeg4 ! mp4mux ! filesink location=file.mp4

Setting pipeline to PAUSED ... 
Pipeline is live and does not need PREROLL ... 
Progress: (open) Opening Stream 
Progress: (connect) Connecting to rtsp://192.168.101.44/moxa-cgi/multicaststream_ch1_stream1 
Progress: (open) Retrieving server options 
Progress: (open) Retrieving media info 
Progress: (request) SETUP stream 0 
/GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstRtpBin:manager: latency = 2000 
/GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstRtpBin:manager: ntp-sync = false 
/GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstRtpBin:manager: use-pipeline-clock = false 
/GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstRtpBin:manager: drop-on-latency = false 
/GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstRtpBin:manager: buffer-mode = Slave receiver to sender clock 
/GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstUDPSrc:udpsrc0: timeout = 5000000000 

(gst-launch-1.0:9068): GStreamer-WARNING **: gstpad.c:4555:store_sticky_event:<udpsrc1:src> Sticky event misordering, got 'caps' before 'stream-start' 
/GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstUDPSrc:udpsrc1.GstPad:src: caps = application/x-rtcp 
/GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstUDPSrc:udpsrc1.GstPad:src: caps = application/x-rtcp 
/GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstUDPSrc:udpsrc1: caps = application/x-rtcp 
/GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstUDPSink:udpsink0: ttl = 128 
Progress: (request) SETUP stream 1 
/GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstUDPSrc:udpsrc2: timeout = 5000000000 
/GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstUDPSrc:udpsrc3.GstPad:src: caps = application/x-rtcp 
/GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstUDPSrc:udpsrc3: caps = application/x-rtcp 

(gst-launch-1.0:9068): GStreamer-WARNING **: gstpad.c:4555:store_sticky_event:<udpsrc3:src> Sticky event misordering, got 'caps' before 'stream-start' 
/GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstUDPSrc:udpsrc3.GstPad:src: caps = application/x-rtcp 
/GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstRtpBin:manager.GstGhostPad:recv_rtcp_sink_1.GstProxyPad:proxypad5: caps = application/x-rtcp 
/GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstRtpBin:manager/GstRtpSession:rtpsession1.GstPad:sync_src: caps = application/x-rtcp 
/GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstRtpBin:manager/GstRtpSsrcDemux:rtpssrcdemux1.GstPad:rtcp_sink: caps = application/x-rtcp 
/GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstRtpBin:manager/GstRtpSession:rtpsession1.GstPad:recv_rtcp_sink: caps = application/x-rtcp 
/GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstRtpBin:manager.GstGhostPad:recv_rtcp_sink_1: caps = application/x-rtcp 
/GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstUDPSink:udpsink2: ttl = 128 
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 
/GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstUDPSrc:udpsrc0: timeout = 0 
/GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstUDPSrc:udpsrc2: timeout = 0 
/GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstRtpBin:manager/GstRtpSession:rtpsession0.GstPad:send_rtcp_src: caps = application/x-rtcp 
/GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstRtpBin:manager.GstGhostPad:send_rtcp_src_0: caps = application/x-rtcp 
/GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstUDPSink:udpsink1.GstPad:sink: caps = application/x-rtcp 
/GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstRtpBin:manager.GstGhostPad:send_rtcp_src_0.GstProxyPad:proxypad3: caps = application/x-rtcp 
/GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstRtpBin:manager/GstRtpSession:rtpsession1.GstPad:send_rtcp_src: caps = application/x-rtcp 
/GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstRtpBin:manager.GstGhostPad:send_rtcp_src_1: caps = application/x-rtcp 
/GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstUDPSink:udpsink3.GstPad:sink: caps = application/x-rtcp 
/GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstRtpBin:manager.GstGhostPad:send_rtcp_src_1.GstProxyPad:proxypad6: caps = application/x-rtcp 
/GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstRtpBin:manager.GstGhostPad:recv_rtp_src_1_109102090_0: caps = application/x-rtp, media=(string)audio, payload=(int)0, clock-rate=(int)8000, encoding-name=(string)PCMU, encoding-params=(string)1, a-tool=(string)"MOXA\ 4CH\ Streamming\ Server\ V1.0", a-type=(string)broadcast, x-qt-text-nam=(string)"4CH\ Streaming", x-qt-text-inf=(string)/dev/at2042, clock-base=(uint)2318609, seqnum-base=(uint)26256, npt-start=(guint64)0, play-speed=(double)1, play-scale=(double)1 
/GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0.GstGhostPad:recv_rtp_src_1_109102090_0: caps = application/x-rtp, media=(string)audio, payload=(int)0, clock-rate=(int)8000, encoding-name=(string)PCMU, encoding-params=(string)1, a-tool=(string)"MOXA\ 4CH\ Streamming\ Server\ V1.0", a-type=(string)broadcast, x-qt-text-nam=(string)"4CH\ Streaming", x-qt-text-inf=(string)/dev/at2042, clock-base=(uint)2318609, seqnum-base=(uint)26256, npt-start=(guint64)0, play-speed=(double)1, play-scale=(double)1 
/GstPipeline:pipeline0/GstDecodeBin:decodebin0.GstGhostPad:sink.GstProxyPad:proxypad0: caps = application/x-rtp, media=(string)audio, payload=(int)0, clock-rate=(int)8000, encoding-name=(string)PCMU, encoding-params=(string)1, a-tool=(string)"MOXA\ 4CH\ Streamming\ Server\ V1.0", a-type=(string)broadcast, x-qt-text-nam=(string)"4CH\ Streaming", x-qt-text-inf=(string)/dev/at2042, clock-base=(uint)2318609, seqnum-base=(uint)26256, npt-start=(guint64)0, play-speed=(double)1, play-scale=(double)1 
/GstPipeline:pipeline0/GstDecodeBin:decodebin0/GstTypeFindElement:typefind.GstPad:src: caps = application/x-rtp, media=(string)audio, payload=(int)0, clock-rate=(int)8000, encoding-name=(string)PCMU, encoding-params=(string)1, a-tool=(string)"MOXA\ 4CH\ Streamming\ Server\ V1.0", a-type=(string)broadcast, x-qt-text-nam=(string)"4CH\ Streaming", x-qt-text-inf=(string)/dev/at2042, clock-base=(uint)2318609, seqnum-base=(uint)26256, npt-start=(guint64)0, play-speed=(double)1, play-scale=(double)1 
/GstPipeline:pipeline0/GstDecodeBin:decodebin0/GstTypeFindElement:typefind.GstPad:sink: caps = application/x-rtp, media=(string)audio, payload=(int)0, clock-rate=(int)8000, encoding-name=(string)PCMU, encoding-params=(string)1, a-tool=(string)"MOXA\ 4CH\ Streamming\ Server\ V1.0", a-type=(string)broadcast, x-qt-text-nam=(string)"4CH\ Streaming", x-qt-text-inf=(string)/dev/at2042, clock-base=(uint)2318609, seqnum-base=(uint)26256, npt-start=(guint64)0, play-speed=(double)1, play-scale=(double)1 
/GstPipeline:pipeline0/GstDecodeBin:decodebin0.GstGhostPad:sink: caps = application/x-rtp, media=(string)audio, payload=(int)0, clock-rate=(int)8000, encoding-name=(string)PCMU, encoding-params=(string)1, a-tool=(string)"MOXA\ 4CH\ Streamming\ Server\ V1.0", a-type=(string)broadcast, x-qt-text-nam=(string)"4CH\ Streaming", x-qt-text-inf=(string)/dev/at2042, clock-base=(uint)2318609, seqnum-base=(uint)26256, npt-start=(guint64)0, play-speed=(double)1, play-scale=(double)1 
/GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0.GstGhostPad:recv_rtp_src_1_109102090_0.GstProxyPad:proxypad8: caps = application/x-rtp, media=(string)audio, payload=(int)0, clock-rate=(int)8000, encoding-name=(string)PCMU, encoding-params=(string)1, a-tool=(string)"MOXA\ 4CH\ Streamming\ Server\ V1.0", a-type=(string)broadcast, x-qt-text-nam=(string)"4CH\ Streaming", x-qt-text-inf=(string)/dev/at2042, clock-base=(uint)2318609, seqnum-base=(uint)26256, npt-start=(guint64)0, play-speed=(double)1, play-scale=(double)1 
/GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstRtpBin:manager.GstGhostPad:recv_rtp_src_1_109102090_0.GstProxyPad:proxypad7: caps = application/x-rtp, media=(string)audio, payload=(int)0, clock-rate=(int)8000, encoding-name=(string)PCMU, encoding-params=(string)1, a-tool=(string)"MOXA\ 4CH\ Streamming\ Server\ V1.0", a-type=(string)broadcast, x-qt-text-nam=(string)"4CH\ Streaming", x-qt-text-inf=(string)/dev/at2042, clock-base=(uint)2318609, seqnum-base=(uint)26256, npt-start=(guint64)0, play-speed=(double)1, play-scale=(double)1 
/GstPipeline:pipeline0/GstDecodeBin:decodebin0/GstRtpPcmuDepay:rtppcmudepay0.GstPad:src: caps = audio/x-mulaw, channels=(int)1, rate=(int)8000 
/GstPipeline:pipeline0/GstDecodeBin:decodebin0/GstMuLawDec:mulawdec0.GstPad:sink: caps = audio/x-mulaw, channels=(int)1, rate=(int)8000 
/GstPipeline:pipeline0/GstDecodeBin:decodebin0/GstRtpPcmuDepay:rtppcmudepay0.GstPad:sink: caps = application/x-rtp, media=(string)audio, payload=(int)0, clock-rate=(int)8000, encoding-name=(string)PCMU, encoding-params=(string)1, a-tool=(string)"MOXA\ 4CH\ Streamming\ Server\ V1.0", a-type=(string)broadcast, x-qt-text-nam=(string)"4CH\ Streaming", x-qt-text-inf=(string)/dev/at2042, clock-base=(uint)2318609, seqnum-base=(uint)26256, npt-start=(guint64)0, play-speed=(double)1, play-scale=(double)1 
/GstPipeline:pipeline0/GstDecodeBin:decodebin0/GstMuLawDec:mulawdec0.GstPad:src: caps = audio/x-raw, format=(string)S16LE, layout=(string)interleaved, rate=(int)8000, channels=(int)1 
/GstPipeline:pipeline0/GstDecodeBin:decodebin0.GstDecodePad:src_0.GstProxyPad:proxypad9: caps = audio/x-raw, format=(string)S16LE, layout=(string)interleaved, rate=(int)8000, channels=(int)1 
/GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstRtpBin:manager.GstGhostPad:recv_rtp_src_0_2387976809_96: caps = application/x-rtp, media=(string)video, payload=(int)96, clock-rate=(int)90000, encoding-name=(string)MP4V-ES, profile-level-id=(string)3, config=(string)000001B003000001B50900000100000001200088400668582120A31F, a-tool=(string)"MOXA\ 4CH\ Streamming\ Server\ V1.0", a-type=(string)broadcast, x-qt-text-nam=(string)"4CH\ Streaming", x-qt-text-inf=(string)/dev/at2042, clock-base=(uint)26503772, seqnum-base=(uint)15792, npt-start=(guint64)0, play-speed=(double)1, play-scale=(double)1 
/GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0.GstGhostPad:recv_rtp_src_0_2387976809_96: caps = application/x-rtp, media=(string)video, payload=(int)96, clock-rate=(int)90000, encoding-name=(string)MP4V-ES, profile-level-id=(string)3, config=(string)000001B003000001B50900000100000001200088400668582120A31F, a-tool=(string)"MOXA\ 4CH\ Streamming\ Server\ V1.0", a-type=(string)broadcast, x-qt-text-nam=(string)"4CH\ Streaming", x-qt-text-inf=(string)/dev/at2042, clock-base=(uint)26503772, seqnum-base=(uint)15792, npt-start=(guint64)0, play-speed=(double)1, play-scale=(double)1 
/GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0.GstGhostPad:recv_rtp_src_0_2387976809_96.GstProxyPad:proxypad11: caps = application/x-rtp, media=(string)video, payload=(int)96, clock-rate=(int)90000, encoding-name=(string)MP4V-ES, profile-level-id=(string)3, config=(string)000001B003000001B50900000100000001200088400668582120A31F, a-tool=(string)"MOXA\ 4CH\ Streamming\ Server\ V1.0", a-type=(string)broadcast, x-qt-text-nam=(string)"4CH\ Streaming", x-qt-text-inf=(string)/dev/at2042, clock-base=(uint)26503772, seqnum-base=(uint)15792, npt-start=(guint64)0, play-speed=(double)1, play-scale=(double)1 
/GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstRtpBin:manager.GstGhostPad:recv_rtp_src_0_2387976809_96.GstProxyPad:proxypad10: caps = application/x-rtp, media=(string)video, payload=(int)96, clock-rate=(int)90000, encoding-name=(string)MP4V-ES, profile-level-id=(string)3, config=(string)000001B003000001B50900000100000001200088400668582120A31F, a-tool=(string)"MOXA\ 4CH\ Streamming\ Server\ V1.0", a-type=(string)broadcast, x-qt-text-nam=(string)"4CH\ Streaming", x-qt-text-inf=(string)/dev/at2042, clock-base=(uint)26503772, seqnum-base=(uint)15792, npt-start=(guint64)0, play-speed=(double)1, play-scale=(double)1 
ERROR: from element /GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstUDPSrc:udpsrc0: Internal data flow error. 
Additional debug info: 
gstbasesrc.c(2865): gst_base_src_loop(): /GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstUDPSrc:udpsrc0: 
streaming task paused, reason not-linked (-1) 
EOS on shutdown enabled -- waiting for EOS after Error 
Waiting for EOS... 

はCtrl + Cがここに押されました。 「良い」「悪い」this linkに(エラーが発生した)と(作品をファイルに保存)のため

handling interrupt. 
Interrupt: Stopping pipeline ... 
Interrupt while waiting for EOS - stopping pipeline... 
Execution ended after 0:00:12.942466327 
Setting pipeline to PAUSED ... 
Setting pipeline to READY ... 
Setting pipeline to NULL ... 
Freeing pipeline ... 

また、あなたは差分で見ることができます。

答えて

1

あなたが持っているカメラは、mp4コンテナでまとめようとしているMPEG4タイプ2ストリームを制作しているようです。ストリームタイプが互換性がないため、x264_encの試みは機能しません。第二に、AVIファイルタイプのMP4マルチプレクサを他の試みと同じように使用することはできませんが、avimuxを試すことはできます。

gst-launch-1.0 -v -e rtspsrc location=rtsp://path/to/source ! rtpmp4vdepay ! mpeg4videoparse ! mp4mux ! filesink location=test.mp4 

rtpmp4vdepaympeg4videoparsemp4mux通常decodebin要素自体に包まれているが、私たちの人生を容易にすると見て:キャップ交渉からうまく機能ストリームを破壊我々はとしてそれを構築することができます何がうまくいかないのかは、要素を並べることが常に良いことです。それはあなたがIPカメラのために私が推薦しないことを理解するためにキャップの交渉にそれを残すよりも、あなたが建設しているパイプラインを制御できます。

私も(ただし、IPカメラ用decodebinを避ける)パイプラインを試してお勧めします:

gst-launch-1.0 -e rtspsrc location=rtsp://path/to/source ! decodebin ! avenc_mpeg4 ! mp4mux ! filesink location=file.mp4 

は、ストリームを再生しようとしたとき、元の質問に掲載this linkは、さまざまな交渉形式が表示されていることを言いました。たとえば、 '作品'は、上の作業piplineに記載された順序で要素を追加しようとします。rtppcmudepay要素を追加することによって、別の形式をネゴシエートします。デコードビンには1種類以上のストリームがあり、必要でない追加要素を加えることによってそれらのキャップを解決することを目指していると考えているのはカメラにあると思います。

+0

最後の行のコマンドは、私の答えと同じです(ファイル拡張子を除く)。これは〜10%のケースでのみ動作します。私。 'decodebin! 'の間には理解できない違いがあります。 avenc_mpeg4'と 'rtpmp4vdepay! mpeg4videoparse'チェーン。もしあなたがそれを知っていれば、それは答えに反映させることが涼しいでしょう。 – alexolut

+0

詳細で編集 - 同様の問題に直面している他の人のために、元の質問にカメラの種類を追加してください。ありがとう:) –

+0

私のビデオサーバー(カメラではない)のためのpdfドキュメントはすでに問題の本体にあります。 4つのチャンネルのそれぞれにビデオ+オーディオストリームが含まれています。オーディオストリームは必要ありません(マイクがないため)。しかし、私は 'gst-play'もオーディオストリームを受信すると思う。実際のオーディオソースなしでそれを確認する方法を知らない。 – alexolut

1

x264encの代わりにavenc_mpeg4を使用してください。最終的なコマンドは:

gst-launch-1.0 -e rtspsrc location=rtsp://path/to/source ! decodebin ! avenc_mpeg4 ! mp4mux ! filesink location=file.avi

です。しかし〜10の1回だけ。他の9回質問と同じエラーが表示されます:

streaming task paused, reason not-linked (-1)

私には本当の理由がわかりません。しかし、私はそれがデバイスの機能だと思う。

はしかし、次のようなコマンド:

gst-play-1.0 rtsp://path/to/source

は、すなわちエラーなしで、安定して動作します。

+0

「リンクされていません」というメッセージが表示される前に、どのパッドまたはどの要素がリンクされていないかを明記する必要があります。 –

+0

@SamerTufailあなたはそれを問題で見ることができます。 – alexolut

+0

私はそれを逃したので、私はトップを下にリンクしようとしていた、謝罪。 '-e'と共にパイプラインを '-v'で実行し、出力を共有できますか? –

関連する問題