Problem in getting the duration

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Problem in getting the duration

AnithaT.R.
Hello,

         I am newbie in gstreamer. I have problem in getting the track length of the file.
I have implemented a timeout function where I am querying the duration of the file using gst_element_query_duration.

Here is my callback function...


static gboolean
cb_print_position (GstElement *pipeline)
{
GstElement *pipeline = (GstElement *) data;
    GstFormat fmt = GST_FORMAT_TIME;
    gboolean test;
    gint64 len;
    guint64 len_seconds;
    gint32 pos = 0;
test = gst_element_query_duration(
        pipeline, &fmt, &len
    );

    if (test)
    {

    len_seconds = len / GST_SECOND;
    printf("total time: %lld (%llds)\n", len, len_seconds);
   
    int hour, mins;
     hour = len_seconds / 3600;
  len_seconds -= (hour * 3600);
  mins = len_seconds / 60;
  len_seconds -= (mins * 60);
    std::cout << "Length is " << mins << ":" << len_seconds;
    pos = g_random_int_range(0, len_seconds);
    printf("random: %d\n", pos);
    }
return TRUE;
}

gst_element_set_state(playerpipeline, GST_STATE_PLAYING);
g_timeout_add(5 * 1000, (GSourceFunc)cb_print_position, playerpipeline);
g_main_loop_run(playerloop);


The problem is that I am not able to get the length of the file. can anyone help me in getting the track length of the file?

Thanks,
Krupa


Sooner or later, those who win are those who think they can.

~ Richard Bach ~



Bollywood news, movie reviews, film trailers and more! Click here.
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel