[gstreamer] goption

Posted renhl

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[gstreamer] goption相关的知识,希望对你有一定的参考价值。

■ The GOption interface:

goption.c

 1 #include <gst/gst.h>
 2 #include <stdio.h>
 3 int
 4 main (int   argc,
 5       char *argv[])
 6 {
 7   gboolean silent = FALSE;
 8   gchar *savefile = NULL;
 9   GOptionContext *ctx;
10   GError *err = NULL;
11   GOptionEntry entries[] = {
12     { "silent", s, 0, G_OPTION_ARG_NONE, &silent,
13       "do not output status information", NULL },
14     { "output", o, 0, G_OPTION_ARG_STRING, &savefile,
15       "save xml representation of pipeline to FILE and exit", "FILE" },
16     { NULL }
17   };
18 
19   ctx = g_option_context_new ("- Your application");
20   g_option_context_add_main_entries (ctx, entries, NULL);
21   g_option_context_add_group (ctx, gst_init_get_option_group ());
22   if (!g_option_context_parse (ctx, &argc, &argv, &err)) {
23     g_print ("Failed to initialize: %s
", err->message);
24     g_clear_error (&err);
25     g_option_context_free (ctx);
26     return 1;
27   }
28   g_option_context_free (ctx);
29 
30   printf ("Run me with --help to see the Application options appended.
");
31   printf ("silent = %d savefile=%s.
", silent, savefile);
32 
33   return 0;
34 }

■ 编译

gcc goption.c -o goption `pkg-config --cflags --libs gstreamer-1.0`

■ 运行结果

[email protected]:~/share/1/goption$ ./goption -o test.txt
Run me with --help to see the Application options appended.
silent = 0 savefile=test.txt.
[email protected]:~/share/1/goption$ ./goption -s 1  -o test.txt
Run me with --help to see the Application options appended.
silent = 1 savefile=test.txt.
[email protected]:~/share/1/goption$ vim goption.c

 

■ 参考

https://developer.gnome.org/glib/stable/glib-Commandline-option-parser.html

https://gstreamer.freedesktop.org/documentation/application-development/basics/init.html#the-goption-interface

 

以上是关于[gstreamer] goption的主要内容,如果未能解决你的问题,请参考以下文章

在 Qt C++ 中访问 GStreamer 库时出错 - 程序在调试时被代码 0xc0000135 激发

视频编码原理及Gstreamer 硬编码代码实现

Gstreamer 音频输入到 mp3

GStreamer 与 FFmpeg

我是不是需要使用 Gstreamer 构建 OpenCV 才能在 OpenCV 中使用 Gstreamer

Android Studio中的Gstreamer示例