def check_available_features(repo): try: print "Detecting environment..." global acodecs global vcodecs global formats global services global transitions global environment_detection_success acodecs = [] vcodecs = [] formats = [] services = {} transitions = {} # video codecs cv = mlt.Consumer(mlt.Profile(), "avformat") cv.set('vcodec', 'list') cv.start() codecs = mlt.Properties(cv.get_data('vcodec')) for i in range(0, codecs.count()): vcodecs.append(codecs.get(i)) # audio codecs ca = mlt.Consumer(mlt.Profile(), "avformat") ca.set('acodec', 'list') ca.start() codecs = mlt.Properties(ca.get_data('acodec')) for i in range(0, codecs.count()): acodecs.append(codecs.get(i)) # formats cf = mlt.Consumer(mlt.Profile(), "avformat") cf.set('f', 'list') cf.start() codecs = mlt.Properties(cf.get_data('f')) for i in range(0, codecs.count()): formats.append(codecs.get(i)) # filters envservices = mlt.Repository.filters(repo) for i in range(mlt.Properties.count(envservices)): services[mlt.Properties.get_name(envservices, i)] = True # transitions envtransitions = mlt.Repository.transitions(repo) for i in range(mlt.Properties.count(envtransitions)): transitions[mlt.Properties.get_name(envtransitions, i)] = True print "MLT detection succeeded, " + str(len(formats)) + " formats, " \ + str(len(vcodecs)) + " video codecs and " + str(len(acodecs)) + " audio codecs found." print str(len(services)) + " MLT services found." environment_detection_success = True except: print "Environment detection failed, environment unknown." GObject.timeout_add(2000, _show_failed_environment_info)
def get_formats(self, format=None): try: formats_raw = [] # Create the consumer c = mlt.Consumer(mlt.Profile(), "avformat") # Ask for video codecs supports c.set('f', 'list') # Start the consumer to generate the list c.start() # Get the vcodec property codecs = mlt.Properties(c.get_data('f')) # Display the list of codecs for i in range(0, codecs.count()): formats_raw.append(codecs.get(i)) # sort list formats_raw.sort() return formats_raw except: # If the above code fails, use an older technique which uses the 'melt' # command line, and parses the output print "Warning: Could not get list of formats using the MLT API. Falling back to 'melt' executable." return self.get_formats_fallback(format)
#!/usr/bin/env python # -*- coding: utf-8 -*- # Import required modules from __future__ import print_function import mlt # Start the mlt system mlt.Factory().init() # Create the consumer c = mlt.Consumer(mlt.Profile(), "avformat") # Ask for video codecs supports c.set('vcodec', 'list') # Start the consumer to generate the list c.start() # Get the vcodec property codecs = mlt.Properties(c.get_data('vcodec')) # Print the list of codecs for i in range(0, codecs.count()): print(codecs.get(i))
#!/usr/bin/env python # -*- coding: utf-8 -*- import mlt p = mlt.Properties() p.anim_set("foo", "bar", 10) a = p.get_anim("bar") print "bar is valid:", a.is_valid() a = p.get_anim("foo") print "foo is valid:", a.is_valid() print "serialize:", a.serialize_cut()