2

这是我的搜索功能:

gboolean seek(CustomData* data)
{
    gint64 position;
    GstFormat format = GST_FORMAT_TIME;
    GstEvent *seek_event;

    /* Obtain the current position, needed for the seek event */
    if (!gst_element_query_position(data->pipeline, &format, &position))
    {
        g_printerr("Unable to retrieve current position.\n");
        return FALSE;
    }

    /* Create the seek event */
    if (data->rate > 0)
    {
        seek_event = gst_event_new_seek(data->rate, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE, GST_SEEK_TYPE_SET,
                position, GST_SEEK_TYPE_NONE, 0);
    }
    else if (data->rate < 0)
    {
        seek_event = gst_event_new_seek(data->rate, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE, GST_SEEK_TYPE_SET, 0,
                GST_SEEK_TYPE_SET, position);
    }
    else
    {
        g_printerr("Rate is set to 0.\n");
        return FALSE;
    }

    /* Check that seek_event was created */
    if (seek_event == NULL) {
        g_printerr("Could not create seek event.\n");
        return FALSE;
    }

    /* Send the event */
    if (!gst_element_send_event(data->autovideosink, seek_event))
    {
        g_printerr("Could not perform seek event.\n");
        return FALSE;
    }

    g_print("Current rate: %gx\n", data->rate);

    return TRUE;
}

但它无法发送 seek 事件。这段代码只是从 GStreamer 教程中稍微修改了一下,但我正在播放一个 .vob 文件,并且我有一个自定义管道而不是 playbin2。我也在使用appsrc,所以我从文件中提供缓冲区,但我不认为这会导致快速转发出现任何问题。但是,我不能向前或向后寻找(将速率设置为 2x 或 .5x 在同一位置失败)。

4

1 回答 1

2

我有同样的问题,我在调试输出中发现了这个:

0:00:49.048266933  4480   03B05000 DEBUG                basesrc gstbasesrc.c:1972:gst_base_src_default_event:<app_source> is not seekable
0:00:49.048386221  4480   03B05000 DEBUG                basesrc gstbasesrc.c:2000:gst_base_src_event:<app_source> subclass refused event
0:00:49.048515238  4480   03B05000 DEBUG               GST_PADS gstpad.c:5050:gst_pad_send_event_unchecked:<app_source:src> sent event, ret error

看起来 appsrc 元素不支持搜索或事件正在向上游发送而不是向下游发送。

于 2014-03-04T12:58:22.847 回答