Video editing with Python
Remove support for Python versions 2.7 and 3.4 (2)
Tom Burrows0dc182a5b5e1
diff --git a/.travis.yml b/.travis.ymlindex cbd7c42e..dc3d574a 100644--- a/.travis.yml+++ b/.travis.yml@@ -9,28 +9,6 @@ python:- 3.7- 3.8-jobs:- include:- - python: 2.7- dist: trusty- before_install:- - sudo add-apt-repository -y ppa:kirillshkrogalev/ffmpeg-next- - sudo apt-get -y -qq update- - sudo apt-get install -y -qq ffmpeg-- # Ensure PIP is up-to-date to avoid warnings.- - python -m pip install --upgrade pip- # Ensure setuptools is up-to-date to avoid environment_markers bug.- - pip install --upgrade setuptools- # The default pytest that is installed is too old on some platforms, leading to version conflicts- # pytest-cov contains plugin support for checking code coverage- - pip install --upgrade pytest-cov- - pip install flake8-- # modify ImageMagick policy file so that Textclips work correctly.- # `| sudo tee` replaces `>` so that it can have root permissions- - cat /etc/ImageMagick/policy.xml | sed 's/none/read,write/g' | sudo tee /etc/ImageMagick/policy.xml-before_install:- sudo apt-get -y -qq updatediff --git a/moviepy/audio/io/readers.py b/moviepy/audio/io/readers.pyindex cfecc826..4f0f0c10 100644--- a/moviepy/audio/io/readers.py+++ b/moviepy/audio/io/readers.py@@ -4,7 +4,6 @@ import warningsimport numpy as np-from moviepy.compat import DEVNULL, PY3from moviepy.config import get_settingfrom moviepy.video.io.ffmpeg_reader import ffmpeg_parse_infos@@ -88,7 +87,7 @@ class FFMPEG_AudioReader:popen_params = {"bufsize": self.buffersize,"stdout": sp.PIPE,"stderr": sp.PIPE,- "stdin": DEVNULL}+ "stdin": sp.DEVNULL}if os.name == "nt":popen_params["creationflags"] = 0x08000000diff --git a/moviepy/config.py b/moviepy/config.pyindex b1ce2f85..b777a0d0 100644--- a/moviepy/config.py+++ b/moviepy/config.py@@ -1,7 +1,6 @@import osimport subprocess as sp-from .compat import DEVNULLfrom .config_defaults import FFMPEG_BINARY, IMAGEMAGICK_BINARYif os.name == 'nt':@@ -16,7 +15,7 @@ def try_cmd(cmd):popen_params = {"stdout": sp.PIPE,"stderr": sp.PIPE,- "stdin": DEVNULL+ "stdin": sp.DEVNULL}# This was added so that no extra unwanted window opens on windowsdiff --git a/moviepy/editor.py b/moviepy/editor.pyindex c5dff72b..3b5babcf 100644--- a/moviepy/editor.py+++ b/moviepy/editor.py@@ -20,14 +20,6 @@ clip.preview().import osimport sys-# Downloads ffmpeg if it isn't already installed-import imageio-# Checks to see if the user has set a place for their own version of ffmpeg--if os.getenv('FFMPEG_BINARY') is None:- if sys.version_info < (3, 4):- #uses an old version of imageio with ffmpeg.download.- imageio.plugins.ffmpeg.download()# Hide the welcome message from pygame: https://github.com/pygame/pygame/issues/542os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = "1"@@ -62,7 +54,7 @@ except ImportError:pass# The next loop transforms many effects into VideoClip methods so that-# they can be walled with myclip.resize(width=500) instead of+# they can be called with myclip.resize(width=500) instead of# myclip.fx( vfx.resize, width= 500)for method in ["afx.audio_fadein",diff --git a/moviepy/tools.py b/moviepy/tools.pyindex 5357c3a6..39f20a8b 100644--- a/moviepy/tools.py+++ b/moviepy/tools.py@@ -8,8 +8,6 @@ import warningsimport proglog-from .compat import DEVNULL-def sys_write_flush(s):@@ -36,9 +34,9 @@ def subprocess_call(cmd, logger='bar', errorprint=True):logger = proglog.default_bar_logger(logger)logger(message='Moviepy - Running:\n>>> "+ " ".join(cmd)')- popen_params = {"stdout": DEVNULL,+ popen_params = {"stdout": sp.DEVNULL,"stderr": sp.PIPE,- "stdin": DEVNULL}+ "stdin": sp.DEVNULL}if os.name == "nt":popen_params["creationflags"] = 0x08000000@@ -57,14 +55,6 @@ def subprocess_call(cmd, logger='bar', errorprint=True):del proc-def is_string(obj):- """ Returns true if s is string or string-like object,- compatible with Python 2 and Python 3."""- try:- return isinstance(obj, basestring)- except NameError:- return isinstance(obj, str)-def cvsecs(time):""" Will convert any time into seconds.@@ -91,7 +81,7 @@ def cvsecs(time):"""factors = (1, 60, 3600)- if is_string(time):+ if isinstance(time, str):time = [float(f.replace(',', '.')) for f in time.split(':')]if not isinstance(time, (tuple, list)):diff --git a/moviepy/version.py b/moviepy/version.pyindex 5c4105cd..05b56ba9 100644--- a/moviepy/version.py+++ b/moviepy/version.py@@ -1 +1 @@-__version__ = "1.0.1"+__version__ = "2.0.0.dev"diff --git a/moviepy/video/VideoClip.py b/moviepy/video/VideoClip.pyindex d19d2535..92a2a745 100644--- a/moviepy/video/VideoClip.py+++ b/moviepy/video/VideoClip.py@@ -14,13 +14,12 @@ import proglogfrom imageio import imread, imsavefrom ..Clip import Clip-from ..compat import DEVNULL, string_typesfrom ..config import get_settingfrom ..decorators import (add_mask_if_none, apply_to_mask,convert_masks_to_RGB, convert_to_seconds, outplace,requires_duration, use_clip_fps_by_default)from ..tools import (deprecated_version_of, extensions_dict, find_extension,- is_string, subprocess_call)+ subprocess_call)from .io.ffmpeg_writer import ffmpeg_write_videofrom .io.gif_writers import (write_gif, write_gif_with_image_io,write_gif_with_tempfiles)@@ -275,7 +274,7 @@ class VideoClip(Clip):elif audio_codec == 'raw32':audio_codec = 'pcm_s32le'- audiofile = audio if is_string(audio) else None+ audiofile = audio if isinstance(audio, str) else Nonemake_audio = ((audiofile is None) and (audio == True) and(self.audio is not None))@@ -885,7 +884,7 @@ class ImageClip(VideoClip):fromalpha=False, duration=None):VideoClip.__init__(self, ismask=ismask, duration=duration)- if isinstance(img, string_types):+ if isinstance(img, str):img = imread(img)if len(img.shape) == 3: # img is (now) a RGB(a) numpy array@@ -1162,8 +1161,8 @@ class TextClip(ImageClip):``TextClip`` given (can be ``font``, ``color``, etc...) """popen_params = {"stdout": sp.PIPE,- "stderr": DEVNULL,- "stdin": DEVNULL}+ "stderr": sp.DEVNULL,+ "stdin": sp.DEVNULL}if os.name == "nt":popen_params["creationflags"] = 0x08000000diff --git a/moviepy/video/io/ffmpeg_reader.py b/moviepy/video/io/ffmpeg_reader.pyindex 7ef5b2d1..9f05d093 100644--- a/moviepy/video/io/ffmpeg_reader.py+++ b/moviepy/video/io/ffmpeg_reader.py@@ -13,7 +13,6 @@ import warningsimport numpy as np-from moviepy.compat import DEVNULL, PY3from moviepy.config import get_setting # ffmpeg, ffmpeg.exe, etc...from moviepy.tools import cvsecs@@ -96,7 +95,7 @@ class FFMPEG_VideoReader:popen_params = {"bufsize": self.bufsize,"stdout": sp.PIPE,"stderr": sp.PIPE,- "stdin": DEVNULL}+ "stdin": sp.DEVNULL}if os.name == "nt":popen_params["creationflags"] = 0x08000000@@ -249,7 +248,7 @@ def ffmpeg_parse_infos(filename, print_infos=False, check_duration=True,popen_params = {"bufsize": 10**5,"stdout": sp.PIPE,"stderr": sp.PIPE,- "stdin": DEVNULL}+ "stdin": sp.DEVNULL}if os.name == "nt":popen_params["creationflags"] = 0x08000000diff --git a/moviepy/video/io/ffmpeg_writer.py b/moviepy/video/io/ffmpeg_writer.pyindex 7fdd1dd6..f56ca507 100644--- a/moviepy/video/io/ffmpeg_writer.py+++ b/moviepy/video/io/ffmpeg_writer.py@@ -9,7 +9,6 @@ import subprocess as spimport numpy as npfrom proglog import proglog-from moviepy.compat import DEVNULL, PY3from moviepy.config import get_setting@@ -117,7 +116,7 @@ class FFMPEG_VideoWriter:filename])- popen_params = {"stdout": DEVNULL,+ popen_params = {"stdout": sp.DEVNULL,"stderr": logfile,"stdin": sp.PIPE}@@ -132,10 +131,7 @@ class FFMPEG_VideoWriter:def write_frame(self, img_array):""" Writes one frame in the file."""try:- if PY3:- self.proc.stdin.write(img_array.tobytes())- else:- self.proc.stdin.write(img_array.tostring())+ self.proc.stdin.write(img_array.tobytes())except IOError as err:_, ffmpeg_error = self.proc.communicate()error = (str(err) + ("\n\nMoviePy error: FFMPEG encountered "@@ -250,7 +246,7 @@ def ffmpeg_write_image(filename, image, logfile=False):else:log_file = sp.PIPE- popen_params = {"stdout": DEVNULL,+ popen_params = {"stdout": sp.DEVNULL,"stderr": log_file,"stdin": sp.PIPE}diff --git a/moviepy/video/io/gif_writers.py b/moviepy/video/io/gif_writers.pyindex b17d0e66..7719140d 100644--- a/moviepy/video/io/gif_writers.py+++ b/moviepy/video/io/gif_writers.py@@ -4,7 +4,6 @@ import subprocess as spimport numpy as npimport proglog-from moviepy.compat import DEVNULLfrom moviepy.config import get_settingfrom moviepy.decorators import requires_duration, use_clip_fps_by_defaultfrom moviepy.tools import subprocess_call@@ -165,16 +164,16 @@ def write_gif(clip, filename, fps=None, program= 'ImageMagick','-pix_fmt', ('rgba' if withmask else 'rgb24'),'-i', '-']- popen_params = {"stdout": DEVNULL,- "stderr": DEVNULL,- "stdin": DEVNULL}+ popen_params = {"stdout": sp.DEVNULL,+ "stderr": sp.DEVNULL,+ "stdin": sp.DEVNULL}if os.name == "nt":popen_params["creationflags"] = 0x08000000if program == "ffmpeg":popen_params["stdin"] = sp.PIPE- popen_params["stdout"] = DEVNULL+ popen_params["stdout"] = sp.DEVNULLproc1 = sp.Popen(cmd1+[ '-pix_fmt', ('rgba' if withmask else 'rgb24'),'-r', "%.02f"%fps, filename], **popen_params)@@ -194,7 +193,7 @@ def write_gif(clip, filename, fps=None, program= 'ImageMagick',if (opt in [False, None]):popen_params["stdin"] = proc1.stdout- popen_params["stdout"] = DEVNULL+ popen_params["stdout"] = sp.DEVNULLproc2 = sp.Popen(cmd2+[filename], **popen_params)else:@@ -210,7 +209,7 @@ def write_gif(clip, filename, fps=None, program= 'ImageMagick',filename]popen_params["stdin"] = proc2.stdout- popen_params["stdout"] = DEVNULL+ popen_params["stdout"] = sp.DEVNULLproc3 = sp.Popen(cmd3, **popen_params)# We send all the frames to the first processdiff --git a/setup.py b/setup.pyindex f8088bb5..d143cf10 100644--- a/setup.py+++ b/setup.py@@ -63,22 +63,20 @@ exec(open('moviepy/version.py').read()) # loads __version__# Define the requirements for specific execution needs.requires = ['decorator>=4.0.2,<5.0',- "imageio>=2.5,<3.0; python_version>='3.4'",- "imageio>=2.0,<2.5; python_version<'3.4'",- "imageio_ffmpeg>=0.2.0; python_version>='3.4'",+ "imageio>=2.5,<3.0",+ "imageio_ffmpeg>=0.2.0",'tqdm>=4.11.2,<5.0',- "numpy>=1.17.3; python_version!='2.7'",- "numpy; python_version>='2.7'",+ "numpy>=1.17.3",'requests>=2.8.1,<3.0','proglog<=1.0.0']optional_reqs = [- "opencv-python>=3.0,<4.0; python_version!='2.7'",- "scikit-image>=0.13.0,<1.0; python_version>='3.4'",- "scikit-learn; python_version>='3.4'",- "scipy>=0.19.0,<1.5; python_version!='3.3'",- "matplotlib>=2.0.0,<3.0; python_version>='3.4'",+ "opencv-python>=3.0,<4.0",+ "scikit-image>=0.13.0,<1.0",+ "scikit-learn",+ "scipy>=0.19.0,<1.5",+ "matplotlib>=2.0.0,<3.0","youtube_dl"]@@ -121,11 +119,12 @@ setup('Natural Language :: English','License :: OSI Approved :: MIT License','Programming Language :: Python',- 'Programming Language :: Python :: 2.7','Programming Language :: Python :: 3',- 'Programming Language :: Python :: 3.4','Programming Language :: Python :: 3.5','Programming Language :: Python :: 3.6',+ 'Programming Language :: Python :: 3.7',+ 'Programming Language :: Python :: 3.8',+'Topic :: Multimedia','Topic :: Multimedia :: Sound/Audio','Topic :: Multimedia :: Sound/Audio :: Analysis',diff --git a/tests/test_examples.py b/tests/test_examples.pyindex 73218d31..3f24e089 100644--- a/tests/test_examples.py+++ b/tests/test_examples.py@@ -13,7 +13,6 @@ from .test_helper import PYTHON_VERSION, TMP_DIR, TRAVIS@pytest.mark.skipif(not matplotlib, reason="no mpl")[email protected](PYTHON_VERSION in ('2.7', '3.3'), reason="version")@pytest.mark.skipif(PYTHON_VERSION == '3.5' and TRAVIS, reason="travis py35")def test_matplotlib():#for now, python 3.5 installs a version of matplotlib that complainsdiff --git a/tests/test_issues.py b/tests/test_issues.pyindex 709d0815..4ed4402d 100644--- a/tests/test_issues.py+++ b/tests/test_issues.py@@ -170,8 +170,8 @@ def test_issue_359():# TODO: Debug matplotlib failures following successful travis builds.# def test_issue_368():-# # Matplotlib only supported in python >= 3.4 and Travis/3.5 fails.-# if PYTHON_VERSION in ('2.7', '3.3') or (PYTHON_VERSION == '3.5' and TRAVIS):+# # Travis/3.5 fails.+# if PYTHON_VERSION == '3.5' and TRAVIS:# return## import numpy as npdiff --git a/tests/test_tools.py b/tests/test_tools.pyindex 63e9bc64..6fdb2bb8 100644--- a/tests/test_tools.py+++ b/tests/test_tools.py@@ -42,18 +42,6 @@ def test_cvsecs(given, expected):assert tools.cvsecs(given) == expected[email protected]("given, expected", [- ("hello straight string", True),- (r'hello raw string', True),- (42, False),- (True, False),- (b'hello bytes', sys.version_info[0] < 3),-])-def test_is_string(given, expected):- """Test the is_string function in tools."""- assert tools.is_string(given) == expected--def test_sys_write_flush():"""Test for sys_write-flush function. Check that stdout has no content after flushing."""tools.sys_write_flush("hello world")