Mike
Mike

Reputation: 1

How can I use gstreamer to mux video, without re-encoding?

I am attempting to use gstreamer to demux an h264 video stream, and wrap the video stream using mp4mux. The following example works, but is going through the additional step of re-encoding the existing h264 video as h264. (Note: this is a live stream with no end, after a few seconds kill the process to see the resulting file).

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

The following is a modified pipeline that replaces decodebin & x264enc with h264parse (this does not work):

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

When running the modified pipeline, I receive the following error:

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 ...

Upvotes: 0

Views: 2806

Answers (1)

Nuno Martins
Nuno Martins

Reputation: 14

Have you tried using GST_DEBUG_DUMP_DOT_DIR="folder where the dot files are going to be after the pipeline is ran"

such as: (if you are in 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

and on another folder

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

And compare both files:

For a graphical comparison you can translate the dot files to png with:

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

Upvotes: 0

Related Questions