Har*_*vic 1 c python gstreamer
Okey的家伙我以为在用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
Run Code Online (Sandbox Code Playgroud)
哦,这是我的逻辑:
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
Run Code Online (Sandbox Code Playgroud)
一切都很好,但在我完成录制后,当我尝试播放时,我收到了这个错误:
此文件不包含可播放的流
如果有一些gstreamer的实验用户,我想问他们我的逻辑漏洞在哪里,这个错误的原因是什么?
小智 7
您必须将EOS事件发送到管道,然后等待管道总线上的EOS消息,然后才关闭管道(将状态从PLAYING更改为READY或NULL).
如果使用gst-launch-1.0,请使用-e参数.当你按下ctrl + c时,它会在关闭所有内容之前完成.
这是必需的,因为最后mp4mux需要最终确定文件并在文件中写入有关完整流的信息.否则该文件不是有效的MP4文件.