如何在使用 gstreamer 使用 appsink 时将流记录到文件中

how to record stream in to file while using appsink using gstreamer

我正在使用以下命令在我的 C++ 代码和 gstreamer 中接收“帧事件”:

gst-launch-1.0.exe -vv udpsrc port=5000 ! application/x-rtp,media=video,clock-rate=90000,encoding-name=H264,payload=96 ! rtph264depay ! decodebin ! videoconvert ! video/x-raw,format=BGR ! videoconvert ! appsink name=sink

而且效果很好。

现在我正在尝试使用 tee 添加录音。 我试过了:

gst-launch-1.0.exe -vv udpsrc port=5000 ! tee name=t t. ! application/x-rtp,media=video,clock-rate=90000,encoding-name=H264,payload=96 ! queue ! rtph264depay ! decodebin ! videoconvert ! appsink ! t. ! application/x-rtp,media=video,clock-rate=90000,encoding-name=H264,payload=96 ! queue ! rtph264depay ! h264parse ! mp4mux ! filesink location=test.mp4

例如,但我收到此错误:

WARNING: erroneous pipeline: syntax error

我不知道如何使用 T 恤。 每个部分单独使用都很好,但是当我使用 T 恤时它不起作用。

正确的语法是什么?

(在我的代码中而不是使用 gstlaunch-1。0.exe 我正在使用 gst_parse_launch)

在您的管道中,appsinkt(三通)元素之间有一个 !。这将他们联系起来。您希望分支是分开的。

gst-launch-1.0.exe -vv udpsrc port=5000 ! tee name=t t. ! application/x-rtp,media=video,clock-rate=90000,encoding-name=H264,payload=96 ! queue ! rtph264depay ! decodebin ! videoconvert ! appsink   t. ! application/x-rtp,media=video,clock-rate=90000,encoding-name=H264,payload=96 ! queue ! rtph264depay ! h264parse ! mp4mux ! filesink location=test.mp4

小提示:在tee前加上caps会更实用,这样就不用写两遍了

gst-launch-1.0 -vv udpsrc port=5000 ! application/x-rtp,media=video,clock-rate=90000,encoding-name=H264,payload=96 ! tee name=t t. ! queue ! rtph264depay ! decodebin ! videoconvert ! appsink  t. ! queue ! rtph264depay ! h264parse ! mp4mux ! filesink location=test.mp4