Skip to content

Commit

Permalink
Merge pull request #1115 from mgaitan/remove_deprecated
Browse files Browse the repository at this point in the history
Remove deprecated functions and parameters
  • Loading branch information
mgaitan authored Apr 9, 2020
2 parents eb988e9 + 3cfa738 commit 3fc80cb
Show file tree
Hide file tree
Showing 14 changed files with 59 additions and 167 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Deprecated <!-- for soon-to-be removed features -->

### Removed <!-- for now removed features -->
- Support removed for Python versions 2.7, 3.4 & 3.5
- Support for Python versions 2.7, 3.4 & 3.5
- All previously deprecated methods and parameters [#1115]:
- `AudioClip.to_audiofile()` -> use `AudioClip.write_audiofile()`
- `VideoClip.to_videofile()` -> use `VideoClip.write_videofile()`
- `VideoClip.to_images_sequence()` -> use `VideoClip.write_images_sequence()`
- `concatenate()` -> use `concatenate_videoclips()`
- `verbose` parameter in `AudioClip.write_audiofile()`, `ffmpeg_audiowriter()`, `VideoFileClip()`, `VideoClip.write_videofile()`, `VideoClip.write_images_sequence()`, `ffmpeg_write_video()`, `write_gif()`, `write_gif_with_tempfiles()`, `write_gif_with_image_io()` -> Instead of `verbose=False`, use `logger=None`
- `verbose_print()` -> no replacement
- `col` parameter in `ColorClip()` -> use `color`

### Fixed <!-- for any bug fixes -->
- When using `VideoClip.write_videofile()` with `write_logfile=True`, errors would not be properly reported [#890]
Expand Down
16 changes: 2 additions & 14 deletions moviepy/audio/AudioClip.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from moviepy.audio.io.ffmpeg_audiowriter import ffmpeg_audiowrite
from moviepy.Clip import Clip
from moviepy.decorators import requires_duration
from moviepy.tools import deprecated_version_of, extensions_dict
from moviepy.tools import extensions_dict


class AudioClip(Clip):
Expand Down Expand Up @@ -169,7 +169,6 @@ def write_audiofile(
bitrate=None,
ffmpeg_params=None,
write_logfile=False,
verbose=True,
logger="bar",
):
""" Writes an audio file from the AudioClip.
Expand Down Expand Up @@ -206,10 +205,7 @@ def write_audiofile(
write_logfile
If true, produces a detailed logfile named filename + '.log'
when writing the file
verbose
Boolean indicating whether to print infomation
logger
Either 'bar' or None or any Proglog logger
Expand Down Expand Up @@ -240,19 +236,11 @@ def write_audiofile(
codec=codec,
bitrate=bitrate,
write_logfile=write_logfile,
verbose=verbose,
ffmpeg_params=ffmpeg_params,
logger=logger,
)


# The to_audiofile method is replaced by the more explicit write_audiofile.
AudioClip.to_audiofile = deprecated_version_of(
AudioClip.write_audiofile, "to_audiofile"
)
###


class AudioArrayClip(AudioClip):
"""
Expand Down
3 changes: 0 additions & 3 deletions moviepy/audio/io/ffmpeg_audiowriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,15 +176,12 @@ def ffmpeg_audiowrite(
codec="libvorbis",
bitrate=None,
write_logfile=False,
verbose=True,
ffmpeg_params=None,
logger="bar",
):
"""
A function that wraps the FFMPEG_AudioWriter to write an AudioClip
to a file.
NOTE: verbose is deprecated.
"""

if write_logfile:
Expand Down
5 changes: 1 addition & 4 deletions moviepy/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@
from .video.io.downloader import download_webfile
from .video.VideoClip import VideoClip, ImageClip, ColorClip, TextClip
from .video.compositing.CompositeVideoClip import CompositeVideoClip, clips_array
from .video.compositing.concatenate import (
concatenate_videoclips,
concatenate,
) # concatenate=deprecated
from .video.compositing.concatenate import concatenate_videoclips

from .audio.AudioClip import AudioClip, CompositeAudioClip, concatenate_audioclips
from .audio.io.AudioFileClip import AudioFileClip
Expand Down
30 changes: 12 additions & 18 deletions moviepy/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
55 changes: 4 additions & 51 deletions moviepy/video/VideoClip.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
use_clip_fps_by_default,
)
from ..tools import (
deprecated_version_of,
extensions_dict,
find_extension,
subprocess_call,
Expand Down Expand Up @@ -157,7 +156,6 @@ def write_videofile(
rewrite_audio=True,
remove_temp=True,
write_logfile=False,
verbose=True,
threads=None,
ffmpeg_params=None,
logger="bar",
Expand Down Expand Up @@ -261,9 +259,6 @@ def write_videofile(
logger
Either "bar" for progress bar or None or any Proglog logger.
verbose (deprecated, kept for compatibility)
Formerly used for toggling messages on/off. Use logger=None now.
Examples
========
Expand Down Expand Up @@ -322,7 +317,6 @@ def write_videofile(
audio_codec,
bitrate=audio_bitrate,
write_logfile=write_logfile,
verbose=verbose,
logger=logger,
)

Expand All @@ -335,7 +329,6 @@ def write_videofile(
preset=preset,
write_logfile=write_logfile,
audiofile=audiofile,
verbose=verbose,
threads=threads,
ffmpeg_params=ffmpeg_params,
logger=logger,
Expand All @@ -349,9 +342,7 @@ def write_videofile(
@requires_duration
@use_clip_fps_by_default
@convert_masks_to_RGB
def write_images_sequence(
self, nameformat, fps=None, verbose=True, withmask=True, logger="bar"
):
def write_images_sequence(self, nameformat, fps=None, withmask=True, logger="bar"):
""" Writes the videoclip to a sequence of image files.
Parameters
Expand All @@ -371,9 +362,6 @@ def write_images_sequence(
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.
Expand Down Expand Up @@ -414,7 +402,6 @@ def write_gif(
program="imageio",
opt="nq",
fuzz=1,
verbose=True,
loop=0,
dispose=False,
colors=None,
Expand Down Expand Up @@ -481,7 +468,6 @@ def write_gif(
fps=fps,
opt=opt,
loop=loop,
verbose=verbose,
colors=colors,
logger=logger,
)
Expand All @@ -496,7 +482,6 @@ def write_gif(
program=program,
opt=opt,
fuzz=fuzz,
verbose=verbose,
loop=loop,
dispose=dispose,
colors=colors,
Expand All @@ -513,7 +498,6 @@ def write_gif(
program=program,
opt=opt,
fuzz=fuzz,
verbose=verbose,
loop=loop,
dispose=dispose,
colors=colors,
Expand Down Expand Up @@ -1041,21 +1025,6 @@ def fl_time(self, time_func, apply_to=None, keep_duration=False):
setattr(self, attr, new_a)


# ##
#
# The old functions to_videofile, to_gif, to_images sequences have been
# replaced by the more explicite write_videofile, write_gif, etc.

VideoClip.set_pos = deprecated_version_of(VideoClip.set_position, "set_pos")
VideoClip.to_videofile = deprecated_version_of(
VideoClip.write_videofile, "to_videofile"
)
VideoClip.to_gif = deprecated_version_of(VideoClip.write_gif, "to_gif")
VideoClip.to_images_sequence = deprecated_version_of(
VideoClip.write_images_sequence, "to_images_sequence"
)


class ColorClip(ImageClip):
"""An ImageClip showing just one color.
Expand All @@ -1073,29 +1042,13 @@ class ColorClip(ImageClip):
ismask
Set to true if the clip will be used as a mask.
col
Has been deprecated. Do not use.
"""

def __init__(self, size, color=None, ismask=False, duration=None, col=None):
if col is not None:
warnings.warn(
"The `ColorClip` parameter `col` has been deprecated."
" Please use `color` instead.",
DeprecationWarning,
)
if color is not None:
warnings.warn(
"The arguments `color` and `col` have both been "
"passed to `ColorClip` so `col` has been ignored.",
UserWarning,
)
else:
color = col
def __init__(self, size, color=None, ismask=False, duration=None):
w, h = size
shape = (h, w) if np.isscalar(color) else (h, w, len(color))
ImageClip.__init__(
self, np.tile(color, w * h).reshape(shape), ismask=ismask, duration=duration
super().__init__(
np.tile(color, w * h).reshape(shape), ismask=ismask, duration=duration
)


Expand Down
5 changes: 0 additions & 5 deletions moviepy/video/compositing/concatenate.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
from functools import reduce

from moviepy.audio.AudioClip import CompositeAudioClip
from moviepy.tools import deprecated_version_of
from moviepy.video.compositing.CompositeVideoClip import CompositeVideoClip
from moviepy.video.compositing.on_color import on_color
from moviepy.video.VideoClip import ColorClip, VideoClip


Expand Down Expand Up @@ -116,6 +114,3 @@ def get_mask(c):
fpss = [c.fps for c in clips if getattr(c, "fps", None) is not None]
result.fps = max(fpss) if fpss else None
return result


concatenate = deprecated_version_of(concatenate_videoclips, oldname="concatenate")
2 changes: 1 addition & 1 deletion moviepy/video/compositing/transitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def slide_in(clip, duration, side):
>>> slided_clips = [CompositeVideoClip([
clip.fx(transfx.slide_in, duration=1, side='left')])
for clip in clips]
>>> final_clip = concatenate( slided_clips, padding=-1)
>>> final_clip = concatenate_videoclips( slided_clips, padding=-1)
"""
w, h = clip.size
Expand Down
13 changes: 6 additions & 7 deletions moviepy/video/io/VideoFileClip.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""

Expand All @@ -85,7 +85,6 @@ def __init__(
resize_algorithm="bicubic",
audio_fps=44100,
audio_nbytes=2,
verbose=False,
fps_source="tbr",
):

Expand Down
4 changes: 0 additions & 4 deletions moviepy/video/io/ffmpeg_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ def ffmpeg_write_video(
withmask=False,
write_logfile=False,
audiofile=None,
verbose=True,
threads=None,
ffmpeg_params=None,
logger="bar",
Expand All @@ -247,9 +246,6 @@ def ffmpeg_write_video(
threads=threads,
ffmpeg_params=ffmpeg_params,
) as writer:

nframes = int(clip.duration * fps)

for t, frame in clip.iter_frames(
logger=logger, with_times=True, fps=fps, dtype="uint8"
):
Expand Down
4 changes: 1 addition & 3 deletions moviepy/video/io/gif_writers.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ def write_gif_with_tempfiles(
program="ImageMagick",
opt="OptimizeTransparency",
fuzz=1,
verbose=True,
loop=0,
dispose=True,
colors=None,
Expand Down Expand Up @@ -129,7 +128,6 @@ def write_gif(
program="ImageMagick",
opt="OptimizeTransparency",
fuzz=1,
verbose=True,
withmask=True,
loop=0,
dispose=True,
Expand Down Expand Up @@ -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).
Expand Down
Loading

0 comments on commit 3fc80cb

Please sign in to comment.