Skip to content

Video editing with Python

PEP 8

Tom Burrows8f3c50320be0
diff --git a/moviepy/video/tools/credits.py b/moviepy/video/tools/credits.py
index 90762959..66424acb 100644
--- a/moviepy/video/tools/credits.py
+++ b/moviepy/video/tools/credits.py
@@ -8,12 +8,11 @@ from moviepy.video.VideoClip import TextClip, ImageClip
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):
+
+def credits1(creditfile, width, stretch=30, color='white', stroke_color='black',
+ stroke_width=2, font='Impact-Normal', fontsize=60):
"""
-
-
+
Parameters
-----------
@@ -51,7 +50,7 @@ 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
@@ -59,52 +58,50 @@ def credits1(creditfile,width,stretch=30,color='white',
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])
+ 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)