def PrepareRendering(self): for audioFile in self.__project.GetAudioFiles(): if not CheckFile(audioFile): dlg = wx.MessageDialog( self, _(u"Audio file '%s' does not exist! Continue anyway?") % audioFile, _(u"Warning"), wx.YES_NO | wx.ICON_WARNING) dlgResult = dlg.ShowModal() dlg.Destroy() if dlgResult == wx.ID_NO: return else: break
def Execute(self): audioFiles = [] audioLength = 0 for audioFile in self.__photoFilmStrip.GetAudioFiles(): if CheckFile(audioFile): length = GPlayer(audioFile).GetLength() audioFiles.append(audioFile) logging.debug("Using audiofile '%s' with length: %s", audioFile, length) audioLength += length else: logging.warning("Missing audiofile '%s'!", audioFile) outFile = self._CheckAndGetOutFile() self._SaveSettings() savedProps = Settings().GetRenderProperties(self.__rendererClass.__name__) for prop in self.__rendererClass.GetProperties(): value = savedProps.get(prop.lower(), self.__rendererClass.GetProperty(prop)) self.__rendererClass.SetProperty(prop, value) totalLength = self.__photoFilmStrip.GetDuration(False) if totalLength == -1: totalLength = int(round((audioLength + 500) / 1000.0)) renderer = self.__rendererClass() renderer.Init(self.__profile, self.__photoFilmStrip.GetAspect(), outFile) renderer.SetAudioFiles(audioFiles) if self.__photoFilmStrip.GetTimelapse(): uxEvent = "RenderTimeLapse" renderEngine = RenderEngineTimelapse(self.__profile, self.__photoFilmStrip.GetPictures(), self.__draftMode) else: uxEvent = "RenderSlideshow" renderEngine = RenderEngineSlideshow(self.__profile, self.__photoFilmStrip.GetPictures(), self.__draftMode, totalLength) name = "%s (%s)" % (self.__photoFilmStrip.GetName(), self.__profile.GetName()) self.__renderJob = RenderJob(name, renderer, renderEngine.GetTasks()) self.__renderJob.AddUxEvent(uxEvent) self.__renderJob.AddUxEvent(self.__profile.GetName())
def IsOk(self): return CheckFile(self._filename) and self._type is not None
def main(showHelp=False): parser = OptionParser(prog="%s-cli" % Constants.APP_NAME.lower(), version="%%prog %s" % Constants.APP_VERSION_SUFFIX) profiles = GetOutputProfiles() + GetMPEGProfiles() profStr = ", ".join( ["%d=%s" % (idx, prof.GetName()) for idx, prof in enumerate(profiles)]) formatStr = ", ".join( ["%d=%s" % (idx, rdr.GetName()) for idx, rdr in enumerate(RENDERERS)]) parser.add_option("-p", "--project", help=_("specifies the project file")) parser.add_option( "-o", "--outputpath", help=_("The path where to save the output files. Use - for stdout."), metavar="PATH") parser.add_option("-t", "--profile", help=profStr + " [default: %default]", default=0, type="int") parser.add_option( "-n", "--videonorm", help=_("Option videonorm is deprecated, use an appropriate profile!")) parser.add_option("-f", "--format", help=formatStr + " [default: %default]", default=4, type="int") parser.add_option( "-a", "--draft", action="store_true", default=False, help="%s - %s" % (_("enable draft mode"), _("Activate this option to generate a preview of your PhotoFilmStrip. The rendering process will speed up dramatically, but results in lower quality." ))) parser.add_option("-d", "--debug", action="store_true", default=False, help="enable debug logging") if showHelp: parser.print_help() return 0 options = parser.parse_args()[0] if options.project: options.project = os.path.abspath(options.project) if not os.path.isfile(options.project): logging.error(_("project file does not exist: %s"), options.project) return 1 else: parser.print_help() logging.error(_("no project file specified!")) return 2 if options.videonorm: parser.print_help() logging.error( _("Option videonorm is deprecated, use an appropriate profile!")) return 4 if options.format not in range(len(RENDERERS)): parser.print_help() logging.error(_("invalid format specified: %s"), options.format) return 5 rendererClass = RENDERERS[options.format] if options.profile >= len(profiles): parser.print_help() logging.error(_("invalid profile specified: %s"), options.profile) return 3 profile = profiles[options.profile] prjFile = ProjectFile(filename=options.project) if not prjFile.Load(): logging.error(_("cannot load project")) return 6 if options.outputpath: if options.outputpath == "-": outpath = "-" rendererClass = StreamRenderer else: outpath = os.path.abspath(options.outputpath) if not os.path.exists(outpath): try: os.makedirs(outpath) except Exception as err: logging.error(_("cannot create output path: %s"), err) return 7 else: outpath = None project = prjFile.GetProject() ar = ActionRender(project, profile, rendererClass, False, outpath) audioFile = project.GetAudioFile() if not CheckFile(audioFile): logging.error(_("Audio file '%s' does not exist!"), audioFile) return 8 if rendererClass is StreamRenderer: cliGui = DummyGui() else: cliGui = CliGui() cliGui.Info(options.project, rendererClass, profile) ar.Execute() renderJob = ar.GetRenderJob() renderJob.AddVisualJobHandler(cliGui) JobManager().EnqueueContext(renderJob) try: while not renderJob.IsDone(): time.sleep(0.1) except KeyboardInterrupt: renderJob.Abort() cliGui.Write("\n" + _("...aborted!")) return 10 resultObj = renderJob.GetResultObject() result = resultObj.GetResult() if result: cliGui.Write(_("all done"))
else: outpath = os.path.abspath(options.outputpath) if not os.path.exists(outpath): try: os.makedirs(outpath) except StandardError, err: logging.error(_(u"cannot create output path: %s"), err) return 7 else: outpath = None project = prjFile.GetProject() ar = ActionRender(project, profile, rendererClass, False, outpath) audioFile = project.GetAudioFile() if not CheckFile(audioFile): logging.error(_(u"Audio file '%s' does not exist!"), audioFile) return 8 if rendererClass is StreamRenderer: cliGui = DummyGui() else: cliGui = CliGui() cliGui.Info(options.project, rendererClass, profile) ar.Execute() renderJob = ar.GetRenderJob() renderJob.AddVisualJobHandler(cliGui) JobManager().EnqueueContext(renderJob)