2016-10-12 2 views
1

나는 비디오를 rtsp를 통해 & 비디오 스트림으로 제공하는 비디오 서버를 보유하고 있습니다.gstreamer로 avi 파일에 rtsp 스트림 저장

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

지금 내가 어떤 인기있는 비디오 플레이어 (등등 VLC, 윈도우 미디어 플레이어 등)에서 연속 재생을위한 파일에 그 비디오 스트림을 저장할 필요가 : 나는 명령을 gstreamer를 도구 gst-launch를 사용하여 볼 수 있습니다.

autovideosinkfilesink location=file.avi으로 바꾸고, -e 옵션을 다음과 같이 추가하려고했습니다 : answer. 파일이 생성되었지만 올바른 비디오 형식이 아 니라 생각합니다 (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 Type 2 스트림을 제작하는 것으로 보입니다. 따라서 스트림 유형이 호환되지 않으므로 x264_enc 시도가 작동하지 않습니다. 둘째, avimux를 시도 할 수 있지만 다른 시도와 마찬가지로 AVI 파일 유형의 MP4 멀티플렉서를 사용할 수 없습니다.

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

rtpmp4vdepay, mpeg4videoparsemp4mux는 일반적으로 자체 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 요소를 추가하여 다른 형식을 협상하는 비 작동 한 시도를 시도합니다. Decodebin이 사용할 수있는 스트림 유형이 두 가지 이상이고 필요하지 않은 추가 요소를 추가하여 이러한 대문자를 해결하는 것이 목표라고 생각하는 카메라에 이르기까지라고 생각합니다.

+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 ~ 10 시간. 다른 9 번 질문에서와 같은 오류가 발생했습니다 :

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

나는 진짜 이유가 무엇인지 모르겠습니다. 하지만 장치 기능이라고 생각합니다.

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

오류없이, 즉를 안정적으로 작동합니다 같은

그러나, 명령.

+0

'연결되지 않음'메시지 앞에 어떤 패드 또는 어떤 요소가 링크되어 있지 않은지 알려 주시면 붙여 넣기를 할 수 있습니까? –

+0

@SamerTufail 당신은 질문에서 그것을 볼 수 있습니다. – alexolut

+0

나는 바닥을 꼭대기에 연결하려고 했으므로 나는 사과하지 않았다. '-e'와 함께 '-v'를 사용하여 파이프 라인을 실행하고 출력을 공유 할 수 있습니까? –