【问题标题】:Gtk/Gstreamer application freezes on first frameGtk/Gstreamer 应用程序在第一帧冻结
【发布时间】:2021-07-14 21:43:11
【问题描述】:

我正在尝试制作一个通过 gtk 绘图区域流式传输视频的应用程序。我目前正在尝试运行的管道是 videotestsrc ! ximagesink。我的问题是,当我尝试运行我的程序时,它显示 videotestsrc,但仅显示为静止图像。这不同于通过终端运行“gst-launch-1.0 videotestsrc!ximagesink”,右下角的静态移动。

关于我做错了什么有什么想法吗?

int main(int argc, char* argv[])
{
        Gst::init(argc, argv);
        auto app = Gtk::Application::create(argc, argv, "gtkmm.video.sunshine.test");
        Program_Window window;
        return app->run(window);
}

    
class Program_Window : public Gtk::Window
{
    
public:
        Program_Window();
        virtual ~Program_Window();

protected:
        Gtk::DrawingArea* display;
        Glib::RefPtr<Gst::Pipeline> playbin;
        gulong window_handler;
        GstVideoOverlay* overlay;
        void on_display_realize();
};


Program_Window::Program_Window()
{

        //initialize variables
        display = new Gtk::DrawingArea();
        window_handler = 0;

        //connect realize callback
        display->signal_realize().connect( sigc::mem_fun( *this, &Program_Window::on_display_realize ));

        //create playbin
        playbin = Gst::PlayBin::create("playbin");

        //prepare elements for the pipeline
        Glib::RefPtr<Gst::Element> source = Gst::ElementFactory::create_element("videotestsrc", "src");
        Glib::RefPtr<Gst::Element> sink = Gst::ElementFactory::create_element("ximagesink", "sink");

        //add elements to the pipeline
        playbin->add(source)->add(sink);

        //link elements
        source->link(sink);

        //prep video overlay interface
        overlay = (GstVideoOverlay*) sink->gobj();

        //add drawing area to main window
        add(*display);
        show_all_children();
}


void Program_Window::on_display_realize()
{
    
            //acquire an xwindow pointer to our draw area   
            window_handler = GDK_WINDOW_XID( display->get_window()->gobj() );
    
            //give xwindow pointer to our pipeline via video overlay interface
            gst_video_overlay_set_window_handle(overlay, window_handler);
    
            //start video
            playbin->set_state(Gst::STATE_PLAYING);
}

【问题讨论】:

    标签: gtk gstreamer


    【解决方案1】:

    可能是在应用程序中它有点慢,导致后续帧错过了它们的时钟时间并被丢弃。尝试为视频接收器设置sync=false 选项并检查它是否有任何改变。否则使用GST_DEBUG 从管道中获取一些关于正在发生的事情的日志。

    附:使用 Gtk 时,请考虑使用 gtksinkgtkglsink 让您的生活更轻松。

    【讨论】:

      【解决方案2】:

      修复它。无论出于何种原因,该程序不喜欢我使用 playbin 的方式。将其更改为正常的 Gst::pipeline 即可。

          //create playbin                             //in the above code
          //playbin = Gst::PlayBin::create("playbin"); //change this
          playbin = Gst::Pipeline::create("pipeline"); //to this
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2022-12-22
        • 2015-04-28
        • 1970-01-01
        • 2011-09-04
        • 1970-01-01
        • 1970-01-01
        • 2012-10-14
        • 1970-01-01
        相关资源
        最近更新 更多