def stream_data(self): mplayer = Commands().make_command('mplayer') mplayer.add_options('dvd://{}'.format(self.track['ix'])) mplayer.add_options('--dvd-device={}'.format(self.parent.node)) mplayer.add_options('--really-quiet', '--dumpstream') mplayer.add_options('--dumpfile=/dev/fd/1') return subp.Popen(mplayer.gen_command(), stdout=subp.PIPE, stderr=subp.DEVNULL)
def on_dvd_sel_changed(self, curr, prev): if not curr.isValid(): self.textTrackInfo.clear() return node = curr.internalPointer() self.textTrackInfo.clear() if node.typeinfo == 'Track': self.DVDTree.resizeColumnToContents(1) elif node.typeinfo == 'File': avprobe = Commands().make_command('avprobe') avprobe.add_options('-show_streams', '-of', 'json') avprobe_command = avprobe.gen_command() avprobe_command.append(node.path) try: streams_json = subp.check_output(avprobe_command, stderr=subp.DEVNULL, universal_newlines=True) except subp.CalledProcessError: self.enable_tabs(False) return node.streams = json.loads(streams_json) else: self.enable_tabs(False) return self.source = self.make_source(node) alist = self.source.audio_streams if alist: self.textTrackInfo.append('<b>Audio:</b>') for a in alist: self.textTrackInfo.append( '{0}: Language: <i>{1}</i>, Format: <i>{2}</i>, Channels: <i>{3}</i>' .format(a.index, a.language, a.format, a.channels)) self.textTrackInfo.append('<p></p>') slist = self.source.subtitle_streams if slist: self.textTrackInfo.append('<b>Subtitles:</b>') for s in slist: self.textTrackInfo.append('{0}: Language: <i>{1}</i>'.format( s.index, s.language)) tuple(map(lambda obj: obj.deleteLater(), self.gen_codec_groups())) self.populate_subtitles() self.populate_audio() self.populate_video() self.enable_tabs(True)
def run(self): """ Start the lsdvd thread. Emits datasig on completion. """ lsdvd = Commands().make_command('lsdvd', '-x', '-Oy') lsdvd.add_options(self.device.device_node) try: contents = subp.check_output(lsdvd.gen_command(), stderr=subp.DEVNULL) except (subp.CalledProcessError): return # lsdvd data is returned as python code so execute it glbs = {} exec(str(contents, errors='ignore'), glbs) self.datasig.emit(glbs['lsdvd'])
def populate_formats(self): avconv = Commands().make_command('avconv', '-formats') formats = subp.check_output(avconv.gen_command(), stderr=subp.DEVNULL, universal_newlines=True) refmt = re.compile(r'^\W+[^.]D?E{1}\W+(?P<ext>\w+)\W+(?P<desc>\w.*$)') with StringIO(formats) as formats: for format in formats: match = refmt.search(format) if match: self.formats[match.group('desc')] = match.group('ext') widget = QWidget() layout = QVBoxLayout() flist = list(self.formats.keys()) flist.sort(key=str.lower) for fmt in flist: radio = QRadioButton(fmt) layout.addWidget(radio) widget.setLayout(layout) self.FscrollArea.setWidget(widget)
def run(self): recrop = re.compile( r'\(-vf crop=(?P<width>\d+):(?P<height>\d+):(?P<horiz>\d+):(?P<vert>\d+)\)' ) widfreq = Counter() hgtfreq = Counter() horfreq = Counter() verfreq = Counter() length = self.stream.length.total_seconds() sample_points = (p * length / self.samples for p in range(1, self.samples)) for point in sample_points: mplayer = Commands().make_command('mplayer') mplayer.add_options('--vo=null', '--ss={}'.format(point), '--frames=100', '--nosound', '--benchmark', '--vf=cropdetect=round,format=yv12') try: mplayer.add_options( 'dvd://{}'.format(self.stream.ix), '--dvd-device={}'.format(self.stream.device)) except: mplayer.outfile = self.stream.path mplayer_proc = subp.Popen(mplayer.gen_command(), stdout=subp.PIPE, stderr=subp.DEVNULL, universal_newlines=True) for mpop in mplayer_proc.stdout: match = recrop.search(mpop) if match: widfreq[match.group('width')] += 1 hgtfreq[match.group('height')] += 1 horfreq[match.group('horiz')] += 1 verfreq[match.group('vert')] += 1 try: self.datasig.emit( (widfreq.most_common(1)[0][0], hgtfreq.most_common(1)[0][0], horfreq.most_common(1)[0][0], verfreq.most_common(1)[0][0])) except: self.datasig.emit(['0'] * 4)