aboutsummaryrefslogtreecommitdiff
path: root/src/components/video.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/video.py')
-rw-r--r--src/components/video.py27
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)