diff options
| author | tassaron | 2017-06-24 23:12:41 -0400 |
|---|---|---|
| committer | tassaron | 2017-06-24 23:12:41 -0400 |
| commit | e32ba958cb95146728d4985221b08c7e01b35470 (patch) | |
| tree | 1fce99082617a5a92a758851e51c32999774d212 /src/components/video.py | |
| parent | 4d955c5a06d8d77c968f594a85b71b516919bcfb (diff) | |
fixing bugs
Diffstat (limited to 'src/components/video.py')
| -rw-r--r-- | src/components/video.py | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/src/components/video.py b/src/components/video.py index 70247e1..3e87d2e 100644 --- a/src/components/video.py +++ b/src/components/video.py @@ -1,6 +1,7 @@ from PIL import Image, ImageDraw -from PyQt5 import uic, QtGui, QtCore, QtWidgets +from PyQt5 import QtGui, QtCore, QtWidgets import os +import math import subprocess import threading from queue import PriorityQueue @@ -79,9 +80,18 @@ class Video: self.frameNo += 1 # If we run out of frames, use the last good frame and loop. - if len(self.currentFrame) == 0: - self.frameBuffer.put((self.frameNo-1, self.lastFrame)) - continue + try: + if len(self.currentFrame) == 0: + self.frameBuffer.put((self.frameNo-1, self.lastFrame)) + continue + except AttributeError as e: + self.parent.showMessage( + msg='%s couldn\'t be loaded.' % os.path.basename( + self.videoPath + ), + detail=str(e) + ) + self.parent.stopVideo() self.currentFrame = pipe.stdout.read(self.chunkSize) if len(self.currentFrame) != 0: @@ -97,10 +107,7 @@ class Component(__base__.Component): def widget(self, parent): self.parent = parent self.settings = parent.settings - page = uic.loadUi(os.path.join( - os.path.dirname(os.path.realpath(__file__)), - 'video.ui' - )) + page = self.loadUi('video.ui') self.videoPath = '' self.x = 0 self.y = 0 @@ -243,9 +250,9 @@ def scale(scale, width, height, returntype=None): width = (float(width) / 100.0) * float(scale) height = (float(height) / 100.0) * float(scale) if returntype == str: - return (str(int(width)), str(int(height))) + return (str(math.ceil(width)), str(math.ceil(height))) elif returntype == int: - return (int(width), int(height)) + return (math.ceil(width), math.ceil(height)) else: return (width, height) |
