使用 Appsrc Appsink 时出错

发布于 2024-11-26 19:32:42 字数 5598 浏览 1 评论 0原文

这是我第一次在 C 程序中使用 Gstreamer。我只用过管道。我正在尝试编写一个程序,该程序采用流将其存储在缓冲区中,使用 OpenCv 编辑流并使用带有 appsrc 的管道来查看流。我收到错误:

rb1:3231): GStreamer-CRITICAL **: gst_caps_get_struct: 断言`index <; caps->structs->len' 失败

(rb1:3231):GStreamer-CRITICAL **:gst_struct_has_field:断言“结构!= NULL”失败

(rb1:3231):GStreamer-CRITICAL **:gst_struct_fixate_field_nearest_fraction:断言“gst_struct_has_field(结构,field_name)”失败

(rb1:3231):GStreamer-CRITICAL **:gst_struct_get_fraction:断言“结构!= NULL”失败

(rb1:3231):GStreamer-CRITICAL **:gst_struct_has_field:断言“结构!= NULL”失败

(rb1:3231):GStreamer-CRITICAL **:gst_struct_has_field:断言“结构!= NULL”失败

(rb1:3231):GStreamer-CRITICAL **:gst_struct_has_field:断言“结构!= NULL”失败

(rb1:3231):GStreamer-CRITICAL **:gst_struct_has_field:断言“结构!= NULL”失败

(rb1:3231): GStreamer-CRITICAL **: gst_pad_set_caps: 断言 `caps == NULL || gst_caps_is_fixed(大写字母)'失败

** 错误 **:未协商 正在中止... 已中止

感激。

作为参考,我给出了代码(我还没有实现 OpenCV 部分):

#include <gst/gst.h>
#include <gst/app/gstappsrc.h>
#include <gst/app/gstappbuffer.h>
#include <gst/app/gstappsink.h>
#include <gst/gstbuffer.h>
#include <stdbool.h>
#include <stdio.h>

static GMainLoop *loop;
GstBuffer *buffer;
GstAppSinkCallbacks callbacks;
GstElement *pipeline_in;
GstElement *pipeline_out;
GstBus *bus;
GError *error;
const char app_sink_name[] = "app-sink";
const char app_src_name[] = "app-src";
const char pipeline_in_str[500];
const char pipeline_out_str[500];

static gboolean bus_call(GstBus * bus, GstMessage * msg, void *user_data)
{
    gchar *userdata = (gchar *) user_data;
    switch (GST_MESSAGE_TYPE(msg)) {
    case GST_MESSAGE_EOS:{
            //sender check - pipeline1 sends a EOS msg to AppSrc in pipeline2
            if (g_ascii_strcasecmp(userdata, gst_element_get_name(pipeline_in)) == 0) {
                g_print("EOS detected (%s)n", userdata);
                gst_app_src_end_of_stream(GST_APP_SRC(gst_bin_get_by_name(GST_BIN(pipeline_out), app_src_name)));
            }
            //sender check - when pipeline2 sends the EOS msg, quite.
            if (g_ascii_strcasecmp(userdata, gst_element_get_name(pipeline_out)) == 0) {
                g_print("Finished playback (%s)n", userdata);
                g_main_loop_quit(loop);
            }
            break;
        }
    case GST_MESSAGE_ERROR:{
            GError *err;
            gst_message_parse_error(msg, &err, NULL);
            g_error("%s", err->message);
            g_error_free(err);

            g_main_loop_quit(loop);
            break;
        }
    default:
        break;
    }

    return true;
}

GstFlowReturn newbuffer(GstAppSink * app_sink, gpointer user_data)
{
    GstBuffer *buffer = gst_app_sink_pull_buffer((GstAppSink *) gst_bin_get_by_name(GST_BIN(pipeline_in), app_sink_name));
    gst_app_src_push_buffer(GST_APP_SRC(gst_bin_get_by_name(GST_BIN(pipeline_out), app_src_name)), buffer);
    return GST_FLOW_OK;
}

