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

如何在使用gstreamer使用appsink时将流记录到文件中,stream,gstreamer,tee,Stream,Gstreamer,Tee,我使用以下命令在C++代码中接收“框架事件”,并从gStule:接收 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

我使用以下命令在C++代码中接收“框架事件”,并从gStule:

接收
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形三通时,它不工作

正确的语法是什么


(在我的代码中,我没有使用gstlaunch-1.0.exe,而是使用gst\u parse\u launch)

在您的管道中有一个
appsink
t
(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
一个小提示:在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

谢谢我没有得到错误“警告:错误管道:语法错误”。我很快就会用相机做一些测试。当使用gst-launch-1.0时,它会将结果保存在一个文件中。但是当使用C++时,文件保持在0KB。appsink再也无法获取帧。有没有办法检查什么是理解gst_parse_启动的。在gst_parse_启动后,我做
GstElement*sink=gst_bin_get_by_name(gst_bin(m_管道),“sink”);gst\应用\接收器\设置\发射\信号((GstAppSink*)接收器,真);gst\u应用\u接收器\u设置\u下降((GstAppSink*)接收器,正确)问题解决了。我需要在appsink tee中添加“queue”。不知道为什么<代码>udpsrc端口=5000!应用程序/x-rtp,媒体=视频,时钟频率=90000,编码名称=H264,有效负载=96!t形三通名称=t!队列rtph264depay!德克宾!视频转换!视频/x-raw,格式=BGR!视频转换!appsink name=sink t!队列rtph264depay!h264parse!mp4mux!fileLink location=Flight.mp4 name=record
并手动添加eos\U事件