Skip to content

Commit

Permalink
Merge branch 'master' into set-tempfile-path
Browse files Browse the repository at this point in the history
  • Loading branch information
tburrows13 authored Apr 23, 2020
2 parents 90e85b2 + 24ebfdb commit be1b455
Show file tree
Hide file tree
Showing 24 changed files with 84 additions and 88 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 @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Support removed for Python versions 2.7, 3.4 & 3.5 [#1103, #1106]

### 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]
- Support for path-like objects as an option wherever filenames are passed in as arguments
- New `temp_audiofile_path` parameter in `VideoClip.write_videofile()` to specify where the temporary audiofile should be created
Expand All @@ -37,6 +38,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
6 changes: 3 additions & 3 deletions docs/getting_started/effects.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ 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.
Also, when you write ``clip.resize(width=640)``, it does not immediately apply 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.

Time representations in MoviePy
---------------------------------
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
14 changes: 7 additions & 7 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 All @@ -21,8 +21,8 @@ The module ``moviepy.editor`` can be loaded using one of the three following met
import moviepy.editor as mpy # Clean. Then use mpy.VideoClip, etc.
from moviepy.editor import VideoFileClip # just import what you need

With any of these lines, the ``moviepy.editor`` module will actually do a lot of work behind the curtain: It will fetch all the most common classes, functions and subpackages of MoviePy, initialize a PyGame session (if PyGame is installed) to be able to preview video clips, and implement some shortcuts, like adding the ``resize`` transformation to the clips. This way you can use ``clip.resize(width=240)`` instead of the longer ``clip.fx( resize, width=240)``. In short, ``moviepy.editor``
provides all you need to play around and edit your videos but it will take time to load (circa one second). So if all you need is one or two features inside another library, it is better to import directly what you need, as follows: ::
With any of these lines, the ``moviepy.editor`` module will actually do a lot of work behind the curtain: it will fetch all the most common classes, functions and subpackages of MoviePy, initialize a PyGame session (if PyGame is installed) to be able to preview video clips, and implement some shortcuts, like adding the ``resize`` transformation to the clips. This way you can use ``clip.resize(width=240)`` instead of the longer ``clip.fx( resize, width=240)``. In short, ``moviepy.editor``
provides all you need to play around and edit your videos, but it will take time to load (circa one second). So if all you need is one or two features inside another library, it is better to import directly what you need, as follows: ::
from moviepy.video.io.VideoFileClip import VideoFileClip
from moviepy.video.fx.resize import resize
Expand All @@ -34,13 +34,13 @@ When to close() a clip

When you create some types of clip instances - e.g. ``VideoFileClip`` or ``AudioFileClip`` - MoviePy creates a subprocess and locks the file. In order to release those resources when you are finished you should call the ``close()`` method.

This is more important for more complex applications and it particularly important when running on Windows. While Python's garbage collector should eventually clean it the resources for you, clsing them makes them available earlier.
This is more important for more complex applications and is particularly important when running on Windows. While Python's garbage collector should eventually clean up the resources for you, closing them makes them available earlier.

However, if you close a clip too early, methods on the clip (and any clips derived from it) become unsafe.

So, the rules of thumb are:

* Call ``close()`` on any clip that you **construct** once you have finished using it, and have also finished using any clip that was derived from it.
* Call ``close()`` on any clip that you **construct** once you have finished using it and have also finished using any clip that was derived from it.
* Also close any clips you create through ``AudioFileClip.coreader()``.
* Even if you close a ``CompositeVideoClip`` instance, you still need to close the clips it was created from.
* Otherwise, if you have a clip that was created by deriving it from from another clip (e.g. by calling ``set_mask()``), then generally you shouldn't close it. Closing the original clip will also close the copy.
Expand Down Expand Up @@ -134,4 +134,4 @@ For instance, when you are editing an animated GIF and want to check that it loo
ipython_display(my_clip, autoplay=1, loop=1)

Importantly, ``ipython_display`` actually embeds the clips physically in your notebook. The advantage is that you can move the notebook or put it online and the videos will work. The drawback is that the file size of the notebook can become very large. Depending on your browser, re-computing and displaying at video many times can take some place in the cache and the RAM (it will only be a problem for intensive uses). Restarting your browser solves the problem.
Importantly, ``ipython_display`` actually embeds the clips physically in your notebook. The advantage is that you can move the notebook or put it online and the videos will work. The drawback is that the file size of the notebook can become very large. Depending on your browser, re-computing and displaying at video many times can take some place in the cache and the RAM (it will only be a problem for intensive uses). Restarting your browser solves the problem.
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
2 changes: 1 addition & 1 deletion moviepy/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def subprocess_call(cmd, logger="bar", errorprint=True):
Set logger to None or a custom Proglog logger to avoid printings.
"""
logger = proglog.default_bar_logger(logger)
logger(message='Moviepy - Running:\n>>> "+ " ".join(cmd)')
logger(message="Moviepy - Running:\n>>> " + " ".join(cmd))

popen_params = {"stdout": sp.DEVNULL, "stderr": sp.PIPE, "stdin": sp.DEVNULL}

Expand Down
Loading

0 comments on commit be1b455

Please sign in to comment.