def filter_settings() -> Munch: return Munch( blackdetect=Munch( min_duration=0.1, default_duration=2.0 ) )
def smartinit(self, clips: int): self.smartcut_jobs = [] # noinspection PyUnusedLocal [ self.smartcut_jobs.append(Munch(output='', bitrate=0, allstreams=True, procs={}, files={}, results={})) for index in range(clips) ]
def probe(self, source: str) -> Munch: try: args = '-v error -show_streams -show_format -of json "{}"'.format(source) json_data = self.cmdExec(self.backends.ffprobe, args, output=True, mergechannels=False) return Munch.fromDict(loads(json_data)) except FileNotFoundError: self.logger.exception('FFprobe could not find media file: {}'.format(source), exc_info=True) raise except JSONDecodeError: self.logger.exception('FFprobe JSON decoding error', exc_info=True) raise
def findBackends(settings: QSettings) -> Munch: tools = Munch(ffmpeg=None, ffprobe=None, mediainfo=None) settings.beginGroup('tools') tools.ffmpeg = settings.value('ffmpeg', None, type=str) tools.ffprobe = settings.value('ffprobe', None, type=str) tools.mediainfo = settings.value('mediainfo', None, type=str) for tool in list(tools.keys()): path = tools[tool] if path is None or not len(path) or not os.path.isfile(path): for exe in VideoService.config.binaries[os.name][tool]: if VideoService.frozen: binpath = VideoService.getAppPath( os.path.join('bin', exe)) else: binpath = QStandardPaths.findExecutable(exe) if not len(binpath): binpath = QStandardPaths.findExecutable( exe, [VideoService.getAppPath('bin')]) if os.path.isfile(binpath) and os.access(binpath, os.X_OK): tools[tool] = binpath if not VideoService.frozen: settings.setValue(tool, binpath) break settings.endGroup() if tools.ffmpeg is None: raise ToolNotFoundException('FFmpeg missing') if tools.ffprobe is None: raise ToolNotFoundException('FFprobe missing') if tools.mediainfo is None: raise ToolNotFoundException('MediaInfo missing') return tools
def __init__(self, settings: QSettings, parent: QWidget): super(VideoService, self).__init__(parent) self.settings = settings self.parent = parent self.logger = logging.getLogger(__name__) try: self.backends = VideoService.findBackends(self.settings) self.proc = VideoService.initProc() if hasattr(self.proc, 'errorOccurred'): self.proc.errorOccurred.connect(self.cmdError) self.lastError = '' self.media, self.source = None, None self.chapter_metadata = None self.keyframes = [] self.streams = Munch() self.mappings = [] except ToolNotFoundException as e: self.logger.exception(e.msg, exc_info=True) QMessageBox.critical(getattr(self, 'parent', None), 'Missing libraries', e.msg)