Skip to content

Video editing with Python

Fixed import bug, created moviepy/all.py, maybe fixed setup.py too

Zulko19a4aa155165
diff --git a/.gitignore b/.gitignore
index 61a16668..5a2209e2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -38,3 +38,7 @@ nosetests.xml
# Temp files
*~
+
+# Pipy codes
+
+.pypirc
diff --git a/MANIFEST.in b/MANIFEST.in
index 2985d188..944f76ad 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -1,2 +1,4 @@
include *.txt
recursive-include docs *.txt
+include *.rst
+recursive-include docs *.rst
diff --git a/README.rst b/README.rst
index 83408b45..01b61642 100644
--- a/README.rst
+++ b/README.rst
@@ -5,7 +5,7 @@ MoviePy is a 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 here_ .
+See the full documentation and demo videos here_ .
A typical MoviePy script looks like that: ::
@@ -30,8 +30,8 @@ Download and Installation
---------------------------
-Core dependencies
-~~~~~~~~~~~~~~~~~~
+Dependencies
+~~~~~~~~~~~~~
MoviePy cannot run without these dependencies:
@@ -43,7 +43,8 @@ Numpy and Decorator will be automatically installed during MoviePy's installatio
Installation with PIP
~~~~~~~~~~~~~~~~~~~~~~
-Coming soon.
+Just type ::
+ sudo pip install moviepy
.. _manual_install:
@@ -63,7 +64,7 @@ Before doing that, you should make sure that MoviePy can locate ffmpeg on your c
(Not so) Optional dependencies
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+-------------------------------
You are not obliged to install these but for many uses MoviePy will scream at you and say that the package or the software is missing. All these dependencies can be installed any time after the installation of MoviePy.
@@ -81,7 +82,7 @@ If you are on linux, these will surely be in your repos.
Installing OpenCV 2.4.6
-'''''''''''''''''''''''''
+------------------------
OpenCV is very optional, its installation is not always simple and I found it to be unstable, be warned. The installation seems easy for Windows. On linux, here is what I found on the Internet:
diff --git a/examples/compo_from_image.py b/examples/compo_from_image.py
index 578d0006..fcbdb313 100644
--- a/examples/compo_from_image.py
+++ b/examples/compo_from_image.py
@@ -1,4 +1,4 @@
-from moviepy import *
+from moviepy.all import *
from moviepy.plugins.segmenting import findObjects
# Load the image specifying the regions.
diff --git a/examples/example_with_sound.py b/examples/example_with_sound.py
index d9590bc8..f431d488 100644
--- a/examples/example_with_sound.py
+++ b/examples/example_with_sound.py
@@ -5,7 +5,7 @@ talking at the same time, because it is actually two scenes of a same
movie put together.
"""
-from moviepy import *
+from moviepy.all import *
from moviepy.video.tools.drawing import color_split
@@ -48,5 +48,5 @@ clip_right.mask = ImageClip(mask, ismask=True)
cc = CompositeVideoClip([clip_right.set_pos('right').fx(afx.volumex, 0.4),
clip_left.set_pos('left').fx(afx.volumex, 0.4)],
size = (W,H))
-
-cc.to_videofile("../../biphone3.avi",fps=24, codec='mpeg4')
+cc.preview()
+#cc.to_videofile("../../biphone3.avi",fps=24, codec='mpeg4')
diff --git a/examples/headblur.py b/examples/headblur.py
index e83740bc..b5596a77 100644
--- a/examples/headblur.py
+++ b/examples/headblur.py
@@ -1,8 +1,7 @@
import pickle
-from moviepy import *
+from moviepy.all import *
from moviepy.video.tools.tracking import manual_tracking, to_fxfy
-import moviepy.video.io.ffmpeg as ffmpeg
# LOAD THE CLIP (subclip 6'51 - 7'01 of a chaplin movie)
diff --git a/examples/masked_credits.py b/examples/masked_credits.py
index a8dad5ce..069bc8b0 100644
--- a/examples/masked_credits.py
+++ b/examples/masked_credits.py
@@ -1,4 +1,4 @@
-from moviepy import *
+from moviepy.all import *
from moviepy.video.tools.credits import credits1
# Load the mountains clip, cut it, slow it down, make it look darker
diff --git a/examples/moving_letters.py b/examples/moving_letters.py
index debbd6b8..cc912510 100644
--- a/examples/moving_letters.py
+++ b/examples/moving_letters.py
@@ -1,6 +1,6 @@
import numpy as np
-from moviepy import *
-from moviepy.plugins.segmenting import findObjects
+from moviepy.all import *
+from moviepy.video.tools.segmenting import findObjects
# WE CREATE THE TEXT THAT IS GOING TO MOVE, WE CENTER IT.
diff --git a/examples/painting_effect.py b/examples/painting_effect.py
index da39a3a5..29df14fb 100644
--- a/examples/painting_effect.py
+++ b/examples/painting_effect.py
@@ -1,6 +1,6 @@
""" requires scikit-image installed (for vfx.painting) """
-from moviepy import *
+from moviepy.all import *
# WE TAKE THE SUBCLIPS WHICH ARE 2 SECONDS BEFORE & AFTER THE FREEZE
diff --git a/examples/soundtrack.py b/examples/soundtrack.py
index 30410d7f..fc4baab1 100644
--- a/examples/soundtrack.py
+++ b/examples/soundtrack.py
@@ -1,5 +1,5 @@
""" A simple test script on how to put a soundtrack to a movie """
-from moviepy import *
+from moviepy.all import *
# We load a movie and replace the sound with some music:
@@ -16,8 +16,5 @@ movie = VideoFileClip("../../videos/dam.mov").\
#soundtrack.subclip(0,25).preview(fps=22050,buffersize=20000)
-movie.fx( vfx.resize, 0.5).\
- set_audio(soundtrack).\
- to_videofile("../../test_soundtrack.avi",
- codec="mpeg4",bitrate="4000k")
+movie.to_videofile("../../test_soundtrack.avi", codec="mpeg4")
diff --git a/examples/star_worms.py b/examples/star_worms.py
index 26b733a0..72d3e7dc 100644
--- a/examples/star_worms.py
+++ b/examples/star_worms.py
@@ -9,7 +9,7 @@ background made of stars. Slight fading effect on the text.
import numpy as np
from skimage import transform as tf
-from moviepy import *
+from moviepy.all import *
from moviepy.video.tools.drawing import color_gradient
diff --git a/examples/the_end.py b/examples/the_end.py
index 5bc784fb..2786b50e 100644
--- a/examples/the_end.py
+++ b/examples/the_end.py
@@ -1,4 +1,4 @@
-from moviepy import *
+from moviepy.all import *
from moviepy.video.tools.drawing import circle
clip = VideoFileClip("../../videos/badl-0006.mov", audio=False).\
diff --git a/examples/ukulele_concerto.py b/examples/ukulele_concerto.py
index aa53cd9a..04612f0f 100644
--- a/examples/ukulele_concerto.py
+++ b/examples/ukulele_concerto.py
@@ -1,4 +1,4 @@
-from moviepy import *
+from moviepy.all import *
# UKULELE CLIP, OBTAINED BY CUTTING AND CROPPING
# RAW FOOTAGE
diff --git a/ez_setup.py b/ez_setup.py
new file mode 100644
index 00000000..25354721
--- /dev/null
+++ b/ez_setup.py
@@ -0,0 +1,258 @@
+#!python
+"""Bootstrap setuptools installation
+
+If you want to use setuptools in your package's setup.py, just include this
+file in the same directory with it, and add this to the top of your setup.py::
+
+ from ez_setup import use_setuptools
+ use_setuptools()
+
+If you want to require a specific version of setuptools, set a download
+mirror, or use an alternate download directory, you can do so by supplying
+the appropriate options to ``use_setuptools()``.
+
+This file can also be run as a script to install or upgrade setuptools.
+"""
+import os
+import shutil
+import sys
+import tempfile
+import tarfile
+import optparse
+import subprocess
+
+from distutils import log
+
+try:
+ from site import USER_SITE
+except ImportError:
+ USER_SITE = None
+
+DEFAULT_VERSION = "0.9.6"
+DEFAULT_URL = "https://pypi.python.org/packages/source/s/setuptools/"
+
+def _python_cmd(*args):
+ args = (sys.executable,) + args
+ return subprocess.call(args) == 0
+
+def _install(tarball, install_args=()):
+ # extracting the tarball
+ tmpdir = tempfile.mkdtemp()
+ log.warn('Extracting in %s', tmpdir)
+ old_wd = os.getcwd()
+ try:
+ os.chdir(tmpdir)
+ tar = tarfile.open(tarball)
+ _extractall(tar)
+ tar.close()
+
+ # going in the directory
+ subdir = os.path.join(tmpdir, os.listdir(tmpdir)[0])
+ os.chdir(subdir)
+ log.warn('Now working in %s', subdir)
+
+ # installing
+ log.warn('Installing Setuptools')
+ if not _python_cmd('setup.py', 'install', *install_args):
+ log.warn('Something went wrong during the installation.')
+ log.warn('See the error message above.')
+ # exitcode will be 2
+ return 2
+ finally:
+ os.chdir(old_wd)
+ shutil.rmtree(tmpdir)
+
+
+def _build_egg(egg, tarball, to_dir):
+ # extracting the tarball
+ tmpdir = tempfile.mkdtemp()
+ log.warn('Extracting in %s', tmpdir)
+ old_wd = os.getcwd()
+ try:
+ os.chdir(tmpdir)
+ tar = tarfile.open(tarball)
+ _extractall(tar)
+ tar.close()
+
+ # going in the directory
+ subdir = os.path.join(tmpdir, os.listdir(tmpdir)[0])
+ os.chdir(subdir)
+ log.warn('Now working in %s', subdir)
+
+ # building an egg
+ log.warn('Building a Setuptools egg in %s', to_dir)
+ _python_cmd('setup.py', '-q', 'bdist_egg', '--dist-dir', to_dir)
+
+ finally:
+ os.chdir(old_wd)
+ shutil.rmtree(tmpdir)
+ # returning the result
+ log.warn(egg)
+ if not os.path.exists(egg):
+ raise IOError('Could not build the egg.')
+
+
+def _do_download(version, download_base, to_dir, download_delay):
+ egg = os.path.join(to_dir, 'setuptools-%s-py%d.%d.egg'
+ % (version, sys.version_info[0], sys.version_info[1]))
+ if not os.path.exists(egg):
+ tarball = download_setuptools(version, download_base,
+ to_dir, download_delay)
+ _build_egg(egg, tarball, to_dir)
+ sys.path.insert(0, egg)
+ import setuptools
+ setuptools.bootstrap_install_from = egg
+
+
+def use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL,
+ to_dir=os.curdir, download_delay=15):
+ # making sure we use the absolute path
+ to_dir = os.path.abspath(to_dir)
+ was_imported = 'pkg_resources' in sys.modules or \
+ 'setuptools' in sys.modules
+ try:
+ import pkg_resources
+ except ImportError:
+ return _do_download(version, download_base, to_dir, download_delay)
+ try:
+ pkg_resources.require("setuptools>=" + version)
+ return
+ except pkg_resources.VersionConflict:
+ e = sys.exc_info()[1]
+ if was_imported:
+ sys.stderr.write(
+ "The required version of setuptools (>=%s) is not available,\n"
+ "and can't be installed while this script is running. Please\n"
+ "install a more recent version first, using\n"
+ "'easy_install -U setuptools'."
+ "\n\n(Currently using %r)\n" % (version, e.args[0]))
+ sys.exit(2)
+ else:
+ del pkg_resources, sys.modules['pkg_resources'] # reload ok
+ return _do_download(version, download_base, to_dir,
+ download_delay)
+ except pkg_resources.DistributionNotFound:
+ return _do_download(version, download_base, to_dir,
+ download_delay)
+
+
+def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL,
+ to_dir=os.curdir, delay=15):
+ """Download setuptools from a specified location and return its filename
+
+ `version` should be a valid setuptools version number that is available
+ as an egg for download under the `download_base` URL (which should end
+ with a '/'). `to_dir` is the directory where the egg will be downloaded.
+ `delay` is the number of seconds to pause before an actual download
+ attempt.
+ """
+ # making sure we use the absolute path
+ to_dir = os.path.abspath(to_dir)
+ try:
+ from urllib.request import urlopen
+ except ImportError:
+ from urllib2 import urlopen
+ tgz_name = "setuptools-%s.tar.gz" % version
+ url = download_base + tgz_name
+ saveto = os.path.join(to_dir, tgz_name)
+ src = dst = None
+ if not os.path.exists(saveto): # Avoid repeated downloads
+ try:
+ log.warn("Downloading %s", url)
+ src = urlopen(url)
+ # Read/write all in one block, so we don't create a corrupt file
+ # if the download is interrupted.
+ data = src.read()
+ dst = open(saveto, "wb")
+ dst.write(data)
+ finally:
+ if src:
+ src.close()
+ if dst:
+ dst.close()
+ return os.path.realpath(saveto)
+
+
+def _extractall(self, path=".", members=None):
+ """Extract all members from the archive to the current working
+ directory and set owner, modification time and permissions on
+ directories afterwards. `path' specifies a different directory
+ to extract to. `members' is optional and must be a subset of the
+ list returned by getmembers().
+ """
+ import copy
+ import operator
+ from tarfile import ExtractError
+ directories = []
+
+ if members is None:
+ members = self
+
+ for tarinfo in members:
+ if tarinfo.isdir():
+ # Extract directories with a safe mode.
+ directories.append(tarinfo)
+ tarinfo = copy.copy(tarinfo)
+ tarinfo.mode = 448 # decimal for oct 0700
+ 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)
+
+ # Set correct owner, mtime and filemode on directories.
+ for tarinfo in directories:
+ dirpath = os.path.join(path, tarinfo.name)
+ try:
+ self.chown(tarinfo, dirpath)
+ self.utime(tarinfo, dirpath)
+ self.chmod(tarinfo, dirpath)
+ except ExtractError:
+ e = sys.exc_info()[1]
+ if self.errorlevel > 1:
+ raise
+ else:
+ self._dbg(1, "tarfile: %s" % e)
+
+
+def _build_install_args(options):
+ """
+ Build the arguments to 'python setup.py install' on the setuptools package
+ """
+ install_args = []
+ if options.user_install:
+ if sys.version_info < (2, 6):
+ log.warn("--user requires Python 2.6 or later")
+ raise SystemExit(1)
+ install_args.append('--user')
+ return install_args
+
+def _parse_args():
+ """
+ Parse the command line for options
+ """
+ parser = optparse.OptionParser()
+ parser.add_option(
+ '--user', dest='user_install', action='store_true', default=False,
+ help='install in user site package (requires Python 2.6 or later)')
+ parser.add_option(
+ '--download-base', dest='download_base', metavar="URL",
+ default=DEFAULT_URL,
+ help='alternative URL from where to download the setuptools package')
+ options, args = parser.parse_args()
+ # positional arguments are ignored
+ return options
+
+def main(version=DEFAULT_VERSION):
+ """Install or upgrade setuptools and EasyInstall"""
+ options = _parse_args()
+ tarball = download_setuptools(download_base=options.download_base)
+ return _install(tarball, _build_install_args(options))
+
+if __name__ == '__main__':
+ sys.exit(main())
diff --git a/moviepy/__init__.py b/moviepy/__init__.py
index 043f7792..8b137891 100644
--- a/moviepy/__init__.py
+++ b/moviepy/__init__.py
@@ -1,20 +1 @@
-from video.io.VideoFileClip import VideoFileClip
-from video.ImageClip import ImageClip, ColorClip, TextClip
-from video.compositing.CompositeVideoClip import CompositeVideoClip
-from video.compositing.concatenate import concatenate
-from audio.io.AudioFileClip import AudioFileClip
-from tools import cvsecs
-import video.fx as vfx
-import video.compositing.transitions as transfx
-import audio.fx as afx
-import video.io.ffmpeg as ffmpeg
-
-
-try:
- import pygame as pg
- pg.init()
- pg.display.set_caption('MoviePy')
-except:
- print ("WARNING: Pygame not found. Previews and many other user" +
- " interfaces will not be enabled.")
diff --git a/moviepy/all.py b/moviepy/all.py
new file mode 100644
index 00000000..83eb64c0
--- /dev/null
+++ b/moviepy/all.py
@@ -0,0 +1,27 @@
+"""
+This file is meant to make it easy to load the main features of MoviePy
+by simply typing: from moviepy.all import *
+"""
+
+# Note that these imports could have been performed in the __init__.py
+# file, but this would make the loading of moviepy slower.
+
+# Clips
+
+from moviepy.video.io.VideoFileClip import VideoFileClip
+from moviepy.video.ImageClip import ImageClip, ColorClip, TextClip
+from moviepy.video.compositing.CompositeVideoClip import CompositeVideoClip
+from moviepy.video.compositing.concatenate import concatenate
+from moviepy.audio.io.AudioFileClip import AudioFileClip
+
+# FX
+
+import moviepy.video.fx as vfx
+import moviepy.audio.fx as afx
+import moviepy.video.compositing.transitions as transfx
+
+# Tools
+
+import moviepy.video.tools as videotools
+import moviepy.video.io.ffmpeg_tools as ffmpeg_tools
+from moviepy.tools import cvsecs
diff --git a/moviepy/audio/io/preview.py b/moviepy/audio/io/preview.py
index 696d91b8..b3f44efe 100644
--- a/moviepy/audio/io/preview.py
+++ b/moviepy/audio/io/preview.py
@@ -1,12 +1,16 @@
import time
import numpy as np
import threading
+import sys
import numpy as np
from moviepy.decorators import requires_duration
import pygame as pg
+pg.init()
+pg.display.set_caption('MoviePy')
+
@requires_duration
def preview(clip, fps=22050, buffersize=50000, nbytes= 2,
audioFlag=None, videoFlag=None):
@@ -47,11 +51,10 @@ def preview(clip, fps=22050, buffersize=50000, nbytes= 2,
videoFlag.wait()
channel = chunk.play()
- t0 = time.time()
for i in range(1,len(pospos)-1):
tt = (1.0/fps)*np.arange(pospos[i],pospos[i+1])
sndarray = clip.to_soundarray(tt,nbytes)
chunk = pg.sndarray.make_sound(sndarray)
+ while channel.get_queue():
+ time.sleep(0.003)
channel.queue(chunk)
- t1 = time.time()
- time.sleep(max(0,tt[i]-Delta- (t1-t0)))
diff --git a/moviepy/audio/io/readers.py b/moviepy/audio/io/readers.py
index c6a2f154..6c8bf493 100644
--- a/moviepy/audio/io/readers.py
+++ b/moviepy/audio/io/readers.py
@@ -80,7 +80,6 @@ class FFMPEG_AudioReader:
self.initialize()
else:
offset = min(1,starttime)
- print "OFFFFSET, start", offset, starttime
cmd = [ FFMPEG_BINARY,
"-ss", "%.05f"%(starttime-offset),
'-i', self.filename, '-vn',
diff --git a/moviepy/video/ImageClip.py b/moviepy/video/ImageClip.py
index 5e22b1a9..0f81476e 100644
--- a/moviepy/video/ImageClip.py
+++ b/moviepy/video/ImageClip.py
@@ -6,9 +6,8 @@ ImageClip, ColorClip, TextClip
import subprocess
import os
import numpy as np
-
-import VideoClip as VC
-import io.readers as readers
+import moviepy.video.VideoClip as VC
+import moviepy.video.io.readers as readers
diff --git a/moviepy/video/VideoClip.py b/moviepy/video/VideoClip.py
index ef1938ba..34608fd5 100644
--- a/moviepy/video/VideoClip.py
+++ b/moviepy/video/VideoClip.py
@@ -19,11 +19,14 @@ import numpy as np
from moviepy.decorators import apply_to_mask, requires_duration
import moviepy.audio.io as aio
-import io.ffmpeg as ffmpeg
-import io as vio
-import ImageClip as ImClip
+import moviepy.video.io.ffmpeg_writer as ffmpeg_writer
+import moviepy.video.io.ffmpeg_tools as ffmpeg_tools
+
+from moviepy.video.tools.drawing import blit
+import moviepy.video.io as vio
from moviepy.Clip import Clip
-from tools.drawing import blit
+
+
@@ -228,8 +231,8 @@ class VideoClip(Clip):
args=(temp_wav,audio_fps,audio_nbytes,
audio_bufsize,verbose))
audioproc.start()
- vio.ffmpeg_write(self, videofile, fps, codec, bitrate=bitrate,
- verbose=verbose)
+ ffmpeg_writer.ffmpeg_write(self, videofile, fps, codec,
+ bitrate=bitrate, verbose=verbose)
audioproc.join()
if audioproc.exitcode:
print ("WARNING: something went wrong with the audio"+
@@ -239,14 +242,15 @@ class VideoClip(Clip):
if make_audio:
self.audio.to_audiofile(temp_wav,audio_fps, audio_nbytes,
audio_bufsize, verbose)
- vio.ffmpeg_write(self, videofile, fps, codec, verbose=verbose)
+ ffmpeg_writer.ffmpeg_write(self, videofile, fps, codec,
+ bitrate=bitrate, verbose=verbose)
# Merge with audio if any and trash temporary files.
if merge_audio:
verbose_print("\nNow merging video and audio...\n")
- vio.ffmpeg.merge_video_audio(videofile,temp_wav,filename,
+ ffmpeg_tools.merge_video_audio(videofile,temp_wav,filename,
ffmpeg_output=False)
if remove_temp:
os.remove(videofile)
@@ -356,7 +360,7 @@ class VideoClip(Clip):
:param constant_size: `False` for clips with moving image size.
"""
if constant_size:
- return self.set_mask(ImClip.ColorClip(self.size, 1.0, ismask=True))
+ return self.set_mask(ColorClip(self.size, 1.0, ismask=True))
else:
mask = VideoClip(ismask=True).set_get_frame(
lambda t: np.ones(self.get_frame(t).shape))
@@ -379,7 +383,7 @@ class VideoClip(Clip):
size = self.size
if pos is None:
pos = 'center'
- colorclip = ImClip.ColorClip(size, color)
+ colorclip = ColorClip(size, color)
if col_opacity:
colorclip = colorclip.add_mask().set_opacity(col_opacity)
@@ -453,7 +457,7 @@ class VideoClip(Clip):
"""
Return an ImageClip made out of the clip's frame at time ``t``
"""
- return ImClip.ImageClip(self.get_frame(t))
+ return ImageClip(self.get_frame(t))
def to_mask(self, canal=0):
""" Returns a mask a video clip made from the clip. """
@@ -496,3 +500,267 @@ try:
VideoClip.show = show
except:
pass
+
+
+
+
+
+"""---------------------------------------------------------------------
+
+ ImageClip (bas class for all 'static clips') and its subclasses
+ ColorClip and TextClip.
+ I would have liked to put these in a separate file but Python is bad
+ at cyclic imports.
+
+---------------------------------------------------------------------"""
+
+
+
+
+"""
+Classes for advantageous handling of static clips.
+ImageClip, ColorClip, TextClip
+"""
+
+
+
+class ImageClip(VideoClip):
+
+ """
+
+ A video clip originating from a picture. This clip will simply
+ display the given picture at all times. For instance:
+
+ >>> clip = ImageClip("myHouse.jpeg")
+ >>> clip = ImageClip( someArray ) # a Numpy array represent
+
+ :param img: Any picture file (png, tiff, jpeg, etc.) or any array
+ representing an RGB image (for instance a frame from a VideoClip
+ or a picture read with scipy of skimage's imread method).
+
+ :param ismask: `True` if the clip is a mask.
+ :param transparent: `True` (default) if you want the alpha layer
+ of the picture (if it exists) to be used as a mask.
+
+ :ivar img: array representing the image of the clip.
+
+ """
+
+ def __init__(self, img, ismask=False, transparent=True, fromalpha=False):
+
+ VideoClip.__init__(self, ismask=ismask)
+
+ if isinstance(img, str):
+ img = vio.readers.read_image(img,with_mask=transparent)
+
+ if len(img.shape) == 3: # img is (now) a RGB(a) numpy array
+
+ if img.shape[2] == 4:
+ if fromalpha:
+ img = 1.0 * img[:, :, 3] / 255
+ elif ismask:
+ img = 1.0 * img[:, :, 0] / 255
+ elif transparent:
+ self.mask = ImageClip(
+ 1.0 * img[:, :, 3] / 255, ismask=True)
+ img = img[:, :, :3]
+ elif ismask:
+ img = 1.0 * img[:, :, 0] / 255
+
+ # if the image was just a 2D mask, it should arrive here unchanged
+ self.get_frame = lambda t: img
+ self.size = img.shape[:2][::-1]
+ self.img = img
+
+ def fl(self, fl, applyto=[], keep_duration=True):
+ """
+ Equivalent to VideoClip.fl . The result is no more an
+ ImageClip, it has the class VideoClip (as it may be animated)
+ """
+ # When we use fl on an image clip it may become animated.
+ #Therefore the result is not an ImageClip, just a VideoClip.
+ newclip = VideoClip.fl(self,fl, applyto=applyto,
+ keep_duration=keep_duration)
+ newclip.__class__ = VideoClip
+ return newclip
+
+ def fl_image(self, image_func, applyto= []):
+ """
+ Similar to VideoClip.fl_image, but for ImageClip the
+ tranformed clip is computed once and for all at the beginning,
+ and not for each 'frame'.
+ """
+
+ newclip = self.copy()
+ arr = image_func(self.get_frame(0))
+ newclip.size = arr.shape[:2][::-1]
+ newclip.get_frame = lambda t: arr
+ newclip.img = arr
+
+ for attr in applyto:
+ if hasattr(newclip, attr):
+ a = getattr(newclip, attr)
+ if a != None:
+ setattr(newclip, attr, a.fl_image(image_func))
+
+ return newclip
+
+ def fl_time(self, applyto =['mask', 'audio']):
+ """
+ This method does nothing for ImageClips (but it may affect their
+ masks of their audios). The result is still an ImageClip
+ """
+ newclip = copy(self, keep_class=True)
+
+ for attr in applyto:
+ if hasattr(newclip, attr):
+ a = getattr(newclip, attr)
+ if a != None:
+ setattr(newclip, attr, a.fl_image(image_func))
+
+ return newclip
+
+
+
+class ColorClip(ImageClip):
+ """
+ An ImageClip showing just one color.
+ :param size: Size (width, height) in pixels of the clip
+ :param color: If argument ``ismask`` is False, ``color`` indicates
+ the color in RGB of the clip (default is black). If `ismask``
+ is True, ``color`` must be a float between 0 and 1 (default is 1)
+ :param ismask: Is the clip a mask clip ?
+ """
+ def __init__(self,size, col=(0, 0, 0), ismask=False):
+ w, h = size
+ shape = (h, w) if np.isscalar(col) else (h, w, len(col))
+ ImageClip.__init__(self, np.tile(col, w * h).reshape(shape),
+ ismask=ismask)
+
+
+
+class TextClip(ImageClip):
+
+ """
+
+ An image clip originating from a script-generated text image.
+ Makes a text PNG using ImageMagick.
+
+ :param txt: either a string, or a filename. If txt is in a file and
+ whose name is ``mytext.txt`` for instance, then txt must be
+ equal to ``@mytext.txt`` .
+
+ :param size: Size of the picture in pixels. Can be auto-set if
+ method='label', but mandatory if method='caption'.
+ the height can be None, it will then be auto-determined.
+
+ :param bg_color: Color of the background. See ``TextClip.list('color')``
+ for a list of acceptable names.
+
+ :param color: Color of the background. See ``TextClip.list('color')``
+ for a list of acceptable names.
+
+ :param font: Name of the font to use. See ``TextClip.list('font')`` for
+ the list of fonts you can use on your computer.
+
+ :param stroke_color: Color of the stroke (=contour line) of the text.
+ if ``None``, there will be no stroke.
+
+ :param stroke_width: Width of the strocke, in pixels. Can be a float,
+ like 1.5.
+
+ :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). If `caption`,
+ the text will be wrapped automagically (sometimes it is buggy, not
+ my fault, complain to the ImageMagick crew) and can be aligned or
+ centered (see parameter ``align``).
+
+ :param kerning: Changes the default spacing between letters. For
+ instance ``kerning=-1`` will make the letters 1 pixel nearer from
+ each other compared to the default spacing.
+
+ :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.
+
+ """
+
+ def __init__(self, txt, size=None, color='black', bg_color='transparent',
+ fontsize=None, font='Times-New-Roman-Regular',
+ stroke_color=None, stroke_width=1, method='label',
+ kerning=None, align='center', interline=None,
+ tempfile='temp.png',
+ temptxt='temp.txt', transparent=True, remove_temp=True,
+ print_cmd=False):
+
+ if not txt.startswith('@'):
+ temptxt = 'temp.txt'
+ with open(temptxt, 'w+') as f:
+ f.write(txt)
+ txt = '@temp.txt'
+ else:
+ txt = "'%s'"%txt
+
+ if size != None:
+ size = ('' if size[0] is None else str(size[0]),
+ '' if size[1] is None else str(size[1]))
+
+ cmd = ( ["convert",
+ "-background", bg_color,
+ "-fill", color,
+ "-font", font])
+
+ if fontsize !=None:
+ cmd += ["-pointsize", "%d"%fontsize]
+ if kerning != None:
+ cmd += ["-kerning", "%0.1f"%kerning]
+ if stroke_color != None:
+ cmd += ["-stroke", stroke_color, "-strokewidth",
+ "%.01f"%stroke_width]
+ if size != None:
+ cmd += ["-size", "%sx%s"%(size[0], size[1])]
+ if align != None:
+ cmd += ["-gravity",align]
+ if interline != None:
+ cmd += ["-interline-spacing", "%d"%interline]
+
+ cmd += ["%s:%s" %(method, txt),
+ "-type", "truecolormatte", tempfile]
+
+ if print_cmd:
+ print " ".join(cmd)
+
+ proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
+ proc.wait()
+ if proc.returncode:
+ print ("Error: problem in the generation of the text file"+
+ "by ImageMagick. Certainly wrong arguments in TextClip")
+ ImageClip.__init__(self, tempfile, transparent=transparent)
+ self.txt = txt
+ self.color = color
+ self.stroke_color = stroke_color
+
+ if remove_temp:
+ os.remove(tempfile)
+ try:
+ os.remove(temptxt)
+ except:
+ pass
+
+ @staticmethod
+ def list(arg):
+ """ Returns the list of all valid entries for the argument given
+ (can be ``font``, ``color``, etc...)
+ argument of ``TextClip`` """
+ process = subprocess.Popen(['convert', '-list', arg],
+ stdout=subprocess.PIPE)
+ result = process.communicate()[0]
+ lines = result.splitlines()
+
+ if arg == 'font':
+ return [l[8:] for l in lines if l.startswith(" Font:")]
+ elif arg == 'color':
+ return [l.split(" ")[1] for l in lines[2:]]
diff --git a/moviepy/video/__init__.py b/moviepy/video/__init__.py
index 65d66813..8b137891 100644
--- a/moviepy/video/__init__.py
+++ b/moviepy/video/__init__.py
@@ -1,12 +1 @@
-#~ from moviepy.video.VideoClip import VideoClip
-from moviepy.video.ImageClip import ImageClip, ColorClip, TextClip
-from io import VideoFileClip
-
-try:
- import pygame as pg
- pg.init()
- pg.display.set_caption('MoviePy')
-except:
- print ("WARNING: Pygame not found. Previews and many other user" +
- " interfaces will not be enabled.")
diff --git a/moviepy/video/compositing/CompositeVideoClip.py b/moviepy/video/compositing/CompositeVideoClip.py
index a9f3d055..e82b09f3 100644
--- a/moviepy/video/compositing/CompositeVideoClip.py
+++ b/moviepy/video/compositing/CompositeVideoClip.py
@@ -1,6 +1,5 @@
import numpy as np
-from moviepy.video.VideoClip import VideoClip
-from moviepy.video.ImageClip import ColorClip
+from moviepy.video.VideoClip import VideoClip, ColorClip
from moviepy.audio.AudioClip import CompositeAudioClip
# CompositeVideoClip
diff --git a/moviepy/video/compositing/concatenate.py b/moviepy/video/compositing/concatenate.py
index 5ce9eb7d..b7e70a6e 100644
--- a/moviepy/video/compositing/concatenate.py
+++ b/moviepy/video/compositing/concatenate.py
@@ -2,7 +2,7 @@ import numpy as np
from moviepy.video.VideoClip import VideoClip
-from CompositeVideoClip import CompositeVideoClip
+from moviepy.video.compositing.CompositeVideoClip import CompositeVideoClip
from moviepy.audio.AudioClip import CompositeAudioClip
from on_color import on_color
@@ -83,7 +83,6 @@ def concatenate(clipslist, method = 'chain', transition=None,
# Compute the audio, if any.
audio_t = [(c.audio,t) for c,t in zip(clipslist,tt) if c.audio!=None]
- print audio_t
if len(audio_t)>0:
result.audio = CompositeAudioClip([a.set_start(t)
for a,t in audio_t])
diff --git a/moviepy/video/fx/blackwhite.py b/moviepy/video/fx/blackwhite.py
index bb9f9f4b..95b101cb 100644
--- a/moviepy/video/fx/blackwhite.py
+++ b/moviepy/video/fx/blackwhite.py
@@ -1,4 +1,3 @@
-
def blackwhite(clip, RGB = [1,1,1], preserve_luminosity=True):
""" Desaturates the picture, makes it black and white.
method = sum (TODO: others) """
diff --git a/moviepy/video/fx/painting.py b/moviepy/video/fx/painting.py
index bcd62d53..85228e6e 100644
--- a/moviepy/video/fx/painting.py
+++ b/moviepy/video/fx/painting.py
@@ -1,3 +1,4 @@
+#------- CHECKING DEPENDENCIES -----------------------------------------
painting_possible = True
try:
from skimage.filter import sobel
@@ -6,7 +7,9 @@ except:
from scipy.ndimage.filters import sobel
except:
painting_possible = False
-
+#-----------------------------------------------------------------------
+
+
import numpy as np
@@ -27,9 +30,14 @@ def painting(clip, saturation = 1.4,black = 0.006):
return clip.fl_image(lambda im : to_painting(im,saturation,black))
+
+#------- OVERWRITE IF REQUIREMENTS NOT MET -----------------------------
+
if not painting_possible:
doc = painting.__doc__
def painting(clip, newsize=None, height=None, width=None):
raise IOError("fx painting needs scikit-image or scipy")
painting.__doc__ = doc
+#-----------------------------------------------------------------------
+
diff --git a/moviepy/video/io/DirectoryClip.py b/moviepy/video/io/DirectoryClip.py
index a25cd065..363afc28 100644
--- a/moviepy/video/io/DirectoryClip.py
+++ b/moviepy/video/io/DirectoryClip.py
@@ -1,8 +1,13 @@
+from moviepy.video.VideoClip import VideoClip
+
+class DirectoryClip(VideoClip)
"""
A VideoClip read from a directory containing pictures.
Still experimental and subject to changes.
+ DEPRECATED - needs update
+
"""
def __init__(self, foldername, fps, transparent=True, ismask=False):
diff --git a/moviepy/video/io/VideoFileClip.py b/moviepy/video/io/VideoFileClip.py
index da139fd3..6f50b7cb 100644
--- a/moviepy/video/io/VideoFileClip.py
+++ b/moviepy/video/io/VideoFileClip.py
@@ -3,7 +3,7 @@ import os
from moviepy.video.VideoClip import VideoClip
from moviepy.audio.io.AudioFileClip import AudioFileClip
from moviepy.Clip import Clip
-from readers import FFMPEG_VideoReader
+from moviepy.video.io.ffmpeg_reader import FFMPEG_VideoReader
class VideoFileClip(VideoClip):
diff --git a/moviepy/video/io/__init__.py b/moviepy/video/io/__init__.py
index cdcd657c..7ad81e6f 100644
--- a/moviepy/video/io/__init__.py
+++ b/moviepy/video/io/__init__.py
@@ -1,8 +1,3 @@
"""
Classes and methods for reading, writing and previewing video files.
"""
-
-import ffmpeg
-
-from writers import ffmpeg_write, write_image
-from readers import FFMPEG_VideoReader
diff --git a/moviepy/video/io/readers.py b/moviepy/video/io/ffmpeg_reader.py
similarity index 99%
rename from moviepy/video/io/readers.py
rename to moviepy/video/io/ffmpeg_reader.py
index d5b97718..919ac850 100644
--- a/moviepy/video/io/readers.py
+++ b/moviepy/video/io/ffmpeg_reader.py
@@ -1,13 +1,9 @@
import subprocess as sp
import re
-import time
import numpy as np
from moviepy.conf import FFMPEG_BINARY
from moviepy.tools import cvsecs
-
-
-
class FFMPEG_VideoReader:
diff --git a/moviepy/video/io/ffmpeg.py b/moviepy/video/io/ffmpeg_tools.py
similarity index 75%
rename from moviepy/video/io/ffmpeg.py
rename to moviepy/video/io/ffmpeg_tools.py
index ea2ac5be..8f5d396f 100644
--- a/moviepy/video/io/ffmpeg.py
+++ b/moviepy/video/io/ffmpeg_tools.py
@@ -1,4 +1,4 @@
-""" Very experimental 'bindings' to ffmpeg and ImageMagick."""
+""" Misc. bindings to ffmpeg and ImageMagick."""
import os
import sys
@@ -59,35 +59,6 @@ def merge_video_audio(video,audio,output, acodec='libvorbis',
return ["ffmpeg", "-y", "-i", audio,"-i", video,
"-vcodec", "copy",
"-acodec", acodec, output]
-
-
-@subprocess_call
-def gif_to_directory(gif_file,dirName=None):
- """
- Stores all the frames of the given .gif file
- into the directory ``dirName``. If ``dirName``
- is not provided, the directory has the same name
- as the .gif file. Supports transparency.
- Returns the directory name.
-
- Example:
-
- >>> d = gif_to_directory("animated-earth.gif")
- >>> clip = DirectoryClip(d,fps=3)
-
- """
-
- if dirName is None:
- name, ext = os.path.splitext(gif_file)
- dirName = name
-
- try:
- os.mkdir(dirName)
- except:
- pass
-
- return ["convert", "-coalesce", gif_file,
- os.path.join(dirName,"%04d.png")]
@subprocess_call
def extract_audio(inputfile,output,bitrate=3000,fps=44100):
diff --git a/moviepy/video/io/writers.py b/moviepy/video/io/ffmpeg_writer.py
similarity index 74%
rename from moviepy/video/io/writers.py
rename to moviepy/video/io/ffmpeg_writer.py
index 812d075f..276d8a92 100644
--- a/moviepy/video/io/writers.py
+++ b/moviepy/video/io/ffmpeg_writer.py
@@ -95,43 +95,4 @@ def write_image(filename, image):
pix_fmt = "rgba" if (image.shape[2] == 4) else "rgb24"
vf = FFMPEG_VideoWriter(filename, pix_fmt='rgba')
vf.writer_frame(image)
- vf.close()
-
-
-# SAFETY WHEEL: opencv writer
- #~
-#~ try:
- #~ import cv2
-#~ except:
- #~ print "OpenCV not found"
-#~ else:
- #~ try:
- #~ FOURCC = cv2.cv.FOURCC
- #~ except:
- #~ try:
- #~ FOURCC = cv2.VideoWriter_fourcc
- #~ except:
- #~ print "Error : unable to find FOURCC in OpenCV."
- #~ raise
-#~
-#~ def opencv_write(clip, filename, fps, codec, verbose=True):
- #~
- #~ if verbose:
- #~ def verbose_print(s):
- #~ sys.stdout.write(s)
- #~ sys.stdout.flush()
- #~ else:
- #~ verbose_print = lambda *a : None
- #~
- #~ verbose_print("Rendering video %s\n"%filename)
- #~ codec = 0 if (codec == 'raw') else FOURCC(*codec)
- #~ writer = cv2.VideoWriter(filename, codec, fps, clip.size)
- #~ i=0
- #~ nframes = clip.duration*fps
- #~ while (i < nframes):
- #~ writer.write(clip.get_frame(1.0*i/fps)[:,:,::-1].astype('uint8'))
- #~ if ((i+1) % (nframes/10)) == 0:
- #~ verbose_print("=")
- #~ i += 1
- #~
- #~ verbose_print("video done !")
+ vf.close()
diff --git a/moviepy/video/io/imageMagick_tools.py b/moviepy/video/io/imageMagick_tools.py
new file mode 100644
index 00000000..c5a9732e
--- /dev/null
+++ b/moviepy/video/io/imageMagick_tools.py
@@ -0,0 +1,27 @@
+@subprocess_call
+def gif_to_directory(gif_file,dirName=None):
+ """
+ Stores all the frames of the given .gif file
+ into the directory ``dirName``. If ``dirName``
+ is not provided, the directory has the same name
+ as the .gif file. Supports transparency.
+ Returns the directory name.
+
+ Example:
+
+ >>> d = gif_to_directory("animated-earth.gif")
+ >>> clip = DirectoryClip(d,fps=3)
+
+ """
+
+ if dirName is None:
+ name, ext = os.path.splitext(gif_file)
+ dirName = name
+
+ try:
+ os.mkdir(dirName)
+ except:
+ pass
+
+ return ["convert", "-coalesce", gif_file,
+ os.path.join(dirName,"%04d.png")]
diff --git a/moviepy/video/io/preview.py b/moviepy/video/io/preview.py
index fedbf992..df2bbc40 100644
--- a/moviepy/video/io/preview.py
+++ b/moviepy/video/io/preview.py
@@ -5,6 +5,9 @@ import pygame as pg
import numpy as np
+pg.init()
+pg.display.set_caption('MoviePy')
+
def imdisplay(imarray, screen=None):
""" splashes the given image array on the given pygame screen """
a = pg.surfarray.make_surface(imarray.swapaxes(0, 1))
@@ -97,8 +100,9 @@ def preview(clip, fps=15, audio=True, audio_fps=22050,
elif event.type == pg.MOUSEBUTTONDOWN:
x,y = pg.mouse.get_pos()
- rgb = img[x,y]
- print "time, position, color : ", t,(x,y),rgb
+ rgb = img[y,x]
+ print "time, position, color : ", "%.03f, %s, %s"%(
+ t,str((x,y)),str(rgb))
t1 = time.time()
time.sleep(max(0, t - (t1-t0)) )
diff --git a/moviepy/video/tools/credits.py b/moviepy/video/tools/credits.py
index 3ef0c166..367549e0 100644
--- a/moviepy/video/tools/credits.py
+++ b/moviepy/video/tools/credits.py
@@ -4,7 +4,8 @@ credits, even though it is difficult to fill everyone needs in this
matter.
"""
-from moviepy import TextClip, ImageClip, CompositeVideoClip
+from moviepy.video.VideoClip import TextClip, ImageClip
+from moviepy.video.compositing.CompositeVideoClip import CompositeVideoClip
from moviepy.video.fx import resize
def credits1(creditfile,width,stretch=30,color='white',
diff --git a/moviepy/video/tools/segmenting.py b/moviepy/video/tools/segmenting.py
index 43055dc9..cccbd798 100644
--- a/moviepy/video/tools/segmenting.py
+++ b/moviepy/video/tools/segmenting.py
@@ -1,6 +1,6 @@
import numpy as np
import scipy.ndimage as ndi
-from moviepy.video import ImageClip
+from moviepy.video.ImageClip import ImageClip
def findObjects(clip,rem_thr=500, preview=False):
diff --git a/output.html b/output.html
new file mode 100644
index 00000000..3097f72a
--- /dev/null
+++ b/output.html
@@ -0,0 +1,426 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<meta name="generator" content="Docutils 0.8.1: http://docutils.sourceforge.net/" />
+<title>MoviePy</title>
+<style type="text/css">
+
+/*
+:Author: David Goodger ([email protected])
+:Id: $Id: html4css1.css 7056 2011-06-17 10:50:48Z milde $
+:Copyright: This stylesheet has been placed in the public domain.
+
+Default cascading style sheet for the HTML output of Docutils.
+
+See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
+customize this style sheet.
+*/
+
+/* used to remove borders from tables and images */
+.borderless, table.borderless td, table.borderless th {
+ border: 0 }
+
+table.borderless td, table.borderless th {
+ /* Override padding for "table.docutils td" with "! important".
+ The right padding separates the table cells. */
+ padding: 0 0.5em 0 0 ! important }
+
+.first {
+ /* Override more specific margin styles with "! important". */
+ margin-top: 0 ! important }
+
+.last, .with-subtitle {
+ margin-bottom: 0 ! important }
+
+.hidden {
+ display: none }
+
+a.toc-backref {
+ text-decoration: none ;
+ color: black }
+
+blockquote.epigraph {
+ margin: 2em 5em ; }
+
+dl.docutils dd {
+ margin-bottom: 0.5em }
+
+object[type="image/svg+xml"], object[type="application/x-shockwave-flash"] {
+ overflow: hidden;
+}
+
+/* Uncomment (and remove this text!) to get bold-faced definition list terms
+dl.docutils dt {
+ font-weight: bold }
+*/
+
+div.abstract {
+ margin: 2em 5em }
+
+div.abstract p.topic-title {
+ font-weight: bold ;
+ text-align: center }
+
+div.admonition, div.attention, div.caution, div.danger, div.error,
+div.hint, div.important, div.note, div.tip, div.warning {
+ margin: 2em ;
+ border: medium outset ;
+ padding: 1em }
+
+div.admonition p.admonition-title, div.hint p.admonition-title,
+div.important p.admonition-title, div.note p.admonition-title,
+div.tip p.admonition-title {
+ font-weight: bold ;
+ font-family: sans-serif }
+
+div.attention p.admonition-title, div.caution p.admonition-title,
+div.danger p.admonition-title, div.error p.admonition-title,
+div.warning p.admonition-title {
+ color: red ;
+ font-weight: bold ;
+ font-family: sans-serif }
+
+/* Uncomment (and remove this text!) to get reduced vertical space in
+ compound paragraphs.
+div.compound .compound-first, div.compound .compound-middle {
+ margin-bottom: 0.5em }
+
+div.compound .compound-last, div.compound .compound-middle {
+ margin-top: 0.5em }
+*/
+
+div.dedication {
+ margin: 2em 5em ;
+ text-align: center ;
+ font-style: italic }
+
+div.dedication p.topic-title {
+ font-weight: bold ;
+ font-style: normal }
+
+div.figure {
+ margin-left: 2em ;
+ margin-right: 2em }
+
+div.footer, div.header {
+ clear: both;
+ font-size: smaller }
+
+div.line-block {
+ display: block ;
+ margin-top: 1em ;
+ margin-bottom: 1em }
+
+div.line-block div.line-block {
+ margin-top: 0 ;
+ margin-bottom: 0 ;
+ margin-left: 1.5em }
+
+div.sidebar {
+ margin: 0 0 0.5em 1em ;
+ border: medium outset ;
+ padding: 1em ;
+ background-color: #ffffee ;
+ width: 40% ;
+ float: right ;
+ clear: right }
+
+div.sidebar p.rubric {
+ font-family: sans-serif ;
+ font-size: medium }
+
+div.system-messages {
+ margin: 5em }
+
+div.system-messages h1 {
+ color: red }
+
+div.system-message {
+ border: medium outset ;
+ padding: 1em }
+
+div.system-message p.system-message-title {
+ color: red ;
+ font-weight: bold }
+
+div.topic {
+ margin: 2em }
+
+h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
+h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
+ margin-top: 0.4em }
+
+h1.title {
+ text-align: center }
+
+h2.subtitle {
+ text-align: center }
+
+hr.docutils {
+ width: 75% }
+
+img.align-left, .figure.align-left, object.align-left {
+ clear: left ;
+ float: left ;
+ margin-right: 1em }
+
+img.align-right, .figure.align-right, object.align-right {
+ clear: right ;
+ float: right ;
+ margin-left: 1em }
+
+img.align-center, .figure.align-center, object.align-center {
+ display: block;
+ margin-left: auto;
+ margin-right: auto;
+}
+
+.align-left {
+ text-align: left }
+
+.align-center {
+ clear: both ;
+ text-align: center }
+
+.align-right {
+ text-align: right }
+
+/* reset inner alignment in figures */
+div.align-right {
+ text-align: inherit }
+
+/* div.align-center * { */
+/* text-align: left } */
+
+ol.simple, ul.simple {
+ margin-bottom: 1em }
+
+ol.arabic {
+ list-style: decimal }
+
+ol.loweralpha {
+ list-style: lower-alpha }
+
+ol.upperalpha {
+ list-style: upper-alpha }
+
+ol.lowerroman {
+ list-style: lower-roman }
+
+ol.upperroman {
+ list-style: upper-roman }
+
+p.attribution {
+ text-align: right ;
+ margin-left: 50% }
+
+p.caption {
+ font-style: italic }
+
+p.credits {
+ font-style: italic ;
+ font-size: smaller }
+
+p.label {
+ white-space: nowrap }
+
+p.rubric {
+ font-weight: bold ;
+ font-size: larger ;
+ color: maroon ;
+ text-align: center }
+
+p.sidebar-title {
+ font-family: sans-serif ;
+ font-weight: bold ;
+ font-size: larger }
+
+p.sidebar-subtitle {
+ font-family: sans-serif ;
+ font-weight: bold }
+
+p.topic-title {
+ font-weight: bold }
+
+pre.address {
+ margin-bottom: 0 ;
+ margin-top: 0 ;
+ font: inherit }
+
+pre.literal-block, pre.doctest-block, pre.math {
+ margin-left: 2em ;
+ margin-right: 2em }
+
+span.classifier {
+ font-family: sans-serif ;
+ font-style: oblique }
+
+span.classifier-delimiter {
+ font-family: sans-serif ;
+ font-weight: bold }
+
+span.interpreted {
+ font-family: sans-serif }
+
+span.option {
+ white-space: nowrap }
+
+span.pre {
+ white-space: pre }
+
+span.problematic {
+ color: red }
+
+span.section-subtitle {
+ /* font-size relative to parent (h1..h6 element) */
+ font-size: 80% }
+
+table.citation {
+ border-left: solid 1px gray;
+ margin-left: 1px }
+
+table.docinfo {
+ margin: 2em 4em }
+
+table.docutils {
+ margin-top: 0.5em ;
+ margin-bottom: 0.5em }
+
+table.footnote {
+ border-left: solid 1px black;
+ margin-left: 1px }
+
+table.docutils td, table.docutils th,
+table.docinfo td, table.docinfo th {
+ padding-left: 0.5em ;
+ padding-right: 0.5em ;
+ vertical-align: top }
+
+table.docutils th.field-name, table.docinfo th.docinfo-name {
+ font-weight: bold ;
+ text-align: left ;
+ white-space: nowrap ;
+ padding-left: 0 }
+
+h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
+h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
+ font-size: 100% }
+
+ul.auto-toc {
+ list-style-type: none }
+
+</style>
+</head>
+<body>
+<div class="document" id="moviepy">
+<h1 class="title">MoviePy</h1>
+
+<p>MoviePy is a 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.</p>
+<p>See the full documentation and demo videos <a class="reference external" href="http://zulko.github.io/moviepy/">here</a> .</p>
+<p>A typical MoviePy script looks like that:</p>
+<pre class="literal-block">
+from moviepy import *
+
+# Load myHolidays.mp4 and select the subclip 00:00:50 - 00:00:60
+clip =VideoFileClip(&quot;myHolidays.mp4&quot;).subclip(50,60)
+
+# Generate a text clip (many options available ! )
+txt_clip = TextClip(&quot;My Holidays 2013&quot;,fontsize=70,color='white')
+txt_clip = txt_clip.set_pos('center').set_duration(10)
+
+# Overlay the text clip above the first clip
+final_clip = CompositeVideoClip([clip, txt_clip])
+
+# write the result to a file in any format
+final_clip.to_videofile(&quot;myHolidays_edited.avi&quot;,fps=25, codec='mpeg4')
+</pre>
+<div class="section" id="download-and-installation">
+<h1>Download and Installation</h1>
+<div class="section" id="dependencies">
+<h2>Dependencies</h2>
+<p>MoviePy cannot run without these dependencies:</p>
+<ul class="simple">
+<li>The software <a class="reference external" href="http://www.ffmpeg.org/download.html">ffmpeg</a> is needed for writing, reading, converting the sound and the video. Normally any version of FFMPEG should work but it is recommended to use a recent version for better results.</li>
+<li><a class="reference external" href="http://www.scipy.org/install.html">Numpy</a> is needed for image and sound manipulation</li>
+<li>The <a class="reference external" href="https://pypi.python.org/pypi/decorator">Decorator</a> module is used in the MoviePy code for better code readability</li>
+</ul>
+<p>Numpy and Decorator will be automatically installed during MoviePy's installation if not present on your computer. As for ffmpeg, you can either install it or save the binary files in any folder and specify the path to these folders before installing MoviePy (see <a class="reference internal" href="#manual-install">manual_install</a>).</p>
+</div>
+<div class="section" id="installation-with-pip">
+<h2>Installation with PIP</h2>
+<p>Coming soon.</p>
+</div>
+<div class="section" id="manual-installation">
+<span id="manual-install"></span><h2>Manual installation</h2>
+<p>If you want the cutting edge version you can <a class="reference external" href="https://github.com/Zulko/moviepy">download MoviePy</a> on its Github repository.</p>
+<p>Just unzip everything in one folder, open a terminal and type</p>
+<pre class="literal-block">
+sudo python setup.py install
+</pre>
+<p>Before doing that, you should make sure that MoviePy can locate ffmpeg on your computer. To do that, run the script <tt class="docutils literal">moviepy/conf.py</tt>. It it fails, then you must enter the path in the first line of this file</p>
+<pre class="literal-block">
+FFMPEG_BINARY = path/to/your/ffmpeg
+</pre>
+</div>
+</div>
+<div class="section" id="not-so-optional-dependencies">
+<h1>(Not so) Optional dependencies</h1>
+<p>You are not obliged to install these but for many uses MoviePy will scream at you and say that the package or the software is missing. All these dependencies can be installed any time after the installation of MoviePy.</p>
+<ul class="simple">
+<li><a class="reference external" href="http://www.pygame.org/download.shtml">PyGame</a> is needed for video and sound previews (really essential for advanced editing).</li>
+<li><a class="reference external" href="http://www.imagemagick.org/script/index.php">imageMagick</a> is needed for all text generation, GIF support, and much more in the future.</li>
+</ul>
+<p>There are many packages for image manipulation/processing in python. Most effects are coded such that none of these packages are needed, or such that having at least one of these packages is sufficient.</p>
+<ul class="simple">
+<li>Scipy is needed for many advanced functionalities (tracking, segmenting, etc.)</li>
+<li><a class="reference external" href="http://scikit-image.org/download.html">Scikit Image</a> may be needed for some advanced image manipulation.</li>
+<li>The Python Imaging Library is not used yet (I don't like the copyright) but it is coming.</li>
+<li><a class="reference external" href="http://sourceforge.net/projects/opencvlibrary/files/">OpenCV 2.4.6</a> (which provides the python package <tt class="docutils literal">cv2</tt>) or more recent may be needed for some advanced image manipulation. See below for the installation of OpenCV.</li>
+</ul>
+<p>If you are on linux, these will surely be in your repos.</p>
+</div>
+<div class="section" id="installing-opencv-2-4-6">
+<h1>Installing OpenCV 2.4.6</h1>
+<p>OpenCV is very optional, its installation is not always simple and I found it to be unstable, be warned. The installation seems easy for Windows. On linux, here is what I found on the Internet:</p>
+<ul>
+<li><p class="first">Remove any other version of OpenCV if you installed it through a package manager.</p>
+</li>
+<li><p class="first">Unzip the source code of <a class="reference external" href="http://sourceforge.net/projects/opencvlibrary/files/">OpenCV 2.4.6</a> in some folder. open a terminal in this folder.</p>
+</li>
+<li><p class="first">Make a new directory and go into this directory:</p>
+<pre class="literal-block">
+mkdir release
+cd release
+</pre>
+</li>
+<li><p class="first">Run <tt class="docutils literal">cmake</tt>. Here is the line I used:</p>
+<pre class="literal-block">
+cmake -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=OFF -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON ..
+</pre>
+</li>
+<li><p class="first">Run <tt class="docutils literal">make</tt>. This may take a few minutes (15 minutes on my computer).</p>
+<pre class="literal-block">
+make
+</pre>
+</li>
+<li><p class="first">Finally, install.</p>
+<pre class="literal-block">
+sudo make install
+</pre>
+</li>
+</ul>
+<p>And voilà !</p>
+<p>You can check if it worked by opeing a Python console and typing</p>
+<pre class="literal-block">
+import cv2
+print cv2.__version__
+</pre>
+<p>Advice: do not throw your <tt class="docutils literal">release</tt> folder away. If later you have strange bugs with OpenCV involving <tt class="docutils literal">.so</tt> files, just redo the <tt class="docutils literal">sudo make install</tt> step.</p>
+</div>
+</div>
+</body>
+</html>
diff --git a/setup.py b/setup.py
index d58e32b3..e4c7d8c8 100644
--- a/setup.py
+++ b/setup.py
@@ -1,13 +1,16 @@
#!/usr/bin/env python
-from setuptools import setup
+import ez_setup
+ez_setup.use_setuptools()
+
+from setuptools import setup, find_packages
setup(name='moviepy',
- version='0.2',
+ version='0.2.1.1',
author='Zulko 2013',
description='Module for script-based video editing',
long_description=open('README.rst').read(),
license='LICENSE.txt',
keywords="movie editing film mixing script-based",
- packages=['moviepy'],
+ packages= find_packages(),
install_requires = ['numpy','decorator','scipy','pygame'])