Search code examples
pythoncgstreamer

Gstreamer understanding


Okey guys I thought that after few days with gstreamer I understand it I wrote some pipelines with would logically work but I have headache when it comes to saving a stream to file.

gst-launch-1.0 rtspsrc location=rstp://ip/url ! decodebin ! textoverlay text="Work you damn thing " ! x264enc ! h264parse ! mp4mux ! filesink location=some_video.mp4

Okey this is my logic:

 1. rtspsrc - has one pad and it's src it outputs x/rtps
 2. decodebin - is a bin (bunch of elements) it has ghost pads and one of those
    sink pads accept x/rtps then on source pad it generates raw video
 4. x264enc - accepts raw video on sink pad and encodes it to a h264 raw
    video
 5. h264parse - accepts raw h264 on sink and it parse it to h264 video
 6. mp4mux - muxing it
 7. filesink - it sinks it to a file

Everything is fine but after I finish recording it and when I try to play it I got this error:

This file contain no playable stream

If there are some experianced users of gstreamer out there I would like to ask them where is the leak in my logic and what is cause of this error ?


Solution

  • You will have to send an EOS event to the pipeline, then wait for the EOS message on the bus of the pipeline, and only then shut down the pipeline (changing state from PLAYING to READY or NULL).

    If you use gst-launch-1.0, use the -e parameter. When you then hit ctrl+c it will do exactly that before shutting down everything.

    This is needed as in the end mp4mux needs to finalize the file and write information about the complete stream in the file. Otherwise the file is not a valid MP4 file.