【gstreamer】Windows VS2022+gstreamer 安装配置

主要分为以下几个步骤:
1)gstreamer 安装
选gstreamer版本 官网
作者使用的版本是MSVC 64-bit (VS 2019, Release CRT)

先安装gstreamer-1.0-msvc-x86_64-1.22.3.msi,choose setup type 时选择 Complete,完整安装
然后gstreamer-1.0-devel-msvc-x86_64-1.22.3.msi 也选择 Complete。

安装结束后会在msi所在路径的根目录下生成gstreamer文件夹,里面的内容就是刚安装的部分。
打开cmd窗口,运行以下命令测试

gst-inspect-1.0 coreelements

运行成功,则会打印一堆plugin details,不成功请回到前面选择合适版本重新安装

到这里,gstreamer就算安装成功了
2)VS2022配置

  1. 创建c++空项目
  2. 配置环境

解决方案资源管理器里选择项目名,右键,属性。
在c/c++ -------常规--------附加包含目录 增加如下目录(作者gstreamer安装在D盘,依据个人路径改动)

D:\gstreamer\1.0\msvc_x86_64\include\gstreamer-1.0
D:\gstreamer\1.0\msvc_x86_64\include\glib-2.0
D:\gstreamer\1.0\msvc_x86_64\include\libxml2
D:\gstreamer\1.0\msvc_x86_64\include

连接器----常规----附加库目录,增加 如下目录

D:\gstreamer\1.0\msvc_x86_64\lib

连接器----输入-----附加依赖性 增加

gobject-2.0.lib;glib-2.0.lib;gstreamer-1.0.lib

测试一下,输入以下代码,没有找不到gst/gst.h基本就成功了,可以尝试生成sln

#include 

#ifdef __APPLE__
#include 
#endif

int
tutorial_main (int argc, char *argv[])
{
  GstElement *pipeline;
  GstBus *bus;
  GstMessage *msg;

  /* Initialize GStreamer */
  gst_init (&argc, &argv);

  /* Build the pipeline */
  pipeline =
      gst_parse_launch
      ("playbin uri=https://gstreamer.freedesktop.org/data/media/sintel_trailer-480p.webm",
      NULL);

  /* Start playing */
  gst_element_set_state (pipeline, GST_STATE_PLAYING);

  /* Wait until error or EOS */
  bus = gst_element_get_bus (pipeline);
  msg =
      gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE,
      GST_MESSAGE_ERROR);

  /* See next tutorial for proper error message handling/parsing */
  if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR) {
    g_error ("run successful while result have another dependence. An error occurred! Re-run with the GST_DEBUG=*:WARN environment "
        "variable set for more details.");
  }

  /* Free resources */
  gst_message_unref (msg);
  gst_object_unref (bus);
  gst_element_set_state (pipeline, GST_STATE_NULL);
  gst_object_unref (pipeline);
  return 0;
}

int
main (int argc, char *argv[])
{
#if defined(__APPLE__) && TARGET_OS_MAC && !TARGET_OS_IPHONE
  return gst_macos_main (tutorial_main, argc, argv, NULL);
#else
  return tutorial_main (argc, argv);
#endif
}

你可能感兴趣的:(multi-media,windows,c++,linux,gstreamer)