[vlc-commits] Added MediaStats, updated __doc__ and some typos.
mrJean1
git at videolan.org
Sat Oct 6 22:54:58 CEST 2018
vlc/python | branch: master | mrJean1 <22154337+mrJean1 at users.noreply.github.com> | Sat Jul 28 12:22:17 2018 -0400| [c8070d5eeee4df7eefa7006d89f7bf8cd41116b9] | committer: GitHub
Added MediaStats, updated __doc__ and some typos.
The `Python, VLC & Media Information` table now includes the `MediaStats` attributes, labeled like the Window -> Media Information -> Statistics pane in the VLC App on macOS.
> http://git.videolan.org/gitweb.cgi/vlc/python.git/?a=commit;h=c8070d5eeee4df7eefa7006d89f7bf8cd41116b9
---
examples/cocoavlc.py | 62 ++++++++++++++++++++++++++++++++++------------------
1 file changed, 41 insertions(+), 21 deletions(-)
diff --git a/examples/cocoavlc.py b/examples/cocoavlc.py
index 3beb6d3..cf53a63 100755
--- a/examples/cocoavlc.py
+++ b/examples/cocoavlc.py
@@ -1,20 +1,19 @@
# -*- coding: utf-8 -*-
-# Original <http://Code.Google.com/archive/p/cocoa-python>
-
# Example of using PyCocoa <http://PyPI.org/project/PyCocoa> to create
# a window, table and an application menu to run a video using VLC on
# macOS. The Python-VLC binding <http://PyPI.Python.org/pypi/python-vlc>
-# and the corresponding VLC App,see <http://www.VideoLan.org/index.html>.
+# and the corresponding VLC App, see <http://www.VideoLan.org/index.html>.
-# This VLC player has only been tested with VLC 2.2.6, 3.0.1, 3.0.2 and
-# 3.0.3 and the corresponding vlc.py Python-VLC binding using 64-bit
-# Python 2.7.14 and 3.6.4 on macOS 10.13.4 High Sierra. The player does
-# not work using PyPy Python <http://PyPy.org> nor with Intel(R)
-# Python <http://Software.Intel.com/en-us/distribution-for-python>.
+# This VLC player has only been tested with VLC 2.2.6, 2.2.8, 3.0.1,
+# 3.0.2 and 3.0.3 and the compatible vlc.py Python-VLC binding using
+# 64-bit Python 2.7.14, 2.7.15, 3.6.4, 3.6.5 and/or 3.7.0 on macOS
+# 10.13.4, 10.13.5 and 10.13.6 High Sierra. This player does not work
+# using PyPy Python <http://PyPy.org> nor with Intel(R) Python
+# <http://Software.Intel.com/en-us/distribution-for-python>.
-# MIT License <http://opensource.org/licenses/MIT>
+# MIT License <http://OpenSource.org/licenses/MIT>
#
# Copyright (C) 2017-2018 -- mrJean1 at Gmail dot com
#
@@ -44,7 +43,7 @@ def _PyPI(package):
try:
import vlc
except ImportError:
- raise ImportError('no %s module, see %s?' % ('vlc.py', _PyPI('python-vlc')))
+ raise ImportError('no %s module, see %s?' % ('vlc.py', _PyPI('Python-VLC')))
try:
import pycocoa # PYCHOK expected
except ImportError:
@@ -60,7 +59,7 @@ import sys
from time import strftime, strptime
__all__ = ('AppVLC',)
-__version__ = '18.06.09'
+__version__ = '18.07.27'
if __PyCocoa__ < '18.06.02':
raise ImportError('%s %s or newer required, see %s' % ('pycocoa',
@@ -109,6 +108,7 @@ class AppVLC(App):
self.adjustr = adjustr
self.logostr = logostr
self.marquee = marquee
+ self.media = None
self.panel = OpenPanel(_Select)
self.player = vlc.MediaPlayer()
self.video = video
@@ -120,7 +120,7 @@ class AppVLC(App):
if self.player:
# the VLC player on macOS needs an NSView
self.player.set_nsobject(self.window.NSview)
- self.player.set_mrl(self.video)
+ self.media = self.player.set_mrl(self.video)
if self.adjustr: # preset video options
for o in self.adjustr.lower().split(','):
@@ -187,7 +187,7 @@ class AppVLC(App):
p = self.player
m = p.get_media()
- t = Table(' Name:bold', ' Value:200:Center:center', ' Alt:300')
+ t = Table(' Name:bold', ' Value:200:Center:center', ' Alt:100')
t.append('cocoavlc', __version__, '20' + __version__)
t.append('PyCocoa', __PyCocoa__, '20' + __PyCocoa__)
t.append('Python', *_Python)
@@ -227,21 +227,41 @@ class AppVLC(App):
t.append('scale', '%.3f' % (p.video_get_scale(),), '%.3f' % (self.scale,))
t.separator()
- def _VLCadjustr2(option):
+ 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.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)
+ 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))
+ t.append('media demuxed', *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:
printf('%r', x, nl=1, nt=1)
@@ -330,7 +350,7 @@ class AppVLC(App):
# adjust a video option like brightness, contrast, etc.
p = self.player
# <http://Wiki.VideoLan.org/Documentation:Modules/adjust>
- # note, .Enable must be set to 1, but once will suffices
+ # note, .Enable must be set to 1, but once is sufficient
p.video_set_adjust_int(_Adjust.Enable, 1)
try:
lo, _, hi = _Adjust3[option]
More information about the vlc-commits
mailing list