gstreamer未刷新到文件链接

gstreamer未刷新到文件链接,gstreamer,Gstreamer,我有一条gstreamer管道,从coomand线开始工作,如下所示: gst-launch-1.0 autovideosrc ! tee name = t ! queue ! omxh264enc ! 'video/x-h264, stream-format=(string)byte-stream' ! h264parse ! qtmux ! filesink name=fileSink location=test.mp4 t. ! queue ! videoscale ! video/

我有一条gstreamer管道,从coomand线开始工作,如下所示:

gst-launch-1.0 autovideosrc ! tee name = t ! queue ! omxh264enc ! 
'video/x-h264, stream-format=(string)byte-stream' ! h264parse ! qtmux 
! filesink name=fileSink location=test.mp4 t. ! queue ! videoscale ! 
video/x-raw, width=480,height=270 ! xvimagesink name=displaySink -e

现在,我在C++方面复制如下:

GstElement * pipeline = gst_parse_launch("autovideosrc ! tee name = t ! "
                    "queue ! omxh264enc ! video/x-h264, "
                    "stream-format=(string)byte-stream ! h264parse ! "
                    "qtmux ! filesink name=fileSink location=test.mp4 t. "
                    "! queue ! videoscale ! video/x-raw, width=480,height=270 ! "
                    "xvimagesink name=displaySink", &error);</raw>
GstElement * displaySink = gst_bin_get_by_name (GST_BIN (pipeline), "displaySink");
qDebug() << displaySink;
// prepare the ui
QWidget window;
window.resize(480, 270);
window.show();

WId xwinid = window.winId();
gst_video_overlay_set_window_handle (GST_VIDEO_OVERLAY(displaySink), xwinid);

// run the pipeline
qDebug() << "Calling run...";

GstStateChangeReturn sret = gst_element_set_state (pipeline,
                                                   GST_STATE_PLAYING);
if (sret == GST_STATE_CHANGE_FAILURE) {
    gst_element_set_state (pipeline, GST_STATE_NULL);
    gst_object_unref (pipeline);
    // Exit application
    QTimer::singleShot(0, QApplication::activeWindow(), SLOT(quit()));
}

int ret = app.exec();

window.hide();
gst_element_set_state (pipeline, GST_STATE_NULL);
gst_object_unref (pipeline);

我推测这可能会关闭管道,而不确保正确创建和最终确定文件。是否有方法确保在关闭管道之前调用EOF或EOS,并确保正确写入文件?这也是我目前的猜测,但可能有其他问题…

是的,发送EOS是必要的

因此,在管道调零之前,请执行以下操作:

gst_element_send_event(pipeline, gst_event_new_eos());

如何知道文件链接已处理EOS?当在
MESSAGE_EOS
的处理程序中将其设置为NULL时,它仍然会生成损坏的文件@Velkan运行应用程序时只需启用GST_DEBUG=5。。这有一些调试类别,但我不记得了。。您应该看到eos事件通过管道。
gst_element_send_event(pipeline, gst_event_new_eos());