Python Discoverer crash
Jon Nordby
jononor at gmail.com
Thu Mar 3 14:03:32 PST 2011
On 3 March 2011 20:21, Matt Veenstra <matt at tribalmedia.com> wrote:
> class cMediaTool:
> # theFile is a local file. Is not tested with proper URI. expects
> format file:///
> # mv this expects a/v file. Fails if not.
> def OnDiscovered(self, discoverer, ismedia, infile):
> print '\non_discovered:', infile
> self.last_duration = 0
> # we always want the shortest direction to avoid a/v sync issues.
> if (discoverer.videolength >= discoverer.audiolength):
> self.last_duration = discoverer.audiolength / gst.MSECOND
> else:
> self.last_duration = discoverer.videolength / gst.MSECOND
> discoverer.print_info()
> self.mainloop.quit()
>
> # this creates its own mainloop to create synchronous call.
> # this might cause bad things ran inside another mainloop.
> def GetFileDuration(self, theFile):
> print("GetDuration")
>
> discoverer = Discoverer(theFile)
> discoverer.print_info()
> discoverer.connect('discovered', self.OnDiscovered, theFile)
>
> # The MainLoop
> self.mainloop = gobject.MainLoop()
> gobject.idle_add(discoverer.discover)
> self.mainloop.run()
> del self.mainloop
> # del discoverer
> return self.last_duration
I suggest you use GstDiscoverer blocking API if you want a blocking
call, find the python equivalent of
http://library.gnome.org/devel/gst-plugins-libs/unstable/gst-plugins-base-libs-gstdiscoverer.html#gst-discoverer-discover-uri
--
Jon Nordby - www.jonnor.com
More information about the gstreamer-devel
mailing list