int main(int argc, char *argv[])
{
    int result;
    gst_init(&argc, &argv);
    loop = g_main_loop_new(NULL, FALSE);

    pipeline_in = gst_pipeline_new("my_pipeline");
    pipeline_out = gst_pipeline_new("my_pipeline2");
    //result=sprintf(pipeline_in_str, "udpsrc port=5000 ! video/x-h264, width=(int)640,  height=(int)480, framerate=(fraction)30/1, pixel-aspect-ratio=(fraction    )1/1, codec_data=(buffer            )0142c01effe100176742c01e92540501ed8088000003000bb9aca00078b17501000468ce3c80, stream-format=(string)avc, alignment=(string)au ! ffdec_h264 ! video/x-raw-yuv,width=640,height=480 ! ffmpegcolorspace ! video/x-raw-rgb,width=640,height=480 !   ffmpegcolorspace ! appsink name="%s"", app_sink_name);
    result = sprintf(pipeline_in_str, "videotestsrc ! video/x-raw-rgb, width=640, height=480     ! ffmpegcolorspace ! appsink name=%s", app_sink_name);
    printf("First pipeline string nn%sn", pipeline_in_str);
    pipeline_in = gst_parse_launch(pipeline_in_str, &error);
    if (error) {
        g_printerr("Error in first pipeline: %sn", error->message);
        return -1;
    }
    result = sprintf(pipeline_out_str, "appsrc name=%s ! queue ! videoparse format=14    width=640 height=480 ! videorate ! videoscale ! ffmpegcolorspace ! video/x-        raw-rgb,width=640,height=480 ! xvimagesink", app_src_name);
    printf("Second pipeline stringnn%sn", pipeline_out_str);
    pipeline_out = gst_parse_launch(pipeline_out_str, &error);
    if (error) {
        g_printerr("Error in first pipeline: %sn", error->message);
        return -1;
    }

    bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline_in));
    gst_bus_add_watch(bus, bus_call, NULL);
    gst_object_unref(bus);
    bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline_out));
    gst_bus_add_watch(bus, bus_call, NULL);
    gst_object_unref(bus);
    gst_element_set_state(GST_ELEMENT(pipeline_in), GST_STATE_PLAYING);
    gst_element_set_state(GST_ELEMENT(pipeline_out), GST_STATE_PLAYING);

    callbacks.eos = NULL;
    callbacks.new_preroll = NULL;
    callbacks.new_buffer = newbuffer;
    gst_app_sink_set_callbacks((GstAppSink *) gst_bin_get_by_name(GST_BIN(pipeline_in), app_sink_name), &callbacks, NULL, NULL);

    g_main_loop_run(loop);
    gst_element_set_state(GST_ELEMENT(pipeline_in), GST_STATE_NULL);
    gst_element_set_state(GST_ELEMENT(pipeline_out), GST_STATE_NULL);
    gst_object_unref(GST_OBJECT(pipeline_in));
    gst_object_unref(GST_OBJECT(pipeline_out));
    return 0;
}

/* indented using http://indentcode.net/ */

This would be my first time working with Gstreamer in a C program. I've only used pipelines. I'm trying to write a program which takes a stream stores it in a buffer, uses OpenCv to edit the stream and use a pipeline with appsrc to view the stream. I'm getting the error:

rb1:3231): GStreamer-CRITICAL **: gst_caps_get_structure: assertion `index < caps->structs->len' failed

(rb1:3231): GStreamer-CRITICAL **: gst_structure_has_field: assertion `structure != NULL' failed

(rb1:3231): GStreamer-CRITICAL **: gst_structure_fixate_field_nearest_fraction: assertion `gst_structure_has_field (structure, field_name)' failed

(rb1:3231): GStreamer-CRITICAL **: gst_structure_get_fraction: assertion `structure != NULL' failed

(rb1:3231): GStreamer-CRITICAL **: gst_structure_has_field: assertion `structure != NULL' failed

(rb1:3231): GStreamer-CRITICAL **: gst_structure_has_field: assertion `structure != NULL' failed

(rb1:3231): GStreamer-CRITICAL **: gst_structure_has_field: assertion `structure != NULL' failed

(rb1:3231): GStreamer-CRITICAL **: gst_structure_has_field: assertion `structure != NULL' failed

