Evan
Evan

Reputation: 1378

Why are seek events failing with my GStreamer app?

This is my seeking function:

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;
}

But it fails at sending the seek event. This code is pertty much just slightly modified from the GStreamer tutorials, but I'm playing a .vob file and I have a custom pipeline instead of playbin2. I'm also using appsrc so I'm feeding the buffers from a file, but I don't imagine that would cause any problems with fast forwarding. However, I can't seek either forward or backward (setting the rate to 2x or .5x fails at the same spot).

Upvotes: 2

Views: 2139

Answers (1)

slayer69
slayer69

Reputation: 81

I have same problem and I've found this on debug output:

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

It looks like appsrc element does not support seeking or event is sending upstream instead downstream.

Upvotes: 2

Related Questions