如何在不重新编码的情况下使用gstreamer来复用视频?

时间:2015-01-06 13:46:28

标签: video gstreamer

我正在尝试使用gstreamer来解压缩h264视频流,并使用mp4mux包装视频流。以下示例有效,但正在执行将现有h264视频重新编码为h264的附加步骤。 (注意:这是一个没有结束的实时流,几秒钟后终止进程以查看生成的文件)。

gst-launch-1.0 souphttpsrc location=http://170.93.143.144:1935/rtplive/8b00ad8b0064001f0053fa36c4235c0a/playlist.m3u8 ! \
    hlsdemux ! \
    decodebin ! \
    x264enc ! \
    queue2 ! \
    mp4mux fragment-duration=10 ! \
    filesink location=/tmp/video.mp4

以下是一个修改后的管道,它取代了decodebin&带有h264parse的x264enc(这不起作用):

gst-launch-1.0 souphttpsrc location=http://170.93.143.144:1935/rtplive/8b00ad8b0064001f0053fa36c4235c0a/playlist.m3u8 ! \
    hlsdemux ! \
    h264parse ! \
    queue2 ! \
    mp4mux fragment-duration=10 ! \
    filesink location=/tmp/video.mp4

运行修改后的管道时,收到以下错误:

Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
ERROR: from element /GstPipeline:pipeline0/GstHLSDemux:hlsdemux0: GStreamer encountered a general stream error.
Additional debug info:
gsthlsdemux.c(946): _src_chain (): /GstPipeline:pipeline0/GstHLSDemux:hlsdemux0:
stream stopped, reason not-negotiated
ERROR: pipeline doesn't want to preroll.
Setting pipeline to NULL ...
Freeing pipeline ...

1 个答案:

答案 0 :(得分:0)

您是否尝试使用GST_DEBUG_DUMP_DOT_DIR ="文件夹,其中点文件将在管道运行后出现"

例如:(如果你在linux中)

GST_DEBUG_DUMP_DOT_DIR=$PWD \
gst-launch-1.0 souphttpsrc location=http://170.93.143.144:1935/rtplive/8b00ad8b0064001f0053fa36c4235c0a/playlist.m3u8 ! \
    hlsdemux ! \
    decodebin ! \
    x264enc ! \
    queue2 ! \
    mp4mux fragment-duration=10 ! \
    filesink location=/tmp/video.mp4

和另一个文件夹

GST_DEBUG_DUMP_DOT_DIR=$PWD \
gst-launch-1.0 souphttpsrc location=http://170.93.143.144:1935/rtplive/8b00ad8b0064001f0053fa36c4235c0a/playlist.m3u8 ! \
   hlsdemux ! \
   h264parse ! \
   queue2 ! \
   mp4mux fragment-duration=10 ! \
   filesink location=/tmp/video.mp4

并比较两个文件:

对于图形比较,您可以将点文件转换为png:

dot -Tpng "file.dot" -o "file_something.png"