(rb1:3231): GStreamer-CRITICAL **: gst_pad_set_caps: assertion `caps == NULL || gst_caps_is_fixed (caps)' failed

** ERROR **: not negotiated
aborting...
Aborted

Any help would be appreciated.

For reference i've given the code (I"ve not implemented the OpenCV part yet):

#include <gst/gst.h>
#include <gst/app/gstappsrc.h>
#include <gst/app/gstappbuffer.h>
#include <gst/app/gstappsink.h>
#include <gst/gstbuffer.h>
#include <stdbool.h>
#include <stdio.h>

static GMainLoop *loop;
GstBuffer *buffer;
GstAppSinkCallbacks callbacks;
GstElement *pipeline_in;
GstElement *pipeline_out;
GstBus *bus;
GError *error;
const char app_sink_name[] = "app-sink";
const char app_src_name[] = "app-src";
const char pipeline_in_str[500];
const char pipeline_out_str[500];

static gboolean bus_call(GstBus * bus, GstMessage * msg, void *user_data)
{
    gchar *userdata = (gchar *) user_data;
    switch (GST_MESSAGE_TYPE(msg)) {
    case GST_MESSAGE_EOS:{
            //sender check - pipeline1 sends a EOS msg to AppSrc in pipeline2
            if (g_ascii_strcasecmp(userdata, gst_element_get_name(pipeline_in)) == 0) {
                g_print("EOS detected (%s)n", userdata);
                gst_app_src_end_of_stream(GST_APP_SRC(gst_bin_get_by_name(GST_BIN(pipeline_out), app_src_name)));
            }
            //sender check - when pipeline2 sends the EOS msg, quite.
            if (g_ascii_strcasecmp(userdata, gst_element_get_name(pipeline_out)) == 0) {
                g_print("Finished playback (%s)n", userdata);
                g_main_loop_quit(loop);
            }
            break;
        }
    case GST_MESSAGE_ERROR:{
            GError *err;
            gst_message_parse_error(msg, &err, NULL);
            g_error("%s", err->message);
            g_error_free(err);

            g_main_loop_quit(loop);
            break;
        }
    default:
        break;
    }

    return true;
}

GstFlowReturn newbuffer(GstAppSink * app_sink, gpointer user_data)
{
    GstBuffer *buffer = gst_app_sink_pull_buffer((GstAppSink *) gst_bin_get_by_name(GST_BIN(pipeline_in), app_sink_name));
    gst_app_src_push_buffer(GST_APP_SRC(gst_bin_get_by_name(GST_BIN(pipeline_out), app_src_name)), buffer);
    return GST_FLOW_OK;
}

int main(int argc, char *argv[])
{
    int result;
    gst_init(&argc, &argv);
    loop = g_main_loop_new(NULL, FALSE);

    pipeline_in = gst_pipeline_new("my_pipeline");
    pipeline_out = gst_pipeline_new("my_pipeline2");
    //result=sprintf(pipeline_in_str, "udpsrc port=5000 ! video/x-h264, width=(int)640,  height=(int)480, framerate=(fraction)30/1, pixel-aspect-ratio=(fraction    )1/1, codec_data=(buffer            )0142c01effe100176742c01e92540501ed8088000003000bb9aca00078b17501000468ce3c80, stream-format=(string)avc, alignment=(string)au ! ffdec_h264 ! video/x-raw-yuv,width=640,height=480 ! ffmpegcolorspace ! video/x-raw-rgb,width=640,height=480 !   ffmpegcolorspace ! appsink name="%s"", app_sink_name);
    result = sprintf(pipeline_in_str, "videotestsrc ! video/x-raw-rgb, width=640, height=480     ! ffmpegcolorspace ! appsink name=%s", app_sink_name);
    printf("First pipeline string nn%sn", pipeline_in_str);
    pipeline_in = gst_parse_launch(pipeline_in_str, &error);
    if (error) {
        g_printerr("Error in first pipeline: %sn", error->message);
        return -1;
    }
    result = sprintf(pipeline_out_str, "appsrc name=%s ! queue ! videoparse format=14    width=640 height=480 ! videorate ! videoscale ! ffmpegcolorspace ! video/x-        raw-rgb,width=640,height=480 ! xvimagesink", app_src_name);
    printf("Second pipeline stringnn%sn", pipeline_out_str);
    pipeline_out = gst_parse_launch(pipeline_out_str, &error);
    if (error) {
        g_printerr("Error in first pipeline: %sn", error->message);
        return -1;
    }

    bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline_in));
    gst_bus_add_watch(bus, bus_call, NULL);
    gst_object_unref(bus);
    bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline_out));
    gst_bus_add_watch(bus, bus_call, NULL);
    gst_object_unref(bus);
    gst_element_set_state(GST_ELEMENT(pipeline_in), GST_STATE_PLAYING);
    gst_element_set_state(GST_ELEMENT(pipeline_out), GST_STATE_PLAYING);

    callbacks.eos = NULL;
    callbacks.new_preroll = NULL;
    callbacks.new_buffer = newbuffer;
    gst_app_sink_set_callbacks((GstAppSink *) gst_bin_get_by_name(GST_BIN(pipeline_in), app_sink_name), &callbacks, NULL, NULL);

    g_main_loop_run(loop);
    gst_element_set_state(GST_ELEMENT(pipeline_in), GST_STATE_NULL);
    gst_element_set_state(GST_ELEMENT(pipeline_out), GST_STATE_NULL);
    gst_object_unref(GST_OBJECT(pipeline_in));
    gst_object_unref(GST_OBJECT(pipeline_out));
    return 0;
}

/* indented using http://indentcode.net/ */

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

昵称有卵用 2024-12-03 19:32:42

检查为什么你会得到断言。

例如:

$ G_DEBUG=fatal_warnings gdb g
GNU gdb (GDB) Fedora (7.2-51.fc14)
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/thomas/g...(no debugging symbols found)...done.
(gdb) r
Starting program: /home/thomas/g 
[Thread debugging using libthread_db enabled]
[New Thread 0x7ffff0e59700 (LWP 24710)]
[New Thread 0x7fffebfff700 (LWP 24711)]
[New Thread 0x7fffeb7fe700 (LWP 24712)]
[New Thread 0x7fffeaffd700 (LWP 24713)]
[New Thread 0x7fffea7fc700 (LWP 24714)]

GStreamer-CRITICAL **: gst_caps_get_structure: assertion `index < caps->structs->len' failed
aborting...
First pipeline string nnvideotestsrc ! video/x-raw-rgb, width=640, height=480     ! ffmpegcolorspace ! appsink name=app-sinknSecond pipeline stringnnappsrc name=app-src ! queue ! videoparse format=14   width=640 height=480 ! videorate ! videoscale ! ffmpegcolorspace ! video/x-raw-rgb,width=640,height=480 ! xvimagesinkn
Program received signal SIGABRT, Aborted.
[Switching to Thread 0x7fffeb7fe700 (LWP 24712)]
0x0000003112e330c5 in raise (sig=6)
    at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
