GStreamer 演示在虚拟机中不起作用(寻求简单示例)

GStreamer demo deosn't work in Virtual Machine (seeking simple example)

我正在尝试编写一个极其简单的 GStreamer 应用程序。它做什么并不重要,只要 GStreamer 有所作为即可。即使只是显示一些文本或简单的 JPEG 也可以。

下面是我可以通过谷歌搜索找到的最佳示例(我添加了一些错误检查)。当我在 Windows 下的 Linux 虚拟机 运行ning 中 运行 时,我看到此控制台消息:

libEGL warning: pci id for fd 4: 80ee:beef, driver (null)

libEGL warning: DRI2: failed to open vboxvideo (search paths /usr/lib/i386-linux-gnu/dri:${ORIGIN}/dri:/usr/lib/dri)

谷歌搜索表明这是虚拟机内部 3D 渲染的错误。我找不到解决方案。

那么,有人可以修复下面的代码,以便它 运行 在 VM 中吗?我假设这意味着避免 3D 渲染,所以可能显示图像或一些文本?不需要播放视频,这只是在其他东西中使用 GStreamer 的简单概念证明(必须在 VM 中 运行ning)。

这是代码...

void GstreamerPlayVideo()
{
      GstElement *pipeline;
      GstBus *bus;
      GstMessage *msg;
      int argc;
      GError *error = NULL;

      /* Initialize GStreamer */
      if (gst_init_check(&argc, NULL, &error) == TRUE)
      {

          /* Build the pipeline */
          // Change URL to test failure
          pipeline = gst_parse_launch ("bin uri=http://docs.gstreamer.com/media/sintel_trailer-480p.webm", &error);
////          pipeline = gst_parse_launch ("bin uri=http://tecfa.unige.ch/guides/x3d/www.web3d.org/x3d/content/examples/HelloWorld.gif", &error);

          if (pipeline != NULL)
          {
              /* Start playing */
              gst_element_set_state (pipeline, GST_STATE_PLAYING);

              /* wait until it's up and running or failed */
              if (gst_element_get_state (pipeline, NULL, NULL, -1) == GST_STATE_CHANGE_FAILURE)
              {
                 g_error ("GST failed to go into PLAYING state");
                 exit(1);
              }

              /* Wait until error or EOS */
              bus = gst_element_get_bus (pipeline);
              if (bus != NULL)
              {
                  msg = gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE, GST_MESSAGE_ERROR | GST_MESSAGE_EOS);

                  /* Parse message */
                  if (msg != NULL)
                  {
                    gchar *debug_info;

                    switch (GST_MESSAGE_TYPE (msg))
                    {
                      case GST_MESSAGE_ERROR:
                        gst_message_parse_error (msg, &error, &debug_info);
                        g_printerr ("Error received from element %s: %s\n", GST_OBJECT_NAME (msg->src), error->message);
                        g_printerr ("Debugging information: %s\n", debug_info ? debug_info : "none");
                        g_clear_error (&error);
                        g_free (debug_info);
                        break;

                      case GST_MESSAGE_EOS:
                        g_print ("End-Of-Stream reached.\n");
                        break;

                      default:
                        /* We should not reach here because we only asked for ERRORs and EOS */
                        g_printerr ("Unexpected message received.\n");
                        break;
                    }

                    gst_message_unref (msg);
                  }

                  /* Free resources */
                  gst_object_unref (bus);
                  gst_element_set_state (pipeline, GST_STATE_NULL);
                  gst_object_unref (pipeline);
              }
              else
              {
                    g_print ("GST get bus error: %s\n", error->message);
                    exit(1);
              }
          }
          else
          {
                g_print ("GST parse error: %s\n", error->message);
                exit(1);
          }
      }
      else
      {
            g_print ("GST init error: %s\n", error->message);
            exit(1);
      }
}   // GstreamerPlayVideo()

尝试在您的管道中手动指定视频接收器。

videotestsrc ! ximagesink

您的系统可能安装了 EGL 视频接收器插件作为主要视频插件。 ximagesink 似乎更有可能工作。

像这样:

//this line is where you're creating your pipeline
pipeline = gst_parse_launch ("videotestsrc ! ximagesink", &error);

我建议先尝试使用 gst-launch 命令,这样您就可以掌握管道语法、接收器和源是什么等等。最简单的测试 运行 就像这样(如果您安装了 gstreamer 1.0,你可能有 0.10),来自命令行:

gst-launch-1.0 videotestsrc ! autovideosink