def print_version(): """Print version of vlc.py and of libvlc""" try: print('%s: %s (%s)' % (basename(vlc.__file__), vlc.__version__, vlc.build_date)) print('LibVLC version: %s (%#x)' % (vlc.bytes_to_str( vlc.libvlc_get_version()), vlc.libvlc_hex_version())) print('LibVLC compiler: %s' % vlc.bytes_to_str(vlc.libvlc_get_compiler())) if vlc.plugin_path: print('Plugin path: %s' % vlc.plugin_path) except Exception: print('Error: %s' % sys.exc_info()[1])
def menuInfo_(self, item): try: self.menuPause_(item) # display Python, vlc, libVLC, media info p = self.player m = p.get_media() t = Table(' Name', ' Value:200', ' Alt:300') t.append('PyCocoa', __PyCocoa__, '20' + __version__) t.append('Python', *_Python) t.append('macOS', *_macOS) t.separator() t.append('vlc.py', vlc.__version__, hex(vlc.hex_version())) b = ' '.join(vlc.build_date.split()[:5]) t.append('built', strftime('%x', strptime(b, '%c')), vlc.build_date) t.separator() t.append('libVLC', bytes2str(vlc.libvlc_get_version()), hex(vlc.libvlc_hex_version())) t.append('libVLC', *bytes2str(vlc.libvlc_get_compiler()).split(None, 1)) t.separator() f = bytes2str(m.get_mrl()) t.append('media', os.path.basename(f), f) if f.startswith('file:///'): z = os.path.getsize(f[7:]) t.append('size', z1000str(z), zSIstr(z)) t.append('state', str(p.get_state())) t.append('track/count', z1000str(p.video_get_track()), z1000str(p.video_get_track_count())) t.append('time/duration', z1000str(p.get_time()), z1000str(m.get_duration())) f = max(p.get_position(), 0) t.append('position', '%.2f%%' % (f * 100,), f) t.separator() f = p.get_fps() t.append('fps/mspf', '%.6f' % (f,), '%.3f ms' % (_mspf(f),)) r = p.get_rate() t.append('rate', '%s%%' % (int(r * 100),), r) w, h = p.video_get_size(0) r = aspect_ratio(w, h) or '' if r: r = '%s:%s' % r t.append('video size', '%sx%s' % (w, h)) # num=0 t.append('aspect ratio', str(p.video_get_aspect_ratio()), r) t.append('scale', '%.3f' % (p.video_get_scale(),), '%.3f' % (self.scale,)) t.display('Python, VLC & Media Information', width=600) except Exception as x: printf('%r', x, nl=1, nt=1)
def info_(self, notification): try: self.pause_(notification) p = self.player m = p.get_media() # print Python, vlc, libVLC, media info _printf('PyCocoa %s (%s)', __PyCocoa__, __version__, nl=1) _printf('python %s', ' '.join(_Python)) _printf('macOS %s', ' '.join(_macOS)) _printf('vlc.py %s (%#x)', vlc.__version__, vlc.hex_version()) _printf('built: %s', vlc.build_date) _printf('libVLC %s (%#x)', _b2str(vlc.libvlc_get_version()), vlc.libvlc_hex_version()) _printf('libVLC %s', _b2str(vlc.libvlc_get_compiler()), nt=1) _printf('media: %s', _b2str(m.get_mrl())) _printf('state: %s', p.get_state()) _printf('track/count: %s/%s', p.video_get_track(), p.video_get_track_count()) _printf('time/duration: %s/%s ms', p.get_time(), m.get_duration()) _printf('position/length: %.2f%%/%s ms', p.get_position() * 100.0, p.get_length()) f = p.get_fps() _printf('fps: %.3f (%.3f ms)', f, _mspf(f)) _printf('rate: %s', p.get_rate()) w, h = p.video_get_size(0) r = gcd(w, h) or '' if r and w and h: r = ' (%s:%s)' % (w // r, h // r) _printf('video size: %sx%s%s', w, h, r) # num=0 _printf('aspect ratio: %s', p.video_get_aspect_ratio()) _printf('scale: %.3f (%.3f)', p.video_get_scale(), self.scale) _printf('window: %r', p.get_hwnd(), nt=1) except Exception as x: _printf('%r', x, nl=1, nt=1)
def menuInfo_(self, item): try: self.menuPause_(item) # display Python, vlc, libVLC, media info table p = self.player m = p.get_media() t = Table(' Name:bold', ' Value:200:Center:center', ' Alt:100') t.append(_Argv0, __version__, '20' + __version__) t.append('PyCocoa', _pycocoa_version, '20' + _pycocoa_version) t.append('Python', *_Python) t.append(*_macOS()) x = 'built-in' if self.window.screen.isBuiltIn else 'external' t.append('screen', x, str(self.window.screen.displayID)) t.separator() t.append('vlc.py', vlc.__version__, hex(vlc.hex_version())) b = ' '.join(vlc.build_date.split()[:5]) t.append('built', strftime('%x', strptime(b, '%c')), vlc.build_date) t.separator() t.append('libVLC', bytes2str(vlc.libvlc_get_version()), hex(vlc.libvlc_hex_version())) t.append('libVLC', *bytes2str(vlc.libvlc_get_compiler()).split(None, 1)) t.separator() f = mrl_unquote(bytes2str(m.get_mrl())) t.append('media', basename(f), f) if f.lower().startswith('file://'): z = getsize(f[7:]) t.append('size', z1000str(z), zSIstr(z)) t.append('state', str(p.get_state())) f = max(p.get_position(), 0) t.append('position/length', '%.2f%%' % (f * 100, ), _ms2str(p.get_length())) f = map(_ms2str, (p.get_time(), m.get_duration())) t.append('time/duration', *f) t.append('track/count', z1000str(p.video_get_track()), z1000str(p.video_get_track_count())) t.separator() f = p.get_fps() t.append('fps/mspf', '%.6f' % (f, ), '%.3f ms' % (_mspf(f), )) r = p.get_rate() t.append('rate', '%s%%' % (int(r * 100), ), r) w, h = p.video_get_size(0) t.append('video size', _ratio2str('x', w, h)) # num=0 r = _ratio2str(':', *aspect_ratio(w, h)) # p.video_get_aspect_ratio() t.append('aspect ratio', r, _ratio2str(':', *self.window.ratio)) t.append('scale', '%.3f' % (p.video_get_scale(), ), '%.3f' % (self.scale, )) t.separator() def VLCadjustr2(option): # get option value lo, _, hi = _Adjust3[option] f = self.player.video_get_adjust_float(option) p = max(0, (f - lo)) * 100.0 / (hi - lo) t = '%.2f %.1f%%' % (f, p) # return 2-tuple (value, percentage) as strings return t.replace('.0%', '%').replace('.00', '.0').split() t.append('brightness', *VLCadjustr2(_Adjust.Brightness)) t.append('contrast', *VLCadjustr2(_Adjust.Contrast)) t.append('gamma', *VLCadjustr2(_Adjust.Gamma)) t.append('hue', *VLCadjustr2(_Adjust.Hue)) t.append('saturation', *VLCadjustr2(_Adjust.Saturation)) t.separator() s = vlc.MediaStats() # re-use single MediaStats instance? if m.get_stats(s): def Kops2bpstr2(bitrate): # convert Ko/s to bits/sec # bitrates are conventionally in kilo-octets-per-sec return zSIstr(bitrate * 8000, B='bps', K=1000).split() t.append('media read', *zSIstr(s.read_bytes).split()) t.append('input bitrate', *Kops2bpstr2(s.input_bitrate)) if s.input_bitrate > 0: # XXX approximate caching, based # on <https://GitHub.com/oaubert/python-vlc/issues/61> b = s.read_bytes - s.demux_read_bytes t.append('input caching', _ms2str(b / s.input_bitrate), zSIstr(b)) t.append('demux read', *zSIstr(s.demux_read_bytes).split()) t.append('stream bitrate', *Kops2bpstr2(s.demux_bitrate)) t.append('video decoded', z1000str(s.decoded_video), 'blocks') t.append('video played', z1000str(s.displayed_pictures), 'frames') t.append('video lost', z1000str(s.lost_pictures), 'frames') t.append('audio decoded', z1000str(s.decoded_audio), 'blocks') t.append('audio played', z1000str(s.played_abuffers), 'buffers') t.append('audio lost', z1000str(s.lost_abuffers), 'buffers') t.display('Python, VLC & Media Information', width=500) except Exception as x: if self.raiser: raise printf('%s', x, nl=1, nt=1)
def menuInfo_(self, item): try: self.menuPause_(item) # display Python, vlc, libVLC, media info p = self.player m = p.get_media() t = Table(' Name:bold', ' Value:200:Center:center', ' Alt:300') t.append('cocoavlc', __version__, '20' + __version__) t.append('PyCocoa', __PyCocoa__, '20' + __PyCocoa__) t.append('Python', *_Python) t.append('macOS', *_macOS) t.separator() t.append('vlc.py', vlc.__version__, hex(vlc.hex_version())) b = ' '.join(vlc.build_date.split()[:5]) t.append('built', strftime('%x', strptime(b, '%c')), vlc.build_date) t.separator() t.append('libVLC', bytes2str(vlc.libvlc_get_version()), hex(vlc.libvlc_hex_version())) t.append('libVLC', *bytes2str(vlc.libvlc_get_compiler()).split(None, 1)) t.separator() f = bytes2str(m.get_mrl()) t.append('media', os.path.basename(f), f) if f.startswith('file:///'): z = os.path.getsize(f[7:]) t.append('size', z1000str(z), zSIstr(z)) t.append('state', str(p.get_state())) t.append('track/count', z1000str(p.video_get_track()), z1000str(p.video_get_track_count())) t.append('time/duration', z1000str(p.get_time()), z1000str(m.get_duration())) f = max(p.get_position(), 0) t.append('position', '%.2f%%' % (f * 100,), f) t.separator() f = p.get_fps() t.append('fps/mspf', '%.6f' % (f,), '%.3f ms' % (_mspf(f),)) r = p.get_rate() t.append('rate', '%s%%' % (int(r * 100),), r) w, h = p.video_get_size(0) r = aspect_ratio(w, h) or '' if r: r = '%s:%s' % r t.append('video size', '%sx%s' % (w, h)) # num=0 t.append('aspect ratio', str(p.video_get_aspect_ratio()), r) t.append('scale', '%.3f' % (p.video_get_scale(),), '%.3f' % (self.scale,)) t.separator() def _VLCadjustr2(option): lo, _, hi = _Adjust3[option] f = self.player.video_get_adjust_float(option) p = max(0, (f - lo)) * 100.0 / (hi - lo) t = '%.2f %.1f%%' % (f, p) return t.replace('.0%', '%').replace('.00', '.0').split() t.append('brightness', *_VLCadjustr2(_Adjust.Brightness)) t.append('contrast', *_VLCadjustr2(_Adjust.Contrast)) t.append('gamma', *_VLCadjustr2(_Adjust.Gamma)) t.append('hue', *_VLCadjustr2(_Adjust.Hue)) t.append('saturation', *_VLCadjustr2(_Adjust.Saturation)) t.separator() t.display('Python, VLC & Media Information', width=600) except Exception as x: printf('%r', x, nl=1, nt=1)