64    return INLINE_SYSCALL (tgkill, 3, pid, selftid, sig);
(gdb) bt
#0  0x0000003112e330c5 in raise (sig=6)
    at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#1  0x0000003112e34a76 in abort () at abort.c:92
#2  0x0000003114a4ab8a in g_logv (log_domain=0x34f3ea7f18 "GStreamer", 
    log_level=<value optimized out>, format=
    0x3114aac838 "%s: assertion `%s' failed", args1=0x7fffeb7fd940)
    at gmessages.c:557
#3  0x0000003114a4ac13 in g_log (log_domain=<value optimized out>, 
    log_level=<value optimized out>, format=<value optimized out>)
    at gmessages.c:577
#4  0x00000034f3e3b0a2 in gst_caps_get_structure (caps=0x7fffe40014c0, index=0)
    at gstcaps.c:864
#5  0x00007ffff1287417 in gst_video_rate_setcaps (pad=<value optimized out>, 
    caps=0x7fffe40014c0) at gstvideorate.c:335
#6  0x00000034f3e5e7bf in gst_pad_set_caps (pad=0x864180 [GstPad], caps=
    0x7fffdc005e80) at gstpad.c:2667
#7  0x00000034f3e5fa5a in gst_pad_chain_data_unchecked (pad=0x864180 [GstPad], 
    is_buffer=1, data=0x7fffe0002b30) at gstpad.c:4172
