Skip to content

Video editing with Python

remove `verbose` argument from every signatures

Martín Gaitánaa258c30bfcd
diff --git a/moviepy/tools.py b/moviepy/tools.py
index cc349824..1091091b 100644
--- a/moviepy/tools.py
+++ b/moviepy/tools.py
@@ -19,15 +19,9 @@ def sys_write_flush(s):
sys.stdout.flush()
-def verbose_print(verbose, s):
- """ Only prints s (with sys_write_flush) if verbose is True."""
- if verbose:
- sys_write_flush(s)
-
-
def subprocess_call(cmd, logger="bar", errorprint=True):
""" Executes the given subprocess command.
-
+
Set logger to None or a custom Proglog logger to avoid printings.
"""
logger = proglog.default_bar_logger(logger)
@@ -54,20 +48,20 @@ def subprocess_call(cmd, logger="bar", errorprint=True):
def cvsecs(time):
- """ Will convert any time into seconds.
-
- If the type of `time` is not valid,
- it's returned as is.
+ """ Will convert any time into seconds.
+
+ If the type of `time` is not valid,
+ it's returned as is.
Here are the accepted formats::
- >>> cvsecs(15.4) # seconds
- 15.4
- >>> cvsecs((1, 21.5)) # (min,sec)
- 81.5
- >>> cvsecs((1, 1, 2)) # (hr, min, sec)
- 3662
- >>> cvsecs('01:01:33.045')
+ >>> cvsecs(15.4) # seconds
+ 15.4
+ >>> cvsecs((1, 21.5)) # (min,sec)
+ 81.5
+ >>> cvsecs((1, 1, 2)) # (hr, min, sec)
+ 3662
+ >>> cvsecs('01:01:33.045')
3693.045
>>> cvsecs('01:01:33,5') # coma works too
3693.5
diff --git a/moviepy/video/VideoClip.py b/moviepy/video/VideoClip.py
index 9aaa4c1f..80663726 100644
--- a/moviepy/video/VideoClip.py
+++ b/moviepy/video/VideoClip.py
@@ -156,7 +156,6 @@ class VideoClip(Clip):
rewrite_audio=True,
remove_temp=True,
write_logfile=False,
- verbose=True,
threads=None,
ffmpeg_params=None,
logger="bar",
@@ -344,7 +343,7 @@ class VideoClip(Clip):
@use_clip_fps_by_default
@convert_masks_to_RGB
def write_images_sequence(
- self, nameformat, fps=None, verbose=True, withmask=True, logger="bar"
+ self, nameformat, fps=None, withmask=True, logger="bar"
):
""" Writes the videoclip to a sequence of image files.
@@ -365,9 +364,6 @@ class VideoClip(Clip):
withmask
will save the clip's mask (if any) as an alpha canal (PNGs only).
- verbose
- Boolean indicating whether to print information.
-
logger
Either 'bar' (progress bar) or None or any Proglog logger.
@@ -408,7 +404,6 @@ class VideoClip(Clip):
program="imageio",
opt="nq",
fuzz=1,
- verbose=True,
loop=0,
dispose=False,
colors=None,
@@ -475,7 +470,6 @@ class VideoClip(Clip):
fps=fps,
opt=opt,
loop=loop,
- verbose=verbose,
colors=colors,
logger=logger,
)
@@ -490,7 +484,6 @@ class VideoClip(Clip):
program=program,
opt=opt,
fuzz=fuzz,
- verbose=verbose,
loop=loop,
dispose=dispose,
colors=colors,
@@ -507,7 +500,6 @@ class VideoClip(Clip):
program=program,
opt=opt,
fuzz=fuzz,
- verbose=verbose,
loop=loop,
dispose=dispose,
colors=colors,
diff --git a/moviepy/video/io/VideoFileClip.py b/moviepy/video/io/VideoFileClip.py
index 9a6938da..9fa30bc8 100644
--- a/moviepy/video/io/VideoFileClip.py
+++ b/moviepy/video/io/VideoFileClip.py
@@ -61,17 +61,17 @@ class VideoFileClip(VideoClip):
fps:
Frames per second in the original file.
-
-
+
+
Read docs for Clip() and VideoClip() for other, more generic, attributes.
-
+
Lifetime
--------
-
+
Note that this creates subprocesses and locks files. If you construct one of these instances, you must call
close() afterwards, or the subresources will not be cleaned up until the process ends.
-
- If copies are made, and close() is called on one, it may cause methods on the other copies to fail.
+
+ If copies are made, and close() is called on one, it may cause methods on the other copies to fail.
"""
@@ -85,7 +85,6 @@ class VideoFileClip(VideoClip):
resize_algorithm="bicubic",
audio_fps=44100,
audio_nbytes=2,
- verbose=False,
fps_source="tbr",
):
diff --git a/moviepy/video/io/gif_writers.py b/moviepy/video/io/gif_writers.py
index baa005e1..89fc767f 100644
--- a/moviepy/video/io/gif_writers.py
+++ b/moviepy/video/io/gif_writers.py
@@ -25,7 +25,6 @@ def write_gif_with_tempfiles(
program="ImageMagick",
opt="OptimizeTransparency",
fuzz=1,
- verbose=True,
loop=0,
dispose=True,
colors=None,
@@ -129,7 +128,6 @@ def write_gif(
program="ImageMagick",
opt="OptimizeTransparency",
fuzz=1,
- verbose=True,
withmask=True,
loop=0,
dispose=True,
@@ -329,7 +327,7 @@ def write_gif(
def write_gif_with_image_io(
- clip, filename, fps=None, opt=0, loop=0, colors=None, verbose=True, logger="bar"
+ clip, filename, fps=None, opt=0, loop=0, colors=None, logger="bar"
):
"""
Writes the gif with the Python library ImageIO (calls FreeImage).
diff --git a/moviepy/video/io/html_tools.py b/moviepy/video/io/html_tools.py
index 5b42705d..e8761578 100644
--- a/moviepy/video/io/html_tools.py
+++ b/moviepy/video/io/html_tools.py
@@ -52,7 +52,7 @@ def html_embed(
clip, filetype=None, maxduration=60, rd_kwargs=None, center=True, **html_kwargs
):
""" Returns HTML5 code embedding the clip
-
+
clip
Either a file name, or a clip to preview.
Either an image, a sound or a video. Clips will actually be
@@ -62,10 +62,10 @@ def html_embed(
filetype
One of 'video','image','audio'. If None is given, it is determined
based on the extension of ``filename``, but this can bug.
-
+
rd_kwargs
keyword arguments for the rendering, like {'fps':15, 'bitrate':'50k'}
-
+
**html_kwargs
Allow you to give some options, like width=260, autoplay=True,
@@ -102,12 +102,12 @@ def html_embed(
clip.save_frame(**kwargs)
elif isinstance(clip, VideoClip):
filename = TEMP_PREFIX + ".mp4"
- kwargs = {"filename": filename, "verbose": False, "preset": "ultrafast"}
+ kwargs = {"filename": filename, "preset": "ultrafast"}
kwargs.update(rd_kwargs)
clip.write_videofile(**kwargs)
elif isinstance(clip, AudioClip):
filename = TEMP_PREFIX + ".mp3"
- kwargs = {"filename": filename, "verbose": False}
+ kwargs = {"filename": filename}
kwargs.update(rd_kwargs)
clip.write_audiofile(**kwargs)
else:
@@ -206,11 +206,11 @@ def ipython_display(
fps
Enables to specify an fps, as required for clips whose fps is unknown.
-
+
**kwargs:
Allow you to give some options, like width=260, etc. When editing
looping gifs, a good choice is loop=1, autoplay=1.
-
+
Remarks: If your browser doesn't support HTML5, this should warn you.
If nothing is displayed, maybe your file or filename is wrong.
Important: The media will be physically embedded in the notebook.
diff --git a/moviepy/video/tools/cuts.py b/moviepy/video/tools/cuts.py
index d98adfb3..066d2e36 100644
--- a/moviepy/video/tools/cuts.py
+++ b/moviepy/video/tools/cuts.py
@@ -21,7 +21,7 @@ def find_video_period(clip, fps=None, tmin=0.3):
class FramesMatch:
"""
-
+
Parameters
-----------
@@ -119,7 +119,7 @@ class FramesMatches(list):
Examples
---------
-
+
We find all matching frames in a given video and turn the best match with
a duration of 1.5s or more into a GIF:
@@ -135,16 +135,16 @@ class FramesMatches(list):
clip
A MoviePy video clip, possibly transformed/resized
-
+
dist_thr
Distance above which a match is rejected
-
+
max_d
Maximal duration (in seconds) between two matching frames
-
+
fps
Frames per second (default will be clip.fps)
-
+
"""
N_pixels = clip.w * clip.h * 3
@@ -278,49 +278,49 @@ class FramesMatches(list):
def write_gifs(self, clip, gif_dir):
for (start, end, _, _) in self:
name = "%s/%08d_%08d.gif" % (gif_dir, 100 * start, 100 * end)
- clip.subclip(start, end).write_gif(name, verbose=False)
+ clip.subclip(start, end).write_gif(name)
@use_clip_fps_by_default
def detect_scenes(clip=None, luminosities=None, thr=10, logger="bar", fps=None):
""" Detects scenes of a clip based on luminosity changes.
-
+
Note that for large clip this may take some time
-
+
Returns
--------
cuts, luminosities
cuts is a series of cuts [(0,t1), (t1,t2),...(...,tf)]
luminosities are the luminosities computed for each
frame of the clip.
-
+
Parameters
-----------
-
+
clip
A video clip. Can be None if a list of luminosities is
provided instead. If provided, the luminosity of each
frame of the clip will be computed. If the clip has no
'fps' attribute, you must provide it.
-
+
luminosities
A list of luminosities, e.g. returned by detect_scenes
in a previous run.
-
+
thr
Determines a threshold above which the 'luminosity jumps'
will be considered as scene changes. A scene change is defined
as a change between 2 consecutive frames that is larger than
(avg * thr) where avg is the average of the absolute changes
between consecutive frames.
-
+
progress_bar
We all love progress bars ! Here is one for you, in option.
-
+
fps
Must be provided if you provide no clip or a clip without
fps attribute.
-
+
"""
if luminosities is None: