Skip to content

Commit

Permalink
added static components which don't get called each frame when rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
Brianna committed May 30, 2017
2 parents d185261 + 369ac2a commit 7240f25
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
__pycache__
settings.ini
build/*
.vscode/*
.vscode/*
*.mkv
*.mp4
4 changes: 4 additions & 0 deletions components/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ def previewRender(self, previewWorker):
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'))
Expand Down
22 changes: 17 additions & 5 deletions video_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,29 +77,41 @@ def getBackgroundAtIndex(i):

# 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')
frame = getBackgroundAtIndex(0)
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))
Expand Down

0 comments on commit 7240f25

Please sign in to comment.