Skip to content

Video editing with Python

Incorporated optional progress_bar flag for writing video to file

wingillis45372285797e
diff --git a/moviepy/video/VideoClip.py b/moviepy/video/VideoClip.py
index bcc6bb2b..fddedf4b 100644
--- a/moviepy/video/VideoClip.py
+++ b/moviepy/video/VideoClip.py
@@ -137,7 +137,7 @@ class VideoClip(Clip):
"""
- im = self.get_frame(t)
+ im = self.get_frame(t)
if withmask and self.mask is not None:
mask = 255 * self.mask.get_frame(t)
@@ -159,7 +159,8 @@ class VideoClip(Clip):
temp_audiofile=None,
rewrite_audio=True, remove_temp=True,
write_logfile=False, verbose=True,
- threads=None, ffmpeg_params=None):
+ threads=None, ffmpeg_params=None,
+ progress_bar=True):
"""Write the clip to a videofile.
@@ -335,7 +336,8 @@ class VideoClip(Clip):
write_logfile=write_logfile,
audiofile = audiofile,
verbose=verbose, threads=threads,
- ffmpeg_params=ffmpeg_params)
+ ffmpeg_params=ffmpeg_params,
+ progress_bar=progress_bar)
if remove_temp and make_audio:
os.remove(audiofile)
@@ -459,7 +461,7 @@ class VideoClip(Clip):
if program == 'imageio':
write_gif_with_image_io(self, filename, fps=fps, opt=opt, loop=loop,
verbose=verbose, colors=colors)
-
+
elif tempfiles:
write_gif_with_tempfiles(self, filename, fps=fps,
program=program, opt=opt, fuzz=fuzz,
@@ -821,12 +823,12 @@ class DataVideoClip(VideoClip):
class UpdatedVideoClip(VideoClip):
"""
-
+
Class of clips whose make_frame requires some objects to
be updated. Particularly practical in science where some
algorithm needs to make some steps before a new frame can
be generated.
-
+
UpdatedVideoClips have the following make_frame:
>>> def make_frame(t):
@@ -850,12 +852,12 @@ class UpdatedVideoClip(VideoClip):
duration
Duration of the clip, in seconds
-
+
"""
-
-
+
+
def __init__(self, world, ismask=False, duration=None):
-
+
self.world = world
def make_frame(t):
while self.world.clip_t < t:
@@ -1159,7 +1161,7 @@ class TextClip(ImageClip):
if print_cmd:
print( " ".join(cmd) )
-
+
try:
subprocess_call(cmd, verbose=False )
except (IOError,OSError) as err:
@@ -1213,7 +1215,7 @@ class TextClip(ImageClip):
>>> # Find all the available fonts which contain "Courier"
>>> print ( TextClip.search('Courier', 'font') )
-
+
"""
string = string.lower()
names_list = TextClip.list(arg)
diff --git a/moviepy/video/io/ffmpeg_writer.py b/moviepy/video/io/ffmpeg_writer.py
index 60501520..e56f13cf 100644
--- a/moviepy/video/io/ffmpeg_writer.py
+++ b/moviepy/video/io/ffmpeg_writer.py
@@ -127,7 +127,7 @@ class FFMPEG_VideoWriter:
# when the child process is created
if os.name == "nt":
popen_params["creationflags"] = 0x08000000
-
+
self.proc = sp.Popen(cmd, **popen_params)
@@ -188,7 +188,8 @@ class FFMPEG_VideoWriter:
def ffmpeg_write_video(clip, filename, fps, codec="libx264", bitrate=None,
preset="medium", withmask=False, write_logfile=False,
- audiofile=None, verbose=True, threads=None, ffmpeg_params=None):
+ audiofile=None, verbose=True, threads=None, ffmpeg_params=None,
+ progress_bar=True):
""" Write the clip to a videofile. See VideoClip.write_videofile for details
on the parameters.
"""
@@ -205,14 +206,14 @@ def ffmpeg_write_video(clip, filename, fps, codec="libx264", bitrate=None,
nframes = int(clip.duration*fps)
- for t,frame in clip.iter_frames(progress_bar=True, with_times=True,
+ for t,frame in clip.iter_frames(progress_bar=progress_bar, with_times=True,
fps=fps, dtype="uint8"):
if withmask:
mask = (255*clip.mask.get_frame(t))
if mask.dtype != "uint8":
mask = mask.astype("uint8")
frame = np.dstack([frame,mask])
-
+
writer.write_frame(frame)
writer.close()
@@ -226,7 +227,7 @@ def ffmpeg_write_video(clip, filename, fps, codec="libx264", bitrate=None,
def ffmpeg_write_image(filename, image, logfile=False):
""" Writes an image (HxWx3 or HxWx4 numpy array) to a file, using
ffmpeg. """
-
+
if image.dtype != 'uint8':
image = image.astype("uint8")