def do(self, args): from morituri.common import encode profile = encode.ALL_PROFILES[self.options.profile]() try: fromPath = unicode(args[0]) except IndexError: self.stdout.write('Please specify an input file.\n') return 3 try: toPath = unicode(args[1]) except IndexError: toPath = fromPath + '.' + profile.extension runner = task.SyncRunner() self.debug('Encoding %s to %s', fromPath.encode('utf-8'), toPath.encode('utf-8')) encodetask = encode.EncodeTask(fromPath, toPath, profile) runner.run(encodetask) self.stdout.write('Peak level: %r\n' % encodetask.peak) self.stdout.write('Encoded to %s\n' % toPath.encode('utf-8'))
def _testSuffix(self, suffix): # because of https://bugzilla.gnome.org/show_bug.cgi?id=688625 # we first create the file with a 'normal' filename, then rename self.runner = task.SyncRunner(verbose=False) fd, path = tempfile.mkstemp() cmd = "gst-launch " \ "audiotestsrc num-buffers=100 samplesperbuffer=1024 ! " \ "audioconvert ! audio/x-raw-int,width=16,depth=16,channels =2 ! " \ "wavenc ! " \ "filesink location=\"%s\" > /dev/null 2>&1" % ( gstreamer.quoteParse(path).encode('utf-8'), ) self.debug('Running cmd %r' % cmd) os.system(cmd) self.failUnless(os.path.exists(path)) os.close(fd) fd, newpath = tempfile.mkstemp(suffix=suffix) os.rename(path, newpath) encodetask = encode.EncodeTask(newpath, newpath + '.out', encode.WavProfile()) self.runner.run(encodetask, verbose=False) os.close(fd) os.unlink(newpath) os.unlink(newpath + '.out')
def main(argv): parser = optparse.OptionParser() default = 'cli' parser.add_option('-r', '--runner', action="store", dest="runner", help="runner ('cli' or 'gtk', defaults to %s)" % default, default=default) options, args = parser.parse_args(argv[1:]) taglist = gst.TagList() taglist[gst.TAG_ARTIST] = 'Thomas' taglist[gst.TAG_TITLE] = 'Yes' taskk = encode.EncodeTask(args[0], args[1], taglist=taglist) if options.runner == 'cli': runner = task.SyncRunner() function = climain elif options.runner == 'gtk': runner = taskgtk.GtkProgressRunner() function = gtkmain function(runner, taskk)
def add(index): # here to avoid import gst eating our options from morituri.common import encode path = image.getRealPath(index.path) assert type(path) is unicode, "%r is not unicode" % path self.debug('schedule encode of %r', path) root, ext = os.path.splitext(os.path.basename(path)) outpath = os.path.join(outdir, root + '.' + profile.extension) self.debug('schedule encode to %r', outpath) taskk = encode.EncodeTask( path, os.path.join(outdir, root + '.' + profile.extension), profile) self.addTask(taskk)