Skip to content

Commit

Permalink
Merge branch 'master' into new-pathlike-support
Browse files Browse the repository at this point in the history
  • Loading branch information
tburrows13 committed Apr 18, 2020
2 parents 4beda6c + 103b2aa commit 54751ff
Show file tree
Hide file tree
Showing 24 changed files with 87 additions and 85 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ jobs:
- name: Black Code Formatter
uses: lgeiger/black-action@v1.0.1
with:
args: "--check --target-version py36 $GITHUB_WORKSPACE"
args: "--check --diff --target-version py36 $GITHUB_WORKSPACE"
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added <!-- for new features -->
- Support for path-like objects as an option wherever filenames are passed in as arguments
- Optional `encoding` parameter in `SubtitlesClip` [#1043]

### Changed <!-- for changes in existing functionality -->

Expand All @@ -35,6 +36,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- When using `VideoClip.write_videofile()` with `write_logfile=True`, errors would not be properly reported [#890]
- `TextClip.list("color")` now returns a list of bytes, not strings [#1119]
- `TextClip.search("colorname", "color")` does not crash with a TypeError [#1119]
- Using `rotate()` with a `ColorClip` no longer crashes [#1139]


## [v1.0.2](https://github.com/zulko/moviepy/tree/v1.0.2) (2020-03-26)
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ Maintainers
.. Software, Tools, Libraries
.. _Pillow: https://pillow.readthedocs.org/en/latest/
.. _Scipy: https://www.scipy.org/
.. _`OpenCV 2.4.6`: https://sourceforge.net/projects/opencvlibrary/files/
.. _`OpenCV 2.4.6`: https://github.com/skvark/opencv-python
.. _Pygame: https://www.pygame.org/download.shtml
.. _Numpy: https://www.scipy.org/install.html
.. _imageio: https://imageio.github.io/
Expand Down
2 changes: 1 addition & 1 deletion docs/FAQ.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ I can't seem to read any video with MoviePy
""""""""""""""""""""""""""""""""""""""""""""""

Known reason: you have a deprecated version of FFMPEG, install a recent version from the
website, not from your OS's repositories ! (see :ref:`install`).
website, not from your OS's repositories! (see :ref:`install`).

Previewing videos make them slower than they are
"""""""""""""""""""""""""""""""""""""""""""""""""
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/compo_from_image.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Placing clips according to a picture
======================================


So how do you do some complex compositing like this ?
So how do you do some complex compositing like this?

.. raw:: html

Expand Down
2 changes: 1 addition & 1 deletion docs/gallery.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Gallery
========

Here are a few projects using MoviePy. The gallery will fill up as more people start using MoviePy (which is currently one year old). If you have a nice project using MoviePy let us know !
Here are a few projects using MoviePy. The gallery will fill up as more people start using MoviePy (which is currently one year old). If you have a nice project using MoviePy let us know!

Videos edited with Moviepy
---------------------------
Expand Down
2 changes: 1 addition & 1 deletion docs/getting_started/compositing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ There are many ways to specify the position: ::
# clip2 is at 40% of the width, 70% of the height of the screen:
clip2.set_position((0.4,0.7), relative=True)

# clip2's position is horizontally centered, and moving down !
# clip2's position is horizontally centered, and moving down!
clip2.set_position(lambda t: ('center', 50+t) )

When indicating the position keep in mind that the ``y`` coordinate has its zero at the top of the picture:
Expand Down
4 changes: 2 additions & 2 deletions docs/getting_started/effects.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ All these effects have in common that they are **not inplace**: they do NOT modi

my_clip = VideoFileClip("some_file.mp4")
my_clip.set_start(t=5) # does nothing, changes are lost
my_new_clip = my_clip.set_start(t=5) # good !
my_new_clip = my_clip.set_start(t=5) # good!

Also, when you write ``clip.resize(width=640)``, it does not immediately applies the effect to all the frames of the clip, but only to the first frame: all the other frames will be resized only when required (that is, when you will write the whole clip to a file of when you will preview it). Said otherwise, creating a new clip is neither time nor memory hungry, all the computations happen during the final rendering.

Expand Down Expand Up @@ -47,7 +47,7 @@ but this is not easy to read. To have a clearer syntax you can use ``clip.fx``:
.fx( effect_2, args2)
.fx( effect_3, args3))

Much better ! There are already many effects implemented in the modules ``moviepy.video.fx`` and ``moviepy.audio.fx``. The fx methods in these modules are automatically applied to the sound and the mask of the clip if it is relevant, so that you don't have to worry about modifying these. For practicality, when you use ``from moviepy.editor import *``, these two modules are loaded as ``vfx`` and ``afx``, so you may write something like ::
Much better! There are already many effects implemented in the modules ``moviepy.video.fx`` and ``moviepy.audio.fx``. The fx methods in these modules are automatically applied to the sound and the mask of the clip if it is relevant, so that you don't have to worry about modifying these. For practicality, when you use ``from moviepy.editor import *``, these two modules are loaded as ``vfx`` and ``afx``, so you may write something like ::
from moviepy.editor import *
clip = (VideoFileClip("myvideo.avi")
Expand Down
4 changes: 2 additions & 2 deletions docs/getting_started/efficient_moviepy.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ The best way to start with MoviePy is to use it with the IPython Notebook: it ma

.. _should_i_use_moviepy_editor:

Should I use ``moviepy.editor`` ?
Should I use ``moviepy.editor``?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Most examples in this documentation use the submodule ``moviepy.editor``, but this submodule is not adapted to all needs so should *you* use it ? Short answer: if you use MoviePy to edit videos *by hand*, use it, but if you use MoviePy inside a larger library or program or webserver, it is better to avoid it and just load the functions that you need.
Most examples in this documentation use the submodule ``moviepy.editor``, but this submodule is not adapted to all needs so should *you* use it? Short answer: if you use MoviePy to edit videos *by hand*, use it, but if you use MoviePy inside a larger library or program or webserver, it is better to avoid it and just load the functions that you need.

The module ``moviepy.editor`` can be loaded using one of the three following methods: ::

Expand Down
4 changes: 2 additions & 2 deletions docs/getting_started/quick_presentation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Quick presentation

This section explains when MoviePy can be used and how it works.

Do I need MoviePy ?
Do I need MoviePy?
~~~~~~~~~~~~~~~~~~~

Here are a few reasons why you may want to edit videos in Python:
Expand Down Expand Up @@ -56,7 +56,7 @@ In a typical MoviePy script, you load video or audio files, modify them, put the
# Overlay the text clip on the first video clip
video = CompositeVideoClip([clip, txt_clip])

# Write the result to a file (many options available !)
# Write the result to a file (many options available!)
video.write_videofile("myHolidays_edited.webm")


Expand Down
8 changes: 4 additions & 4 deletions docs/getting_started/videoclips.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ The following code summarizes the base clips that you can create with moviepy: :
clip = VideoFileClip("my_video_file.mp4") # or .avi, .webm, .gif ...
clip = ImageSequenceClip(['image_file1.jpeg', ...], fps=24)
clip = ImageClip("my_picture.png") # or .jpeg, .tiff, ...
clip = TextClip("Hello !", font="Amiri-Bold", fontsize=70, color="black")
clip = TextClip("Hello!", font="Amiri-Bold", fontsize=70, color="black")
clip = ColorClip(size=(460,380), color=[R,G,B])

# AUDIO CLIPS
clip = AudioFileClip("my_audiofile.mp3") # or .ogg, .wav... or a video !
clip = AudioFileClip("my_audiofile.mp3") # or .ogg, .wav... or a video!
clip = AudioArrayClip(numpy_array, fps=44100) # from a numerical array
clip = AudioClip(make_frame, duration=3) # uses a function make_frame(t)

Expand Down Expand Up @@ -170,8 +170,8 @@ Sometimes it is impossible for MoviePy to guess the ``duration`` attribute of th

# Make a video showing a flower for 5 seconds
my_clip = Image("flower.jpeg") # has infinite duration
my_clip.write_videofile("flower.mp4") # Will fail ! NO DURATION !
my_clip.set_duration(5).write_videofile("flower.mp4") # works !
my_clip.write_videofile("flower.mp4") # Will fail! NO DURATION!
my_clip.set_duration(5).write_videofile("flower.mp4") # works!


Animated GIFs
Expand Down
5 changes: 2 additions & 3 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,14 @@ User Guide
gallery
examples/examples
docker
opencv_instructions
FAQ
advanced_tools/advanced_tools
ref/ref

Contribute !
Contribute!
--------------

MoviePy is an open source software originally written by Zulko_ and released under the MIT licence. It works on Windows, Mac, and Linux, with Python 2 or Python 3. The code is hosted on Github_, where you can push improvements, report bugs and ask for help. There is also a MoviePy forum on Reddit_ and a mailing list on librelist_ .
MoviePy is an open source software originally written by Zulko_ and released under the MIT licence. It works on Windows, Mac, and Linux, with Python 2 or Python 3. The code is hosted on Github_, where you can push improvements, report bugs and ask for help. There is also a MoviePy forum on Reddit_ and a mailing list on librelist_.

.. raw:: html

Expand Down
6 changes: 3 additions & 3 deletions docs/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ If you have neither ``setuptools`` nor ``ez_setup`` installed the command above

(sudo) python setup.py install

MoviePy depends on the Python modules NumPy_, Imageio_, Decorator_, and Proglog_, which will be automatically installed during MoviePy's installation. It should work on Windows/Mac/Linux, with Python 2.7+ and 3 ; if you have trouble installing MoviePy or one of its dependencies, please provide feedback !
MoviePy depends on the Python modules NumPy_, Imageio_, Decorator_, and Proglog_, which will be automatically installed during MoviePy's installation. It should work on Windows/Mac/Linux, with Python 2.7+ and 3 ; if you have trouble installing MoviePy or one of its dependencies, please provide feedback!

MoviePy depends on the software FFMPEG for video reading and writing. You don't need to worry about that, as FFMPEG should be automatically downloaded/installed by ImageIO during your first use of MoviePy (it takes a few seconds). If you want to use a specific version of FFMPEG, you can set the FFMPEG_BINARY environment variable See ``moviepy/config_defaults.py`` for details.

Expand All @@ -29,7 +29,7 @@ Other optional but useful dependencies

ImageMagick_ is not strictly required, only if you want to write texts. It can also be used as a backend for GIFs but you can do GIFs with MoviePy without ImageMagick.

Once you have installed it, ImageMagick will be automatically detected by MoviePy, **except on Windows !**. Windows user, before installing MoviePy by hand, go into the ``moviepy/config_defaults.py`` file and provide the path to the ImageMagick binary called `magick`. It should look like this ::
Once you have installed it, ImageMagick will be automatically detected by MoviePy, **except on Windows!**. Windows user, before installing MoviePy by hand, go into the ``moviepy/config_defaults.py`` file and provide the path to the ImageMagick binary called `magick`. It should look like this ::

IMAGEMAGICK_BINARY = "C:\\Program Files\\ImageMagick_VERSION\\magick.exe"

Expand Down Expand Up @@ -65,6 +65,6 @@ If you are on linux, these packages will likely be in your repos.

.. _Github: https://github.com/Zulko/moviepy
.. _PyPI: https://pypi.python.org/pypi/moviepy
.. _`OpenCV 2.4.6`: https://sourceforge.net/projects/opencvlibrary/files/
.. _`OpenCV 2.4.6`: https://github.com/skvark/opencv-python


35 changes: 0 additions & 35 deletions docs/opencv_instructions.rst

This file was deleted.

2 changes: 1 addition & 1 deletion examples/headblur.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
# Generate the text, put in on a grey background

txt = TextClip(
"Hey you ! \n You're blurry!",
"Hey you! \n You're blurry!",
color="grey70",
size=clip.size,
bg_color="grey20",
Expand Down
2 changes: 1 addition & 1 deletion examples/star_worms.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def trapzWarp(pic, cx, cy, ismask=False):
We will now code the video tutorial for this video.
When you think about it, it is a code for a video explaining how to
make another video using some code (this is so meta !).
make another video using some code (this is so meta!).
This code uses the variables of the previous code (it should be placed
after that previous code to work).
Expand Down
10 changes: 1 addition & 9 deletions ez_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,15 +206,7 @@ def _extractall(self, path=".", members=None):
self.extract(tarinfo, path)

# Reverse sort directories.
if sys.version_info < (2, 4):

def sorter(dir1, dir2):
return cmp(dir1.name, dir2.name)

directories.sort(sorter)
directories.reverse()
else:
directories.sort(key=operator.attrgetter("name"), reverse=True)
directories.sort(key=operator.attrgetter("name"), reverse=True)

# Set correct owner, mtime and filemode on directories.
for tarinfo in directories:
Expand Down
2 changes: 1 addition & 1 deletion moviepy/Clip.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ def set_end(self, t):
return
if self.start is None:
if self.duration is not None:
self.start = max(0, t - newclip.duration)
self.start = max(0, t - self.duration)
else:
self.duration = self.end - self.start

Expand Down
2 changes: 1 addition & 1 deletion moviepy/audio/fx/all/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Loads all the fx !
Loads all the fx!
Usage:
import moviepy.audio.fx.all as afx
audio_clip = afx.volume_x(some_clip, .5)
Expand Down
28 changes: 19 additions & 9 deletions moviepy/video/VideoClip.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
import proglog
from imageio import imread, imsave

from ..Clip import Clip
from ..config import get_setting
from ..decorators import (
from moviepy.Clip import Clip
from moviepy.config import get_setting
from moviepy.decorators import (
add_mask_if_none,
apply_to_mask,
convert_masks_to_RGB,
Expand All @@ -25,14 +25,18 @@
use_clip_fps_by_default,
convert_path_to_string,
)
from ..tools import (
from moviepy.tools import (
extensions_dict,
find_extension,
subprocess_call,
)
from .io.ffmpeg_writer import ffmpeg_write_video
from .io.gif_writers import write_gif, write_gif_with_image_io, write_gif_with_tempfiles
from .tools.drawing import blit
from moviepy.video.io.ffmpeg_writer import ffmpeg_write_video
from moviepy.video.io.gif_writers import (
write_gif,
write_gif_with_image_io,
write_gif_with_tempfiles,
)
from moviepy.video.tools.drawing import blit


class VideoClip(Clip):
Expand Down Expand Up @@ -1237,14 +1241,20 @@ def list(arg):
popen_params["creationflags"] = 0x08000000

process = sp.Popen(
[get_setting("IMAGEMAGICK_BINARY"), "-list", arg], **popen_params
[get_setting("IMAGEMAGICK_BINARY"), "-list", arg],
encoding="utf-8",
**popen_params,
)
result = process.communicate()[0].decode()
result = process.communicate()[0]
lines = result.splitlines()

if arg == "font":
# Slice removes first 8 characters: " Font: "
return [l[8:] for l in lines if l.startswith(" Font:")]
elif arg == "color":
# Each line is of the format "aqua srgb(0,255,255) SVG" so split on space and take
# the first item to get the color name.
# The first 5 lines are header information, not colors, so ignore
return [l.split(" ")[0] for l in lines[5:]]
else:
raise Exception("Moviepy Error: Argument must equal 'font' or 'color'")
Expand Down
5 changes: 4 additions & 1 deletion moviepy/video/fx/rotate.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@
PIL_FOUND = True

def pil_rotater(pic, angle, resample, expand):
# Ensures that pic is of the correct type
return np.array(
Image.fromarray(pic).rotate(angle, expand=expand, resample=resample)
Image.fromarray(np.array(pic).astype(np.uint8)).rotate(
angle, expand=expand, resample=resample
)
)


Expand Down
Loading

0 comments on commit 54751ff

Please sign in to comment.