Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • gstreamer gstreamer
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 938
    • Issues 938
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 440
    • Merge requests 440
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • GStreamerGStreamer
  • gstreamergstreamer
  • Issues
  • #558
Closed
Open
Issue created May 17, 2020 by ztluo@zt-luo

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.

Assignee
Assign to
Time tracking