relative gradients & last good frame used for preview errors

This commit is contained in:
tassaron 2017-08-03 00:44:46 -04:00
parent 62431a3cfe
commit 6611492b30
5 changed files with 29 additions and 23 deletions

View File

@ -65,6 +65,11 @@ class Component(Component):
'y': 'y', 'y': 'y',
'sizeWidth': 'x', 'sizeWidth': 'x',
'sizeHeight': 'y', 'sizeHeight': 'y',
'RG_start': 'x',
'LG_start': 'x',
'RG_end': 'x',
'LG_end': 'x',
'RG_centre': 'x',
}, },
) )

View File

@ -20,6 +20,7 @@ class Component(Component):
def widget(self, *args): def widget(self, *args):
self.previewFrame = None self.previewFrame = None
super().widget(*args) super().widget(*args)
self._image = BlankFrame(self.width, self.height)
self.chunkSize = 4 * self.width * self.height self.chunkSize = 4 * self.width * self.height
self.changedOptions = True self.changedOptions = True
@ -268,11 +269,15 @@ class Component(Component):
return changed return changed
def finalizeFrame(self, imageData): def finalizeFrame(self, imageData):
image = Image.frombytes( try:
'RGBA', image = Image.frombytes(
scale(self.scale, self.width, self.height, int), 'RGBA',
imageData scale(self.scale, self.width, self.height, int),
) imageData
)
self._image = image
except ValueError:
image = self._image
if self.scale != 100 \ if self.scale != 100 \
or self.x != 0 or self.y != 0: or self.x != 0 or self.y != 0:
frame = BlankFrame(self.width, self.height) frame = BlankFrame(self.width, self.height)

View File

@ -17,8 +17,6 @@ class Component(Component):
def widget(self, *args): def widget(self, *args):
super().widget(*args) super().widget(*args)
# height = int(self.settings.value('outputHeight'))
# width = int(self.settings.value('outputWidth'))
self.textColor = (255, 255, 255) self.textColor = (255, 255, 255)
self.title = 'Text' self.title = 'Text'
self.alignment = 1 self.alignment = 1

View File

@ -16,12 +16,12 @@ class Component(Component):
def widget(self, *args): def widget(self, *args):
self.videoPath = '' self.videoPath = ''
self.badVideo = False
self.badAudio = False self.badAudio = False
self.x = 0 self.x = 0
self.y = 0 self.y = 0
self.loopVideo = False self.loopVideo = False
super().widget(*args) super().widget(*args)
self._image = BlankFrame(self.width, self.height)
self.page.pushButton_video.clicked.connect(self.pickVideo) self.page.pushButton_video.clicked.connect(self.pickVideo)
self.trackWidgets( self.trackWidgets(
{ {
@ -70,8 +70,6 @@ class Component(Component):
if not self.videoPath: if not self.videoPath:
self.lockError("There is no video selected.") self.lockError("There is no video selected.")
elif self.badVideo:
self.lockError("Could not identify an audio stream in this video.")
elif not os.path.exists(self.videoPath): elif not os.path.exists(self.videoPath):
self.lockError("The video selected does not exist!") self.lockError("The video selected does not exist!")
elif os.path.realpath(self.videoPath) == os.path.realpath(outputFile): elif os.path.realpath(self.videoPath) == os.path.realpath(outputFile):
@ -199,14 +197,10 @@ class Component(Component):
'RGBA', 'RGBA',
scale(self.scale, self.width, self.height, int), scale(self.scale, self.width, self.height, int),
imageData) imageData)
self._image = image
except ValueError: except ValueError:
print( # use last good frame
'### BAD VIDEO SELECTED ###\n' image = self._image
'Video will not export with these settings'
)
self.badVideo = True
return BlankFrame(self.width, self.height)
if self.scale != 100 \ if self.scale != 100 \
or self.xPosition != 0 or self.yPosition != 0: or self.xPosition != 0 or self.yPosition != 0:
@ -214,5 +208,4 @@ class Component(Component):
frame.paste(image, box=(self.xPosition, self.yPosition)) frame.paste(image, box=(self.xPosition, self.yPosition))
else: else:
frame = image frame = image
self.badVideo = False
return frame return frame

View File

@ -19,6 +19,7 @@ class Component(Component):
def widget(self, *args): def widget(self, *args):
super().widget(*args) super().widget(*args)
self._image = BlankFrame(self.width, self.height)
self.page.lineEdit_color.setText('255,255,255') self.page.lineEdit_color.setText('255,255,255')
@ -178,11 +179,15 @@ class Component(Component):
self.chunkSize = 4 * width * height self.chunkSize = 4 * width * height
def finalizeFrame(self, imageData): def finalizeFrame(self, imageData):
image = Image.frombytes( try:
'RGBA', image = Image.frombytes(
scale(self.scale, self.width, self.height, int), 'RGBA',
imageData scale(self.scale, self.width, self.height, int),
) imageData
)
self._image = image
except ValueError:
image = self._image
if self.scale != 100 \ if self.scale != 100 \
or self.x != 0 or self.y != 0: or self.x != 0 or self.y != 0:
frame = BlankFrame(self.width, self.height) frame = BlankFrame(self.width, self.height)