Video editing with Python
PEP8 2
Tom Burrows8676acc2c2ba
diff --git a/moviepy/Clip.py b/moviepy/Clip.pyindex 015ecf51..4e72f5d7 100644--- a/moviepy/Clip.py+++ b/moviepy/Clip.py@@ -7,14 +7,15 @@ and AudioClip.from copy import copyimport numpy as np-from moviepy.decorators import ( apply_to_mask,- apply_to_audio,- requires_duration,- outplace,- convert_to_seconds,- use_clip_fps_by_default)+from moviepy.decorators import (apply_to_mask,+ apply_to_audio,+ requires_duration,+ outplace,+ convert_to_seconds,+ use_clip_fps_by_default)from tqdm import tqdm+class Clip:"""@@ -53,9 +54,7 @@ class Clip:self.memoize = Falseself.memoized_t = None- self.memoize_frame = None--+ self.memoize_frame = Nonedef copy(self):""" Shallow copy of the clip.@@ -148,13 +147,11 @@ class Clip:if hasattr(newclip, attr):a = getattr(newclip, attr)if a is not None:- new_a = a.fl(fun, keep_duration=keep_duration)+ new_a = a.fl(fun, keep_duration=keep_duration)setattr(newclip, attr, new_a)return newclip--def fl_time(self, t_func, apply_to=None, keep_duration=False):"""Returns a Clip instance playing the content of the current clip@@ -190,9 +187,7 @@ class Clip:apply_to = []return self.fl(lambda gf, t: gf(t_func(t)), apply_to,- keep_duration=keep_duration)--+ keep_duration=keep_duration)def fx(self, func, *args, **kwargs):"""@@ -246,7 +241,7 @@ class Clip:self.start = tif (self.duration is not None) and change_end:self.end = t + self.duration- elif (self.end is not None):+ elif self.end is not None:self.duration = self.end - self.start@@ -348,7 +343,7 @@ class Clip:# If we arrive here, a part of t falls in the clipresult = 1 * (t >= self.start)- if (self.end is not None):+ if self.end is not None:result *= (t <= self.end)return result@@ -384,14 +379,15 @@ class Clip:they exist."""- if t_start < 0: #make this more python like a negative value- #means to move backward from the end of the clip- t_start = self.duration + t_start #remeber t_start is negative+ if t_start < 0:+ # Make this more Python-like, a negative value means to move+ # backward from the end of the clip+ t_start = self.duration + t_start # Remember t_start is negative- if (self.duration is not None) and (t_start>self.duration):- raise ValueError("t_start (%.02f) "%t_start ++ if (self.duration is not None) and (t_start > self.duration):+ raise ValueError("t_start (%.02f) "% t_start +"should be smaller than the clip's "+- "duration (%.02f)."%self.duration)+ "duration (%.02f)."% self.duration)newclip = self.fl_time(lambda t: t + t_start, apply_to=[])@@ -403,14 +399,14 @@ class Clip:if self.duration is None:- print ("Error: subclip with negative times (here %s)"%(str((t_start, t_end)))- +" can only be extracted from clips with a ``duration``")+ print("Error: subclip with negative times (here %s)" % (str((t_start, t_end)))+ + " can only be extracted from clips with a ``duration``")else:t_end = self.duration + t_end- if (t_end is not None):+ if t_end is not None:newclip.duration = t_end - t_startnewclip.end = newclip.start + newclip.durationdiff --git a/moviepy/video/io/VideoFileClip.py b/moviepy/video/io/VideoFileClip.pyindex 015963eb..cd5534e1 100644--- a/moviepy/video/io/VideoFileClip.py+++ b/moviepy/video/io/VideoFileClip.py@@ -15,7 +15,7 @@ class VideoFileClip(VideoClip):>>> clip = VideoFileClip("myHolidays.mp4")>>> clip.close()>>> with VideoFileClip("myMaskVideo.avi") as clip2:- >>> pass # Implicit close called by contex manager.+ >>> pass # Implicit close called by context manager.Parameters@@ -76,7 +76,7 @@ class VideoFileClip(VideoClip):"""def __init__(self, filename, has_mask=False,- audio=True, audio_buffersize = 200000,+ audio=True, audio_buffersize=200000,target_resolution=None, resize_algorithm='bicubic',audio_fps=44100, audio_nbytes=2, verbose=False,fps_source='tbr'):@@ -104,7 +104,7 @@ class VideoFileClip(VideoClip):self.make_frame = lambda t: self.reader.get_frame(t)[:,:,:3]mask_mf = lambda t: self.reader.get_frame(t)[:,:,3]/255.0- self.mask = (VideoClip(ismask = True, make_frame=mask_mf)+ self.mask = (VideoClip(ismask=True, make_frame=mask_mf).set_duration(self.duration))self.mask.fps = self.fps