import gobject gobject.threads_init() import pygst pygst.require('0.10') import gst import sys import os results = [] def peekfunction(data, offset, size): #print "peek %d bytes at %d" % (size, offset) try: data.seek(offset) res = data.read(size) except: res = None return res def suggestfunction(data, probability, caps): #print "suggest", probability, caps.to_string() results.append((probability, caps)) for infile in sys.argv[1:]: if not os.path.isfile(infile): continue results = [] t = gst.type_find_new(open(infile, 'r'), peekfunction, suggestfunction) for factory in gst.type_find_factory_get_list(): factory.call_function(t) print "\nRESULTS", infile bestprob = 0 bestcaps = None for prob, caps in results: print prob, "\t\t", caps if prob > bestprob: bestprob = prob bestcaps = caps print "Best Caps [%d] : %s" % (bestprob, bestcaps)