gst_element_query_convert return wrong value
hi, i am trying use gst_element_query_convert() to convert GST_FORMAT_TIME value to GST_FORMAT_BYTES, but i cant not get right value.
firstly, make a pipeline:
mediaInfoPipeline = gst_pipeline_new("mediaInfoPipeline");
mediaInfoDecodebin = gst_element_factory_make("uridecodebin", NULL);
g_assert(mediaInfoDecodebin);
gst_bin_add(GST_BIN(mediaInfoPipeline), mediaInfoDecodebin);
g_signal_connect(mediaInfoDecodebin,
"pad-added",
G_CALLBACK(on_new_pad),
mediaInfoPipeline);
static void
on_new_pad(GstElement *decodebin, GstPad *srcpad, GstElement *pipeline)
{
Q_UNUSED(decodebin);
GstElement *sink = gst_element_factory_make("fakesink", NULL);
g_assert(sink);
gst_bin_add(GST_BIN(pipeline), sink);
GstPad *sinkpad = gst_element_get_static_pad(sink, "sink");
if (!gst_pad_is_linked(sinkpad))
{
if (gst_pad_link(srcpad, sinkpad) != GST_PAD_LINK_OK)
g_error("Failed to link pads!");
}
// TODO: unref all no need pad
gst_object_unref(sinkpad);
}
then,
g_object_set(mediaInfoDecodebin, "uri", "file:///filetomedia.mp4", NULL);
gst_element_set_state(mediaInfoPipeline, GST_STATE_PAUSED);
after ASYNC_DONE,
if (gst_element_query_convert(mediaInfoPipeline,
GST_FORMAT_TIME,
time,
GST_FORMAT_BYTES,
&bytes))
{
return bytes;
}
else
{
return -1;
}
but i got wrong bytes value, the value even bigger than the whole file bytes. i have try to seek to position in bytes, also wrong position.