Demux H264来自(已记录)HDD上的原始RTSP流

时间:2017-01-04 18:10:26

标签: video ffmpeg gstreamer h.264 rtsp

我曾经不得不赶时间从IP摄像机(Sony SRG 300SE)录制视频。我是通过启动

来实现的

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网址”(GStreamer 1.10.2);
  2. ffmpeg -i recording.raw -c:v copy -c:a copy recording.mp4,只会导致“处理输入时发现无效数据”(ffmpeg 3.2.2)
  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. 有没有办法让我至少得到该视频中的视频?

    更新  4. cat recording.raw | ffmpeg -i - -c:v copy -c:a copy recording.mp4在ffmpeg 3.2.2中导致pipe:: Invalid data found when processing input,在旧版本中导致以下内容:

    [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是沉默(虽然可能是这种情况)。

    提前致谢, 帕斯卡

1 个答案:

答案 0 :(得分:1)

gstrtspsrc例如these表明gstrtspsrc本身就是一个分路器。这意味着命令的输出如...

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

...只是RTSP会话中包含的第一个(RTP)流。鉴于播放录制文件时的调试,这可能是AAC流。至于其他流(例如H264流)可能是也可能不是RTSP会话的一部分,它只是忽略它们并丢弃数据包。对于AAC数据,由于AAC数据包边界数据丢失,它可能无法恢复,因此从RTP封装的数据中解析完整的AAC数据包几乎是不可能的。你可以尝试filesrc location = recording.raw! rtpaacdepay! [常规解码元素],但不幸的是我给它成功的机会很低......