#8  0x00000034f3e60136 in gst_pad_push_data (pad=0x864000 [GstPad], is_buffer=
    1, data=0x7fffe0002b30) at gstpad.c:4419
#9  0x00007ffff148e54b in gst_raw_parse_chain (pad=<value optimized out>, 
    buffer=<value optimized out>) at gstrawparse.c:292
#10 0x00000034f3e5f96d in gst_pad_chain_data_unchecked (pad=0x83edf0 [GstPad], 
    is_buffer=1, data=0x7fffec002480) at gstpad.c:4190
#11 0x00000034f3e60136 in gst_pad_push_data (pad=0x83ec70 [GstPad], is_buffer=
    1, data=0x7fffec002480) at gstpad.c:4419
#12 0x00007ffff16a9e43 in gst_queue_push_one (pad=<value optimized out>)
    at gstqueue.c:1144
#13 gst_queue_loop (pad=<value optimized out>) at gstqueue.c:1260
#14 0x00000034f3e88c46 in gst_task_func (task=0x8eb110 [GstTask])
    at gsttask.c:271
#15 0x0000003114a6bbc4 in g_thread_pool_thread_proxy (
    data=<value optimized out>) at gthreadpool.c:319
#16 0x0000003114a69446 in g_thread_create_proxy (data=0x8debc0)
    at gthread.c:1897
#17 0x0000003113206ccb in start_thread (arg=0x7fffeb7fe700)
    at pthread_create.c:301
#18 0x0000003112ee0c2d in clone ()
    at ../sysdeps/unix/sysv/linux/x86_64/clone.S:115

使用 GST_DEBUG=*:5 获取失败原因的更详细输出。

结合 G_DEBUG 设置以确保它在遇到断言时停止。

Check why you are getting the assertions.

For example:

$ G_DEBUG=fatal_warnings gdb g
GNU gdb (GDB) Fedora (7.2-51.fc14)
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/thomas/g...(no debugging symbols found)...done.
(gdb) r
Starting program: /home/thomas/g 
[Thread debugging using libthread_db enabled]
[New Thread 0x7ffff0e59700 (LWP 24710)]
[New Thread 0x7fffebfff700 (LWP 24711)]
[New Thread 0x7fffeb7fe700 (LWP 24712)]
[New Thread 0x7fffeaffd700 (LWP 24713)]
[New Thread 0x7fffea7fc700 (LWP 24714)]

GStreamer-CRITICAL **: gst_caps_get_structure: assertion `index < caps->structs->len' failed
aborting...
First pipeline string nnvideotestsrc ! video/x-raw-rgb, width=640, height=480     ! ffmpegcolorspace ! appsink name=app-sinknSecond pipeline stringnnappsrc name=app-src ! queue ! videoparse format=14   width=640 height=480 ! videorate ! videoscale ! ffmpegcolorspace ! video/x-raw-rgb,width=640,height=480 ! xvimagesinkn
Program received signal SIGABRT, Aborted.
[Switching to Thread 0x7fffeb7fe700 (LWP 24712)]
0x0000003112e330c5 in raise (sig=6)
    at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
64    return INLINE_SYSCALL (tgkill, 3, pid, selftid, sig);
(gdb) bt
#0  0x0000003112e330c5 in raise (sig=6)
    at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#1  0x0000003112e34a76 in abort () at abort.c:92
#2  0x0000003114a4ab8a in g_logv (log_domain=0x34f3ea7f18 "GStreamer", 
    log_level=<value optimized out>, format=
    0x3114aac838 "%s: assertion `%s' failed", args1=0x7fffeb7fd940)
    at gmessages.c:557
#3  0x0000003114a4ac13 in g_log (log_domain=<value optimized out>, 
    log_level=<value optimized out>, format=<value optimized out>)
    at gmessages.c:577
#4  0x00000034f3e3b0a2 in gst_caps_get_structure (caps=0x7fffe40014c0, index=0)
    at gstcaps.c:864
