GStreamer演示deosn在虚拟机中工作(寻求简单示例)

时间:2015-05-20 13:40:55

标签: virtual-machine gstreamer

我尝试编写一个非常简单的GStreamer应用程序。只要GStreamer做某事,它的作用并不重要。即使只显示一些文字或简单的JPEG也没关系。

下面是Googling找到的最好的例子(我添加了一些错误检查)。当我在Windows下运行的Linux虚拟机中运行它时,我看到这个控制台消息:

  

libEGL警告:fd 4的pci id:80ee:beef,driver(null)

     

libEGL警告:DRI2:无法打开vboxvideo(搜索路径   / usr / lib中/ I386-Linux的GNU / DRI:$ {ORIGIN} / DRI:/ usr / lib中/ DRI)

Google搜索表示这是虚拟机内3D渲染的错误。我找不到解决办法。

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

这是代码......

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()

1 个答案:

答案 0 :(得分:1)

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

  
    

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