【问题标题】:How to output GStreamer video to Gdk.Pixbuf using Vala?如何使用 Vala 将 GStreamer 视频输出到 Gdk.Pixbuf?
【发布时间】:2014-11-24 18:38:04
【问题描述】:

我在我的程序中使用 GStreamer 1.0 来播放文件中的视频。我想将其输出到 Gdk.Pixbuf 以将其添加到 Image 以显示它。但我不知道如何正确使用它。

这是我试图做的,但它不会编译:

this.pipeline = new Pipeline ("mypipeline");
this.src = ElementFactory.make ("filesrc", "video");
src.set("location", downloadFileName);
this.sink = ElementFactory.make ("gdkpixbufsink", "sink");
this.pipeline.add_many (this.src, this.sink);
this.src.link (this.sink);

this.pipeline.set_state (State.PLAYING);

this.videoPixbuf = sink.get("last-pixbuf") as Gdk.Pixbuf;

如果可能的话,你能建议我如何正确地做到这一点吗?或者我如何在不使用 Gdk.Pixbuf 的情况下以另一种方式做到这一点?我只是不知道该怎么办。

【问题讨论】:

    标签: video gstreamer vala


    【解决方案1】:

    我不知道 vala 但你应该看看那里:

    http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-base-libs/html/gst-plugins-base-libs-gstvideooverlay.html,寻找videooverlay使用的C Gtk实现,这个应该很容易翻译成Vala。

    【讨论】:

      【解决方案2】:

      编辑:Matthew Waters 为您提供 Gtk/Gst 元素:https://github.com/ystreet/gtkgst

      gtksink 元素为您的应用提供视频小部件

      public static void main (string[] args) {
          X.init_threads();
          Gst.init (ref args);
          Gtk.init (ref args);
      
          var sink = Gst.ElementFactory.make ("gtksink", "sink");
          var playbin = Gst.ElementFactory.make ("playbin", "bin");
          playbin["video-sink"] = sink;
          playbin["uri"] = "http://www.nicolas-hoffmann.net/animations/Cavernae_Terragen2.mp4";
          Gtk.Widget area;
          sink.get ("widget", out area);
          var win = new Gtk.Window();
          var bar = new Gtk.HeaderBar();
          bar.title = "Test";
          bar.show_close_button = true;
          win.set_titlebar (bar);
          win.add (area);
          win.realize.connect (() => {
                  playbin.set_state (Gst.State.PLAYING);
          });
          win.set_size_request (400, 300);
          win.show_all();
          Gtk.main();
      }
      

      【讨论】:

        猜你喜欢
        • 2019-11-17
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-06-14
        • 2013-09-22
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多