我正在运行 rtspsrc 到 filesink 管道。在终端中,我必须输入-e
来指示该流的末尾。当我在命令中输入-e
时,可以成功播放创建的mp4。
gst-launch-1.0
-e
rtspsrc location = rtsp://192.168.1.0:1 / stream! rtph264depay! h264parse! mp4mux! filesink location = file.mp4
但是,当我不使用-e
时,创建的视频将无法播放
gst-launch-1.0 rtspsrc location = rtsp://192.168.1.0:1 / stream! rtph264depay! h264parse! mp4mux! filesink location = file.mp4
问题不是使用命令,而是将python代码写入上述命令。在终端机中,我可以-e
指示EOS
,但是如何在python代码中指示EOS
bus = self.pipeline.get_bus()
terminate = False
while True:
msg = bus.timed_pop_filtered(
Gst.CLOCK_TIME_NONE,
Gst.MessageType.STATE_CHANGED | Gst.MessageType.EOS |
Gst.MessageType.ERROR
)
msg_type = msg.type
if msg_type == Gst.MessageType.ERROR:
error, debug = msg.parse_error()
print("Error: ", msg.src.get_name(), " ", error.message)
if debug:
print("Debugging info", debug)
terminate = True
elif msg_type == Gst.MessageType.EOS:
print("End of file reached")
terminate = True[enter image description here][1]