Skip to content

Video editing with Python

Fixing (?) the installation bugs and package dependencies. Using setuptools.

Zulkoa4c75295ae55
diff --git a/README.md b/README.md
deleted file mode 100644
index 89acc195..00000000
--- a/README.md
+++ /dev/null
@@ -1,63 +0,0 @@
-MoviePy
-========
-
-MoviePy is Python module for script-based movie editing, which enables
-basic operations (cuts, concatenations, title insertions) to be done
-in a few lines. It can also be used for advanced compositing.
-
-See the full documentation online at `http://zulko.github.io/moviepy/`_
-
-
-A typical MoviePy script looks like that:
-
- from moviepy import *
-
- # Load myHolidays.mp4 and select the subclip 00:00:50 - 00:00:60
- clip = MovieClip("myHolidays.mp4").subclip(50,60)
-
- # Generate a text clip (many options available ! )
- txt_clip = TextClip("My Holidays 2013",fontsize=70,color='white')
- txt_clip = txt_clip.set_pos(('center','center')).set_duration(10)
-
- # Overlay the text clip above the first clip
- video = CompositeVideoClip(clip.size, [clip, txt_clip])
-
- # write the result to a file in any format
- video.write("myHolidays_edited.avi",fps=25, codec='DIVX')
-
-
-
-Download And Installation
---------------------------
-
-You can `download MoviePy`_ on Github. Just unzip everything in one folder, open a terminal and type ::
-
- sudo python setup.py install
-
-MoviePy is a very small program but it relies on many existing Python libraries that you will need to install first:
-
-- `OpenCV 2.4.6`_ or more recent, to read and write movie files.
-- PyGame_ for video and sound previews
-- `Scipy and Numpy`_, for image and sound manipulation
-- `Scikit Image`_ for advanced image manipulation
-- The Decorator_ module for better code readability
-
-And it needs some external software:
-
-- ffmpeg_, for writing movies and many other useful operations.
-- imageMagick_ for text generation, GIF support, and much more in the future.
-
-All these are normally easy to install (on linux, they will certainly be in your repos).
-
-
-.. _`download MoviePy`: https://github.com/Zulko/moviepy
-.. _`OpenCV 2.4.6`: http://sourceforge.net/projects/opencvlibrary/files/
-.. _Pygame: http://www.pygame.org/download.shtml
-.. _`Scipy and Numpy`: http://www.scipy.org/install.html
-.. _`Scikit Image`: http://scikit-image.org/download.html
-.. _Decorator: https://pypi.python.org/pypi/decorator
-
-
-.. _ffmpeg: http://www.ffmpeg.org/download.html
-.. _imageMagick: http://www.imagemagick.org/script/index.php
-
diff --git a/a__init__.py b/a__init__.py
deleted file mode 100644
index e69de29b..00000000
diff --git a/docs/Makefile b/docs/Makefile
index a1f83541..c077a760 100644
--- a/docs/Makefile
+++ b/docs/Makefile
@@ -2,7 +2,7 @@
#
# You can set these variables from the command line.
-SPHINXOPTS = -E
+SPHINXOPTS =
SPHINXBUILD = sphinx-build
PAPER =
BUILDDIR = ../../docs
diff --git a/docs/first_steps/crash_course.rst b/docs/first_steps/crash_course.rst
index bb2a9166..95a9e8d0 100644
--- a/docs/first_steps/crash_course.rst
+++ b/docs/first_steps/crash_course.rst
@@ -3,16 +3,16 @@ A MoviePy crash-course
In this section we will give you the basics to start editing your videos.
-The central objects of MoviePy are video clips. To compose movies, you start by loading video clips, then you may modify some of these, put them all together, and write the result to a file.
+The central objects of MoviePy are video clips. To compose movies, you start by loading video clips, you modify some of them, put them all together, and write the result to a file.
What is a video clip ?
~~~~~~~~~~~~~~~~~~~~~~~~~~
A video clip is basically an object with a ``get_frame`` attribute. ``get_frame`` is a function which for a given time ``t`` returns a picture of the clip at time ``t`` (more precisely, an array of numbers representing a picture). As an example, to play a clip frame by frame, you can (but you won't have to) write something like that: ::
- while t< clip.duration:
+ while t < clip.duration:
display( clip.get_frame(t) )
- t = t + 1.0/24 # for 24 frames/second
+ t = t + 1.0/24 # for 24 frames/second
A video clip has some fundamental attributes:
@@ -20,65 +20,65 @@ A video clip has some fundamental attributes:
- **The duration**, ``clip.duration``, is the time after which the clip stops playing
- **The soundtrack**, ``clip.sound``, which contains the sound data (an array actually) of the clip. See :ref:`CCaudioClips`
-When you mix several clips together (see :ref:`CompositeVideoClips`), you may have to worry about some other attributes:
+When you put several clips together (see :ref:`CompositeVideoClips`), you may have to worry about some other attributes:
-- **The position** indicates where the clip will appear if you display it as part of a bigger screen.
+- **The position** indicates where the clip will appear if you display it as part of a bigger screen. It is actually a function which for each time ``t`` returns the position ``(x(t),y(t))`` at which the clip must appear.
- **The mask**, ``clip.mask``, is an array of numbers between 0 and 1, a 0 at some position meaning that the pixel at the same position in the picture should not be displayed. If you are not going to do anything complicated, you shouldn't worry about the mask (by default, all video clips have a mask with only ones, meaning that the picture should be completely visible). Just know that ``clip.mask`` is actually... a clip ! More precisely, its method ``clip.mask.get_frame`` returns, for a given time, the mask that should be used when blitting the clip's frame over another picture.
Classes of video clips
~~~~~~~~~~~~~~~~~~~~~~
-Video clips can be created using one of the following commands:
+Video clips can be of one of these sorts:
-- **MovieClips** created with ``MovieClip('myHolidays.mp4')`` are clips read from a movie file.
-- **Image clips** created with ``ImageClip('myPic.png')`` are clips displaying a picture, for an *a priori* infinite duration.
-- **Color clips** created with ``ColorClip((height,width),color=(R,G,B))`` are special ImageClips of a single color.
-- **Text clips** created with ``TextClip('Hello public',font='Impact-Regular')`` are special ImageClips representing a text. They are automatically generated using ImageMagick.
+- ``MovieClip('myHolidays.mp4')`` for clips read from a movie file. See :class:`~VideoClip.MovieClip`.
+- ``ImageClip('myPic.png')`` for clips displaying a picture, for an *a priori* infinite duration. See :class:`~VideoClip.ImageClip`.
+- ``ColorClip((height,width),color=(R,G,B))`` for special ImageClips of a single color. See :class:`~VideoClip.ColorClip`.
+- ``TextClip('Hello public',font='Impact-Regular')`` for special ImageClips representing a text. They are automatically generated using ImageMagick. See :class:`~VideoClip.TextClip`.
-To that list we should add the ``CompositeVideoClips`` that are obtained by mixing several clips together (see :ref:`renderingAClip`).
+To that list we should add the ``CompositeVideoClips`` that are obtained by mixing several clips together (see :ref:`CompositeVideoClips`).
-Finally, a clip can be of the base class :class:`VideoClip`, and have any arbitrary ``get_frame`` method. For instance the following clip represents a 460x320
+Finally, a clip can be of the base class :class:`~VideoClip.VideoClip`, and have any arbitrary ``get_frame`` method. For instance the following clip represents a 460x320
screen, that will go from black (color ``[1,1,1]``) to white (color ``[255,255,255]``) in 255 seconds. ::
import numpy
from moviepy import *
dark_picture = np.ones((320,460,3))
def custom_get_frame(t):
- return min(int(t),255) * dark_picture
+ return min( int(t) , 255 ) * dark_picture
clip = VideoClip().set_get_frame(custom_get_frame)
Modifying a clip
~~~~~~~~~~~~~~~~
-You will find many pre-implemented methods to modify a clip ( see :class:`VideoClip`). For instance ``clip.subclip(15,20)`` returns the part of ``clip`` that is between 20 seconds and 50 seconds, ``clip.resize((heigth,width))`` will change the resolution of the clip, while ``clip.crop`` will enable you to keep only a region of the clip and ``clip.speedx(0.5)`` will make your clip play two times slower. When it is relevant, these methods are also applied to the sound and the mask of the clip, so that you don't have to worry about modifying these.
+You will find many pre-implemented methods to modify a clip in the reference manual. For instance ``clip.subclip(15,20)`` returns the part of ``clip`` that is playing between 15 seconds and 20 seconds, ``clip.resize((width, height))`` will change the resolution of the clip, while ``clip.crop`` will enable you to keep only a region of the clip and ``clip.speedx(0.5)`` will make your clip play two times slower. When it is relevant, these methods are also applied to the sound and the mask of the clip, so that you don't have to worry about modifying these.
-In MoviePy **no modification of a clip occurs inplace**, which means that the result of ``clip.resize``, ``clip.speedx`` etc. will be a new clip and the original clip will be untouched. ::
+In MoviePy **no modification of a clip occurs inplace**, which means that the result of ``clip.resize``, ``clip.speedx``, etc., will be a new clip and the original clip will be untouched. ::
clip = MovieClip('myHolidays.mp4')
clip.resize((460,320)) # ``clip`` is NOT modified
clip = clip.resize((460,320)) # ``clip`` is modified
-Another important aspect is that modified clips are just *special views* of the original clip, they do not carry all the video data with them. Actually, the *real* modifications are only performed when you are rendering the clip (see :ref:`renderingAClip`). The good news is, all the clip objects that you will create through modifications of other clips take virtually no place in the memory and are created instantly.
+Another important aspect is that modified clips are just *special views* of the original clip, they do not carry all the video data with them. Actually, the *real* modifications are only performed when you are rendering the clip (see :ref:`renderingAClip`). This means that all the clip objects that you will create through modifications of other clips take virtually no place in the memory and are created instantly.
-Apart from the pre-implemented modifications, you can modify a clip as you want using filters. You can change the timeline of the clip like this: ::
+Apart from the pre-implemented modifications, you can modify a clip as you want using custom filters. You can change the timeline of the clip like this: ::
modifiedClip1 = myClip.fl_time(lambda t: 3*t)
modifiedClip2 = myClip.fl_time(lambda t: 1+sin(t))
-Now the clip ``modifiedClip1`` plays the same as ``myClip``, only three times faster, while ``modifiedClip2`` will play `myClip`` by oscillating between the times t=0s and t=2s. Note that in the last case you have created a clip of infinite duration (which is not a problem for the moment).
+Now the clip ``modifiedClip1`` plays the same as ``myClip``, only three times faster, while ``modifiedClip2`` will play ``myClip`` by oscillating between the times t=0s and t=2s. Note that in the last case you have created a clip of infinite duration (which is not a problem for the moment).
You can also modify the display of a clip. The following takes a clip and inverts the green and blue channels: ::
- modified clip1 = myClip.fl_image(lambda im: im[:,:,[0,2,1]])
+ modifiedClip = myClip.fl_image(lambda im: im[:,:,[0,2,1]])
Finally, you may want to process the clip by taking into account the time and the picture at the same time. This is possible with ``clip.fl``. The filter must be a function which takes two arguments and returns a picture. the fist argument is a ``get_frame`` method (i.e. a function which given a time returns a picture), and the second argument is the time. ::
modifiedClip = myClip.fl(lambda gf,t: np.minimum(int(t),gf(2*t))
-This one is a little complicated to grasp.
+This last one is a little complicated to grasp. ``modifiedClip`` is now a version of ``myClip``, only two times faster, and with some sort of a fade-in effect.
@@ -96,7 +96,7 @@ Now ``myVideo`` is a clip that plays the clips 1, 2, and 3 one after the other.
Next, you have the composite videoclip: ::
- video = CompositeVideoClip(clip.res, [clip1,clip2,clip3])
+ video = CompositeVideoClip(clip1.size, [clip1,clip2,clip3])
Now ``myVideo`` is a clip that has the size of ``clip1``, and plays ``clip1``, and ``clip2`` *on top of* ``clip1``, and ``clip3`` on top of
``clip1``, and ``clip2``. Of course, if ``clip2`` and ``clip3`` have the same size as ``clip1``, then only ``clip3``, which is on top, will be
@@ -104,17 +104,17 @@ visible in the video... unless ``clip3`` and ``clip2`` have masks which hide pa
You can set the starting time of each clip as follows: ::
- video = CompositeVideoClip(clip.res, [clip1,clip2,clip3])
+ video = CompositeVideoClip(clip.size, [clip1,clip2,clip3])
Because the three clips overlap, we can make them appear with a fading-in effect. Here we go for fadein effects that last 1.5 seconds: ::
- video = CompositeVideoClip(clip.res, [clip1, # starts at t=0
+ video = CompositeVideoClip(clip1.size, [clip1, # starts at t=0
clip2.set_start(50).fadein(1.5),
clip3.set_start(90).fadein(1.5)])
Finally, if ``clip2`` and ``clip3`` are smaller than ``clip1``, you can decide where they will appear: ::
- video = CompositeVideoClip(clip.res,
+ video = CompositeVideoClip(clip1.size,
[clip1,
clip2.set_pos((45,150)),
clip3.set_pos((90,100))])
@@ -166,7 +166,7 @@ To write a clip as a video file, use ::
myClip.to_movie("myEditedMovie.avi",fps=24, codec='raw') # raw movie
myClip.to_movie("myEditedMovie.avi",audio=False) # don't render the audio.
-The codec *DIVX* will produce very light yet good quality movies, while the *raw* codec will produce very large movies with perfect quality.
+The codec *DIVX* will produce very light yet good quality movies, while the *raw* codec will produce very large movies with perfect quality. Many other codecs are available.
.. _CCaudioClips:
diff --git a/docs/forDevelopers.rst b/docs/forDevelopers.rst
index 0d5ad0d6..f5d93a1a 100644
--- a/docs/forDevelopers.rst
+++ b/docs/forDevelopers.rst
@@ -30,7 +30,7 @@ To write a movie, I used to generate pictures of the frames and then put them to
However, I like how you can tune the quality of the movie with ffmpeg, and I can't think of something else to merge sound and image. I know there is a war between ffmpeg/avconv/mencoder. I think ffmpeg is the most spread software. And no, it's not deprecated.
-Movie Rendering
+Movie rendering
~~~~~~~~~~~~~~~~~~~~~~~
For movie previews I am using Pygame instead of the original OpenCV frontend because Pygame
@@ -38,7 +38,7 @@ can also generate sound.
-Movie and Image manimulation
+Movie and image manipulation
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The python package SimpleCV is an attempt at making OpenCV easier to use. It is totally cool, but the OpenCV devs are also trying to make it easier so they always make a lot of changes which break SimpleCV. They use the Python Imaging Library for image processing.
diff --git a/docs/install.rst b/docs/install.rst
index 526e4676..0d3874c7 100644
--- a/docs/install.rst
+++ b/docs/install.rst
@@ -5,7 +5,10 @@ You can `download MoviePy`_ on Github. Just unzip everything in one folder, open
sudo python setup.py install
-MoviePy is a very small program but it relies on many existing Python libraries that you will need to install first:
+
+** This should install the python packages listed below, but NOT OpenCV, which you will have to download manually for the moment. **
+
+MoviePy is a very small program but it relies on many existing Python packages:
- `OpenCV 2.4.6`_ or more recent, to read and write movie files.
- PyGame_ for video and sound previews
@@ -13,7 +16,9 @@ MoviePy is a very small program but it relies on many existing Python libraries
- `Scikit Image`_ for advanced image manipulation
- The Decorator_ module for better code readability
-And it needs some external software:
+
+
+MoviePy also needs some external software:
- ffmpeg_, for writing movies and many other useful operations.
- imageMagick_ for text generation, GIF support, and much more in the future.
diff --git a/moviepy/VideoClip.py b/moviepy/VideoClip.py
index d5f1dca9..5fd65a59 100644
--- a/moviepy/VideoClip.py
+++ b/moviepy/VideoClip.py
@@ -947,9 +947,17 @@ class TextClip(ImageClip):
:param stroke_width: Width of the strocke, in pixels. Can be a float,
like 1.5.
- :param method: 'label' (autosized) or 'caption' (presized, wrapped)
+ :param method: 'label' (the picture will be autosized so as to fit
+ exactly the size) or 'caption' (the text will be drawn in a picture
+ with fixed size (provided with the ``size`` argument) it will be
+ wrapped automatically (sometimes it is buggy, not my fault, complain
+ to the ImageMagick crew) and can be aligned or centered (see
+ parameter ``align``).
- :param align: center | East | West | South | North
+ :param kerning: Changes the default spacing between letters
+
+ :param align: center | East | West | South | North . Will work if
+ ``method`` is set to ``caption``
:param transparent: ``True`` (default) if you want to take into account
the transparency in the image.
diff --git a/setup.py b/setup.py
index 4276a981..a58e6a30 100644
--- a/setup.py
+++ b/setup.py
@@ -1,13 +1,14 @@
#!/usr/bin/env python
-from distutils.core import setup
+from setuptools import setup
+
setup(name='moviepy',
version='0.1',
author='Zulko 2013',
description='Module for script-based video editing',
- long_description=open('README.txt').read(),
+ long_description=open('README.rst').read(),
license='LICENSE.txt',
keywords="movie editing film mixing script-based",
packages=['moviepy'],
- requires = ['scipy','numpy','matplotlib','pygame',
- 'cv2 >=2.4.6','decorator'])
+ install_requires = ['scipy','numpy','matplotlib','pygame',
+ 'scikit-image','decorator', 'cython'])