gst_element_seek_simple returns false using GST_FORMAT_BYTES format

greg gallardo raydeeohwayshun at gmail.com
Mon Sep 26 15:37:30 UTC 2016


Hi,
I've been trying to use  gst_element_seek_simple() to move around in a
video file.   I'm using gstreamer 1.8.2 on Windows 7 and 10 with  Visual
Studio 2010.

I'm building the pipeline using gst_parse_launch ().

            gchar location[] = "C:\\temp\\test.h264";

            CustomData customdata;
            memset(&customdata, 0, sizeof(customdata));

            gst_init(NULL, NULL);
            gst_debug_set_threshold_from_string("video*:6", TRUE);

            GError *error = NULL;
            GstElement *pipeline = gst_parse_launch("filesrc name=src !
decodebin name=dec ! videoconvert name=conv ! autovideosink name=sink",
&error);

            customdata.pipeline = pipeline;

            // set file
            GstElement *src = gst_bin_get_by_name(GST_BIN(pipeline), "src");
            g_object_set(src, "location", location, NULL);

            //
            GstElement *dec = gst_bin_get_by_name(GST_BIN(pipeline), "dec");
            if (dec)
            {
                g_signal_connect(dec, "pad-added", G_CALLBACK(cb_newpad),
(gpointer)&customdata);
            }

            GstElement *conv = gst_bin_get_by_name(GST_BIN(pipeline),
"conv");
            customdata.conv = conv;

            GstElement *sink = gst_bin_get_by_name(GST_BIN(pipeline),
"sink");
            GstCaps *appsink_caps = gst_caps_from_string(APPSINK_CAPS);
            g_object_set(G_OBJECT(sink), "caps", appsink_caps, NULL);
            gst_caps_unref(appsink_caps);

            GstAppSink *appsink = (GstAppSink *)sink;
            gst_app_sink_set_max_buffers(appsink, 300); // limit number of
buffers queued
            gst_app_sink_set_drop(appsink, true);
            GstStateChangeReturn ret = gst_element_set_state(pipeline,
GST_STATE_PAUSED);
            GThread *main_loop_thread = g_thread_new("main_loop_thread",
&thread_func_main_loop_run, (gpointer)&customdata);

I'm able to see video frames with this.  I have some code that lets me step
through the video using gst_event_new_step().

I'm able to seek using GST_FORMAT_TIME and gst_element_seek_simple()
The following code returns true and I can see the video change to a new
frame.
                success = gst_element_seek_simple(GST_FORMAT_TIME,
                                                  format,

(GstSeekFlags)(GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_SNAP_NEAREST),
                                                  position);


Switching to GST_FORMAT_BYTES, gst_element_seek_simple returns false

                success = gst_element_seek_simple(GST_FORMAT_BYTES,
                                                  format,

(GstSeekFlags)(GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_SNAP_NEAREST),
                                                  position);


debug output says there's a problem with converting

    0:03:40.267769863  4668 00000000035CD1E0 DEBUG           videodecoder
gstvideodecoder.c:1671:gst_video_decoder_src_event:<avdec_h264-0> received
event 51201, seek
    0:03:40.269860528  4668 00000000035CD1E0 DEBUG           videodecoder
gstvideodecoder.c:1572:gst_video_decoder_src_event_default:<avdec_h264-0>
received event 51201, seek
    0:03:40.272414995  4668 00000000035CD1E0 DEBUG           videodecoder
gstvideodecoder.c:1812:gst_video_decoder_src_query:<avdec_h264-0> received
query 20483, convert
    0:03:40.307895856  4668 00000000035CD1E0 LOG             videodecoder
gstvideodecoder.c:1685:gst_video_decoder_src_query_default:<avdec_h264-0>
handling query: convert query: 00000000035B3DD0, GstQueryConvert,
src_format=(GstFormat)GST_FORMAT_BYTES, src_value=(gint64)713509,
dest_format=(GstFormat)GST_FORMAT_TIME, dest_value=(gint64)-1;
    0:03:40.318774662  4668 00000000035CD1E0 DEBUG           videodecoder
gstvideodecoder.c:1751:gst_video_decoder_src_query_default:<avdec_h264-0>
convert query
    0:03:40.321472536  4668 00000000035CD1E0 ERROR           videodecoder
gstvideodecoder.c:1797:gst_video_decoder_src_query_default:<avdec_h264-0>
query failed
    0:03:40.353767622  4668 00000000035CD1E0 DEBUG           videodecoder
gstvideodecoder.c:1656:gst_video_decoder_src_event_default:<avdec_h264-0>
could not convert format


I'm new to gstreamer and I'm not sure what this means.  Presumably the byte
format has to be changed into a time in the video.  Is there something I
should be doing to make this conversion happen?    Trying to convert using
gst_element_query_convert() gets me the same error message.

Thanks,

Greg
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20160926/e6e6c749/attachment.html>


More information about the gstreamer-devel mailing list