how to get video duration

Nicolas Dufresne nicolas at ndufresne.ca
Fri Jun 21 15:02:22 UTC 2019


Le jeudi 20 juin 2019 à 10:50 -0500, kilamski a écrit :
> Hi,
> 
> I am using following example to get an* mpeg-TS video file duration:*
> https://gstreamer.freedesktop.org/documentation/tutorials/basic/media-information-gathering.html?gi-language=c
> However this code is 200 lines long. Is there a more elegant and short way
> to do it.
> Right click on Ubuntu will also give me video duration but I have no idea
> how to do this programatically.
> Thanks for any hints. 

If you are programming a cli, where blocking is fine, something like
this should do (untested):

g_autoptr(GError) error = NULL;
g_autoptr(GstDiscoverer) disc = NULL;
g_autoptr(GstDiscovererInfo) info = NULL;
GstClocktime duration;

dis = gst_discoverer_new (30 * GST_SECOND, &error);
g_assert_no_error (error);
info = gst_discoverer_discover_uri (dis, "http://myuri", &error);
g_assert_no_error (error);

duration = gst_discoverer_info_get_duration (info);

> 
> 
> 
> --
> Sent from: http://gstreamer-devel.966125.n4.nabble.com/
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: This is a digitally signed message part
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20190621/4d737d66/attachment.sig>


More information about the gstreamer-devel mailing list