#5  0x00007ffff1287417 in gst_video_rate_setcaps (pad=<value optimized out>, 
    caps=0x7fffe40014c0) at gstvideorate.c:335
#6  0x00000034f3e5e7bf in gst_pad_set_caps (pad=0x864180 [GstPad], caps=
    0x7fffdc005e80) at gstpad.c:2667
#7  0x00000034f3e5fa5a in gst_pad_chain_data_unchecked (pad=0x864180 [GstPad], 
    is_buffer=1, data=0x7fffe0002b30) at gstpad.c:4172
#8  0x00000034f3e60136 in gst_pad_push_data (pad=0x864000 [GstPad], is_buffer=
    1, data=0x7fffe0002b30) at gstpad.c:4419
#9  0x00007ffff148e54b in gst_raw_parse_chain (pad=<value optimized out>, 
    buffer=<value optimized out>) at gstrawparse.c:292
#10 0x00000034f3e5f96d in gst_pad_chain_data_unchecked (pad=0x83edf0 [GstPad], 
    is_buffer=1, data=0x7fffec002480) at gstpad.c:4190
#11 0x00000034f3e60136 in gst_pad_push_data (pad=0x83ec70 [GstPad], is_buffer=
    1, data=0x7fffec002480) at gstpad.c:4419
#12 0x00007ffff16a9e43 in gst_queue_push_one (pad=<value optimized out>)
    at gstqueue.c:1144
#13 gst_queue_loop (pad=<value optimized out>) at gstqueue.c:1260
#14 0x00000034f3e88c46 in gst_task_func (task=0x8eb110 [GstTask])
    at gsttask.c:271
#15 0x0000003114a6bbc4 in g_thread_pool_thread_proxy (
    data=<value optimized out>) at gthreadpool.c:319
#16 0x0000003114a69446 in g_thread_create_proxy (data=0x8debc0)
    at gthread.c:1897
#17 0x0000003113206ccb in start_thread (arg=0x7fffeb7fe700)
    at pthread_create.c:301
#18 0x0000003112ee0c2d in clone ()
    at ../sysdeps/unix/sysv/linux/x86_64/clone.S:115

Use GST_DEBUG=*:5 to get a more detailed output of what is failing.

Combine the G_DEBUG setting to make sure it stops when it hits the assertion.

甲如呢乙后呢 2024-12-03 19:32:42

虽然我还没有完全弄清楚错误到底是什么,但我设法让它工作。我更改了管道的字符串(在 gst_parse_launch 函数中)。第二个管道 *pipeline_out* 中一定有一些错误。

Though I haven't quite figured out what exactly the error was, i managed to get it working. I changed the string for the pipeline (in the gst_parse_launch function). It must've been some error in the second pipeline, *pipeline_out*.

半葬歌 2024-12-03 19:32:42
callbacks.eos = NULL;
callbacks.new_preroll = NULL;
callbacks.new_buffer = newbuffer;
gst_app_sink_set_callbacks((GstAppSink *) gst_bin_get_by_name(GST_BIN(pipeline_in), app_sink_name), &callbacks, NULL, NULL);

gst_element_set_state(GST_ELEMENT(pipeline_in), GST_STATE_PLAYING);
gst_element_set_state(GST_ELEMENT(pipeline_out), GST_STATE_PLAYING);

g_main_loop_run(loop);

播放应该在设置回调后完成,并尝试使用传递到缓冲区的 appsink 从缓冲区中拉取,您将获得良好的性能。

callbacks.eos = NULL;
callbacks.new_preroll = NULL;
callbacks.new_buffer = newbuffer;
gst_app_sink_set_callbacks((GstAppSink *) gst_bin_get_by_name(GST_BIN(pipeline_in), app_sink_name), &callbacks, NULL, NULL);

gst_element_set_state(GST_ELEMENT(pipeline_in), GST_STATE_PLAYING);
gst_element_set_state(GST_ELEMENT(pipeline_out), GST_STATE_PLAYING);

g_main_loop_run(loop);

Playing should be done after you have set the callbacks, and try to use the appsink that's passed to the buffer to pull from the buffer, you'd get good performance.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文