gst_discoverer_info_get_duration() sometimes returns "0" without an error
Hello!
I amusing the following code in order to get the duration of an AMR-NB file on Pinephone, Mobian/Bullseye, GStreamer version 1.18.4-2, Pulseaudio:
discoverer = gst_discoverer_new (GST_SECOND, &error);
if (!discoverer) {
g_print ("Error creating discoverer instance: %s\n", error->message);
error = NULL;
return NULL;
}
info = gst_discoverer_discover_uri(discoverer, attachment_uri, &error);
if (error != NULL) {
g_warning ("Error discovering file: %s", error->message);
self->duration_formatted = g_strdup ("??:??");
} else {
self->duration = gst_discoverer_info_get_duration (info);
self->minutes = (self->duration / (GST_SECOND * 60)) % 60;
self->seconds = GST_TIME_AS_SECONDS (self->duration) - self->minutes * 60;
self->duration_formatted = g_strdup_printf ("%02lu:%02lu", self->minutes, self->seconds);
}
Every so often, info
returns a duration of 0
and does not give me an error.
This code is intergrated here: https://gitlab.com/kop316/vvmplayer/-/blob/main/src/vvmplayer-voicemail-window.c#L302