2017-01-04 116 views
0

我曾經不得不從IP攝像機(Sony SRG 300SE)錄製視頻。我通過啓動從硬盤上(已錄製)原始RTSP流中解複用H264

gst-launch-1.0 rtspsrc location="rtsp://192.168.0.100/video1" ! filesink location="recording.raw"

它完美地跑這樣做了。 現在,我想從該文件解複用音頻和視頻(aac和h264)。我現在知道,在接收流時做這件事會更聰明,但是,我沒有。

我已經嘗試過

  1. gst-launch-1.0 rtspsrc location="recording.raw" ! ...,這會導致 「沒有有效的RTSP URL中提供」(GStreamer的1.10.2);
  2. ffmpeg -i recording.raw -c:v copy -c:a copy recording.mp4,這隻會導致「處理輸入時發現無效數據」(3.2.2的ffmpeg)
  3. gst-launch-1.0 filesrc location="recording.raw" ! application/x-rtp ! rtph264depay ! h264parse ! matroskamux ! filesink location=out.mkv,導致 WARNING: from element /GstPipeline:pipeline0/GstRtpH264Depay:rtph264depay0: Could not decode stream. Additional debug info: gstrtpbasedepayload.c(503): gst_rtp_base_depayload_handle_buffer(): /GstPipeline:pipeline0/GstRtpH264Depay:rtph264depay0: Received invalid RTP payload, dropping

有什麼辦法,我得到至少視頻輸出的那個流?

更新: 4. cat recording.raw | ffmpeg -i - -c:v copy -c:a copy recording.mp4導致pipe:: Invalid data found when processing input在FFMPEG 3.2.2,並在舊的編譯如下:

[aac @ 0x2d4b3a0] Format aac detected only with low score of 1, misdetection possible! 
[aac @ 0x2d4c180] More than one AAC RDB per ADTS frame is not implemented. Update your FFmpeg version to the newest one from Git. If the problem still occurs, it means that your file has a feature which has not been implemented.                                    
[aac @ 0x2d4c180] Sample rate index in program config element does not match the sample rate index configured by the container.               
[aac @ 0x2d4c180] Reserved bit set. 
[aac @ 0x2d4c180] Prediction is not allowed in AAC-LC. 
[aac @ 0x2d4c180] channel element 3.10 is not allocated 
[aac @ 0x2d4c180] Assuming an incorrectly encoded 7.1 channel layout instead of a spec-compliant 7.1(wide) layout, use -strict 1 to decode according to the specification instead. 
[aac @ 0x2d4c180] channel element 1.6 is not allocated 
[aac @ 0x2d4c180] channel element 2.5 is not allocated 
[aac @ 0x2d4c180] channel element 2.8 is not allocated 
[aac @ 0x2d4c180] channel element 2.12 is not allocated 
[aac @ 0x2d4c180] channel element 3.2 is not allocated 
[aac @ 0x2d4c180] channel element 2.10 is not allocated 
[aac @ 0x2d4c180] Reserved bit set. 
[aac @ 0x2d4c180] Prediction is not allowed in AAC-LC. 
[aac @ 0x2d4c180] Reserved bit set. 
[aac @ 0x2d4c180] TNS filter order 15 is greater than maximum 12. 
[aac @ 0x2d4c180] Sample rate index in program config element does not match the sample rate index configured by the container. 
[aac @ 0x2d4c180] Inconsistent channel configuration. 
[aac @ 0x2d4c180] get_buffer() failed 
[aac @ 0x2d4c180] Reserved bit set. 
[aac @ 0x2d4c180] Prediction is not allowed in AAC-LC. 
[aac @ 0x2d4c180] channel element 1.5 is not allocated 
[aac @ 0x2d4c180] Reserved bit set. 
[aac @ 0x2d4c180] Pulse tool not allowed in eight short sequence. 
[aac @ 0x2d4c180] Number of bands (30) exceeds limit (21). 
[aac @ 0x2d4c180] Number of bands (16) exceeds limit (14). 
[aac @ 0x2d4c180] Assuming an incorrectly encoded 7.1 channel layout instead of a spec-compliant 7.1(wide) layout, use -strict 1 to decode according to the specification instead. 
[aac @ 0x2d4c180] Sample rate index in program config element does not match the sample rate index configured by the container. 

...從而創造一個AAC只有文件。據我所知,AAC是沉默的(但情況可能如此)。

由於提前, 帕斯卡

+0

嘗試'ffmpeg -f rtsp -i file://recording.raw -c:v複製-c:複製記錄。 mp4'或'cat recording.raw | ffmpeg -i - -c:v copy -c:副本recording.mp4' – Mulvya

+0

謝謝。第一個根本不起作用: FFMPEG用'file:/// [path] /recording.raw:連接被拒絕'退出' 後者給我一個只包含AAC流的文件,沒有視頻。如果我放棄一個'-an'選項,就會得到'輸出文件#0不包含任何流',就好像輸入文件中沒有H264流一樣。 –

+0

@aergistal也許你有一些想法。 – Mulvya

回答

1

gstrtspsrc例子如these表明gstrtspsrc本身作爲分路器。這也就意味着,一個命令等的輸出...

gst-launch-1.0 rtspsrc location="rtsp://192.168.0.100/video1" ! filesink location="recording.raw" 

...只是包含在RTSP會話第一(RTP)流。鑑於播放錄製文件時的調試,這可能是AAC流。對於可能或可能不是RTSP會話的一部分的其他流(例如H264流),它簡單地忽略它們並丟棄分組。至於AAC數據,由於AAC數據包邊界數據丟失,可能無法恢復,因此從RTP封裝的數據解析完整的AAC數據包幾乎是不可能的。你可以嘗試filesrc location = recording.raw! rtpaacdepay! [常規解碼元素],但我給它一個很低的成功機率,不幸的是...