简体   繁体   English

Gstreamer理解

[英]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.好吧,伙计们,我认为在使用 gstreamer 几天后我明白了,我写了一些逻辑上可以工作的管道,但是在将流保存到文件时我很头疼。

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 ?如果那里有一些有经验的 gstreamer 用户,我想问他们我的逻辑中的泄漏在哪里以及导致此错误的原因是什么?

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).您必须向管道发送 EOS 事件,然后等待管道总线上的 EOS 消息,然后才关闭管道(将状态从 PLAYING 更改为 READY 或 NULL)。

If you use gst-launch-1.0, use the -e parameter.如果您使用 gst-launch-1.0,请使用 -e 参数。 When you then hit ctrl+c it will do exactly that before shutting down everything.当您然后按 ctrl+c 时,它会在关闭所有内容之前完成此操作。

This is needed as in the end mp4mux needs to finalize the file and write information about the complete stream in the file.这是必需的,因为最终 mp4mux 需要完成文件并在文件中写入有关完整流的信息。 Otherwise the file is not a valid MP4 file.否则该文件不是有效的 MP4 文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM