diff options
| author | Brianna | 2017-05-29 20:47:51 -0400 |
|---|---|---|
| committer | GitHub | 2017-05-29 20:47:51 -0400 |
| commit | 7240f25deb21db365f39d00c50eb07d41dc4c797 (patch) | |
| tree | d765bd8753524dc2fd5109b1d9183c76ca49b15d | |
| parent | d1852619dfa22833cc5fd13af17afe031ee08ece (diff) | |
| parent | 369ac2a855c70b717c5b8a94ce5e97e1e4a0fc59 (diff) | |
added static components which don't get called each frame when rendering
| -rw-r--r-- | .gitignore | 4 | ||||
| -rw-r--r-- | components/text.py | 4 | ||||
| -rw-r--r-- | video_thread.py | 22 |
3 files changed, 24 insertions, 6 deletions
@@ -1,4 +1,6 @@ __pycache__ settings.ini build/* -.vscode/*
\ No newline at end of file +.vscode/* +*.mkv +*.mp4 diff --git a/components/text.py b/components/text.py index c7f37c1..c9359f2 100644 --- a/components/text.py +++ b/components/text.py @@ -81,6 +81,10 @@ class Component(__base__.Component): width = int(previewWorker.core.settings.value('outputWidth')) height = int(previewWorker.core.settings.value('outputHeight')) return self.addText(width, height) + + def preFrameRender(self, **kwargs): + super().preFrameRender(**kwargs) + return ['static'] def frameRender(self, moduleNo, frameNo): width = int(self.worker.core.settings.value('outputWidth')) diff --git a/video_thread.py b/video_thread.py index 8bef6ef..93ca7bd 100644 --- a/video_thread.py +++ b/video_thread.py @@ -77,10 +77,15 @@ class Worker(QtCore.QObject): # initialize components print('######################## Data') - print('loaded components: ', [str(component) for component in components]) + print('loaded components:', + ["%s%s" % (num, str(component)) for num, component in enumerate(components)]) + staticComponents = {} sampleSize = 1470 - for component in components: - component.preFrameRender(worker=self, completeAudioArray=completeAudioArray, sampleSize=sampleSize) + for compNo, comp in enumerate(components): + properties = None + properties = comp.preFrameRender(worker=self, completeAudioArray=completeAudioArray, sampleSize=sampleSize) + if properties and 'static' in properties: + staticComponents[compNo] = None # create video for output numpy.seterr(divide='ignore') @@ -88,18 +93,25 @@ class Worker(QtCore.QObject): bgI = 0 for i in range(0, len(completeAudioArray), sampleSize): newFrame = Image.new("RGBA", (int(self.core.settings.value('outputWidth')), int(self.core.settings.value('outputHeight'))),(0,0,0,255)) - if imBackground: newFrame.paste(imBackground) else: newFrame.paste(getBackgroundAtIndex(bgI)) + # composite all frames returned by the components in order for compNo, comp in enumerate(components): - newFrame = Image.alpha_composite(newFrame,comp.frameRender(compNo, i)) + if compNo in staticComponents and staticComponents[compNo] != None: + newFrame = Image.alpha_composite(newFrame,staticComponents[compNo]) + else: + newFrame = Image.alpha_composite(newFrame,comp.frameRender(compNo, i)) + if i == 0 and compNo in staticComponents: + staticComponents[compNo] = comp.frameRender(compNo, i) if not imBackground: + # increment background video frame for next iteration if bgI < len(backgroundFrames)-1: bgI += 1 + # write to out_pipe try: frame = Image.new("RGB", (int(self.core.settings.value('outputWidth')), int(self.core.settings.value('outputHeight'))),(0,0,0)) |
