Skip to content

Commit

Permalink
Merge pull request #715 from tburrows13/pep8
Browse files Browse the repository at this point in the history
Credits.py PEP 8
  • Loading branch information
tburrows13 committed Feb 12, 2018
2 parents d6708b3 + f92157b commit f2b107c
Showing 1 changed file with 26 additions and 29 deletions.
55 changes: 26 additions & 29 deletions moviepy/video/tools/credits.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@
from moviepy.video.compositing.CompositeVideoClip import CompositeVideoClip
from moviepy.video.fx import resize

def credits1(creditfile,width,stretch=30,color='white',
stroke_color='black', stroke_width=2,
font='Impact-Normal',fontsize=60,gap=0):

def credits1(creditfile, width, stretch=30, color='white', stroke_color='black',
stroke_width=2, font='Impact-Normal', fontsize=60, gap=0):
"""
Parameters
-----------
Expand Down Expand Up @@ -51,60 +50,58 @@ def credits1(creditfile,width,stretch=30,color='white',
image
An ImageClip instance that looks like this and can be scrolled
to make some credits :
to make some credits:
Executive Story Editor MARCEL DURAND
Associate Producers MARTIN MARCEL
DIDIER MARTIN
Music Supervisor JEAN DIDIER
"""



# PARSE THE TXT FILE

with open(creditfile) as f:
lines = f.readlines()

lines = filter(lambda x:not x.startswith('\n'),lines)
lines = filter(lambda x: not x.startswith('\n'), lines)
texts = []
oneline=True
for l in lines:
oneline = True
for l in lines:
if not l.startswith('#'):
if l.startswith('.blank'):
for i in range(int(l.split(' ')[1])):
texts.append(['\n','\n'])
elif l.startswith('..'):
texts.append([l[2:],''])
oneline=True
texts.append(['\n', '\n'])
elif l.startswith('..'):
texts.append([l[2:], ''])
oneline = True
else:
if oneline:
texts.append(['',l])
oneline=False
texts.append(['', l])
oneline = False
else:
texts.append(['\n',l])
texts.append(['\n', l])

left,right = [ "".join(l) for l in zip(*texts)]
left, right = ["".join(l) for l in zip(*texts)]

# MAKE TWO COLUMNS FOR THE CREDITS

left,right = [TextClip(txt,color=color,stroke_color=stroke_color,
stroke_width=stroke_width,font=font,
fontsize=fontsize,align=al)
for txt,al in [(left,'East'),(right,'West')]]

left, right = [TextClip(txt, color=color, stroke_color=stroke_color,
stroke_width=stroke_width, font=font,
fontsize=fontsize, align=al)
for txt, al in [(left, 'East'), (right, 'West')]]

cc = CompositeVideoClip( [left, right.set_pos((left.w+gap,0))],
size = (left.w+right.w+gap,right.h),
transparent=True)
cc = CompositeVideoClip([left, right.set_pos((left.w+gap, 0))],
size=(left.w+right.w+gap, right.h),
transparent=True)

# SCALE TO THE REQUIRED SIZE

scaled = cc.fx(resize , width=width)
scaled = cc.fx(resize, width=width)

# TRANSFORM THE WHOLE CREDIT CLIP INTO AN ImageCLip

imclip = ImageClip(scaled.get_frame(0))
amask = ImageClip(scaled.mask.get_frame(0),ismask=True)
amask = ImageClip(scaled.mask.get_frame(0), ismask=True)

return imclip.set_mask(amask)

0 comments on commit f2b107c

Please sign in to comment.