[gst-devel] Problem in getting the duration
T.R. Anitha
tranitha83 at yahoo.co.in
Wed Oct 22 17:47:12 CEST 2008
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 ~
Add more friends to your messenger and enjoy! Go to http://messenger.yahoo.com/invite/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20081022/90ee3809/attachment.htm>
More information about the gstreamer-devel
mailing list