小编Dmi*_*vin的帖子

Optarg 始终为空

Optarg 始终为空。应用程序崩溃。

static const char* const short_options = "a:h:p";
static const struct option long_options[] =
{
    { "address",    1, NULL, 'a' },
    { "help",       0, NULL, 'h' },
    { "port",       1, NULL, 'p' }
};
Run Code Online (Sandbox Code Playgroud)

我尝试向 long_options 添加空字符串,但没有帮助。

static const struct option long_options[] =
{
    { "address",    1, NULL, 'a' },
    { "help",       0, NULL, 'h' },
    { "port",       1, NULL, 'p' },
    {0,             0, NULL,  0 }
};
Run Code Online (Sandbox Code Playgroud)

但它没有帮助。

使用 optarg 的示例。我以相同的方式使用 optarg,但得到 null。

do {
        nextOption = …
Run Code Online (Sandbox Code Playgroud)

c++ getopt

1
推荐指数
1
解决办法
627
查看次数

如何使用 Gstreamer 播放原始字符 * 缓冲区?

我有从 video.mp4 文件中读取的 char* 缓冲区。此缓冲区的大小为 4096。我尝试从 char* 缓冲区创建 GstBuffer

GstBuffer* Buffer = gst_buffer_new_wrapped(data, size);
dataBuffer = gst_buffer_copy(tmpBuf);
Run Code Online (Sandbox Code Playgroud)

然后我把这个缓冲区推到appsrc

GstElement* source = gst_bin_get_by_name (GST_BIN (consumer), "source");
gst_app_src_push_buffer (GST_APP_SRC (source), dataBuffer);
gst_object_unref (source);
Run Code Online (Sandbox Code Playgroud)

管道消费者是通过以下方式创建的:

gchar* videoConsumerString = g_strdup_printf ("appsrc max-buffers=5 drop=false name=source ! decodebin ! xvimagesink");
consumer = gst_parse_launch (videoConsumerString, NULL);
gst_element_set_state (consumer, GST_STATE_NULL);
g_free (videoConsumerString);
Run Code Online (Sandbox Code Playgroud)

创建管道后,我将其状态设置为 GST_STATE_NULL。当我开始播放时,我将其状态设置为 GST_STATE_PLAYING。

但在外面我得到了错误:

ERROR from element mpegvparse0: No valid frames found before end of stream
Run Code Online (Sandbox Code Playgroud)

我尝试更改 char* 缓冲区的大小,在管道中使用不同的元素(例如 ffmpegcolorspace、videconvert 等),但没有解决此问题。

如果使用 GST_DEBUG=3 …

c++ gstreamer

1
推荐指数
1
解决办法
2754
查看次数

标签 统计

c++ ×2

getopt ×1

gstreamer ×1