Skip to content

Commit

Permalink
Update (#3)
Browse files Browse the repository at this point in the history
* Fixed copy-paste typo

Changed documentation for the color parameter to distinguish from bg_color

* Fixed missing list

(using python 3)

* fixed module hierarchy for Trajectory

* fixed addy

* small recipe

* on_color function docstring has wrong parameter

The docstring for the on_color method has a parameter of bg_color but
the function uses color as the parameter.

* Update README.rst

Changed Code Block to use Python Syntax Highlighting

* fix deprecation message

currently, the docstring is nonsense. 

```
The function ``concatenate_videoclips`` is deprecated and is kept temporarily for backwards compatibility.
Please use the new name, ``concatenate_videoclips``, instead.
```

* ImageSequenceClip: Check for fps and durations rather than fps and duration

* Add a test case.

* Add another test

* ensures int arguments to np.reshape; closes Zulko#383

* fix issue Zulko#401

*  fix issue Zulko#335

* Update maintainer section in README

* make concatenate_videoclips Python 3 compatible..  fix issue Zulko#313

* Increment release version

* CompositeVideoClip doesn't accept an argument of transparent

* move PY3 variable to compat.py

* fix movie => moviepy typo

* fix issue Zulko#341

* Fixed typo Zulko#375

Zulko#375 fixed

* fix issue Zulko#357, which makes real problem more obvious (media file does not exist

* Revert "small recipe (mirroring a video)"

* Fixed indentation

* .gitignore ignore Mac-specific files, Jetbrains settings dir

* README.rst make mention of Gitter, add PyPI and Gitter badge

* README.rst wording, formatting

* README.rst structure link targets, add co-maintainers (with @username)

* README.rst move maintainers, contributing sections; change docs x-reference name

* README.rst fix grammar

* fix issue 145.  raise Exception when concatenate method != chain or compose

* make PEP8 compatible

* fix PR Zulko#413 . (issue Zulko#357)

* create test for issue Zulko#145

* add tests/media to .gitignore

* fix Issue Zulko#385 ,  no DirectoryClip class (Zulko#434)

* fix issue Zulko#385 , no DirectoryClip class

* replace DirectoryClip with ImageSequenceClip

* fix issue 417, unicode has no attribute 'shape' error.

* add test for issue 417

* add test for issue 417

* Fixed resize documentation issue Zulko#319 (Zulko#346)

* Handle bytes when listing fonts in VideoClip.py (Zulko#306)

Handle bytes when listing fonts in VideoClip.py

* add test for PR306

* add test for PR306 (Zulko#440)

* create test file for pull requests (Zulko#433)

* Test issue 407 (video has a valid fps after concatenate function) (Zulko#443)

* Move PR test to test_PR.py file (Zulko#444)

* move PR test from test_issues.py to test_PR.py

* add code to download python_logo.png

* remove duplicate test_issue_417 function

* add testing with travis-ci (Zulko#447)

added testing via travis-ci

* put DEVNULL into compat.py (Zulko#432)

* add travis-ci badge to readme file

* pick highest fps when concatenating (Zulko#416)

* readers.py cast chunksize from float to int

* choose highest fps of clips when concatenating

* pick highest fps when concatenating

* pick highest fps when concatenating

* fps either max or none

* remove resolve markers

removed resolve markers such as HEAD, etc so that the file will compile correctly.
Remove some double blank lines, etc

* update concatenate.py; add c.fps is not None

* add test for issue 416

* fix test_issue_416
  • Loading branch information
Gloin1313 committed Feb 27, 2017
1 parent acfe6dc commit 25ed5a4
Show file tree
Hide file tree
Showing 25 changed files with 298 additions and 155 deletions.
10 changes: 8 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,15 @@ nosetests.xml
.pydevproject

# Temp files

*~

# Pipy codes

.pypirc

# Mac
.DS_Store

# JetBrains
.idea

tests/media
16 changes: 16 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
language: python
python:
- "2.7"
- "3.3"
- "3.4"
- "3.5"
- "3.6"
# command to install dependencies
before_install:
- sudo apt-get -qq update
- sudo apt-get install -y ffmpeg
- mkdir media
install:
- python setup.py install
# command to run tests
script: py.test
105 changes: 66 additions & 39 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
MoviePy
========

MoviePy (full documentation here_) is a Python module for video editing: cuts, concatenations, title insertions, video compositing (a.k.a. non-linear editing), video processing, and creation of custom effects. See the gallery_ for some examples of use.
=======

.. image:: https://badge.fury.io/py/moviepy.svg
:target: PyPI_
:alt: MoviePy page on the Python Package Index
.. image:: https://badges.gitter.im/movie-py/gitter.png
:target: Gitter_
:alt: Discuss MoviePy on Gitter
.. image:: https://travis-ci.org/Zulko/moviepy.svg?branch=master
:target: https://travis-ci.org/Zulko/moviepy
:alt: Build status on travis-ci

MoviePy (full documentation_) is a Python module for video editing: cutting, concatenations, title insertions, video compositing (a.k.a. non-linear editing), video processing, and creation of custom effects. See the gallery_ for some examples of use.

MoviePy can read and write all the most common audio and video formats, including GIF, and runs on Windows/Mac/Linux, with Python 2.7+ and 3. Here it is in action in an IPython notebook:

Expand All @@ -10,9 +20,11 @@ MoviePy can read and write all the most common audio and video formats, includin
:align: center

Example
--------
-------

In this example we open a video file, select the subclip between t=50s and t=60s, add a title at the center of the screen, and write the result to a new file:

In this example we open a video file, select the subclip between t=50s and t=60s, add a title at the center of the screen, and write the result to a new file: ::
.. code:: python
from moviepy.editor import *
Expand All @@ -27,76 +39,91 @@ In this example we open a video file, select the subclip between t=50s and t=60s
result.write_videofile("myHolidays_edited.webm",fps=25) # Many options...
Installation
------------

Contribute !
-------------
MoviePy depends on the Python modules Numpy_, imageio_, Decorator_, and tqdm_, which will be automatically installed during MoviePy's installation. The software FFMPEG should be automatically downloaded/installed (by imageio) during your first use of MoviePy (installation will take a few seconds). If you want to use a specific version of FFMPEG, follow the instructions in ``config_defaults.py``. In case of trouble, provide feedback.

MoviePy is an open-source software originally written by Zulko_ and released under the MIT licence. The project is hosted on Github_ , where everyone is welcome to contribute, ask for help or simply give feedback.
**Installation by hand:** download the sources, either from PyPI_ or, if you want the development version, from Github_, unzip everything into one folder, open a terminal and type: ::

You can also discuss about the project on Reddit_ or on the mailing list moviepy@librelist.com .
$ (sudo) python setup.py install

**Installation with pip:** if you have ``pip`` installed, just type this in a terminal: ::

Maintainers
--------------
$ (sudo) pip install moviepy

- [Zulko](https://github.com/Zulko/) - Owner
- [mbeacom](https://github.com/mbeacom/)
If you have neither ``setuptools`` nor ``ez_setup`` installed, the command above will fail. In this case type this before installing: ::

$ (sudo) pip install ez_setup

Installation
---------------

MoviePy depends on the Python modules Numpy_, imageio_, Decorator_, and tqdm_, which will be automatically installed during MoviePy's installation. The software 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, follow the instructions in file ``config_defaults.py``. In case of trouble, provide feedback.
Optional but useful dependencies
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

**Installation by hand:** download the sources, either on PyPI_ or (if you want the development version) on Github_, unzip everything in one folder, open a terminal and type ::
ImageMagick_ is not strictly required, but needed if you want to incorporate texts. It can also be used as a backend for GIFs, though you can also create GIFs with MoviePy without ImageMagick.

(sudo) python setup.py install
Once you have installed ImageMagick, it will be automatically detected by MoviePy, **except on Windows!**. Windows users, before installing MoviePy by hand, need to edit ``moviepy/config_defaults.py`` to provide the path to the ImageMagick binary, which is called `convert`. It should look like this ::

**Installation with pip:** if you have ``pip`` installed, just type this in a terminal: ::
IMAGEMAGICK_BINARY = "C:\\Program Files\\ImageMagick_VERSION\\convert.exe"

(sudo) pip install moviepy
PyGame_ is needed for video and sound previews (not relevant if you intend to work with MoviePy on a server but essential for advanced video editing by hand).

If you have neither ``setuptools`` nor ``ez_setup`` installed the command above will fail, is this case type this before installing: ::
For advanced image processing, you will need one or several of the following packages:

(sudo) pip install ez_setup
- The Python Imaging Library (PIL) or, even better, its branch Pillow_.
- Scipy_ (for tracking, segmenting, etc.) can be used to resize video clips if PIL and OpenCV are not installed.
- `Scikit Image`_ may be needed for some advanced image manipulation.
- `OpenCV 2.4.6`_ or a more recent version (one that provides the package ``cv2``) may be needed for some advanced image manipulation.

For instance, using the method ``clip.resize`` requires that at least one of Scipy, PIL, Pillow or OpenCV is installed.

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.
Contribute
----------

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 `convert`. It should look like this ::
MoviePy is open-source software originally written by Zulko_ and released under the MIT licence. The project is hosted on Github_, where everyone is welcome to contribute, ask for help or simply give feedback.

You can also discuss the project on Reddit_ (preferred over GitHub issues for usage/examples), Gitter_ or the mailing list moviepy@librelist.com.

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

PyGame_ is needed for video and sound previews (useless if you intend to work with MoviePy on a server but really essential for advanced video editing *by hand*).
Maintainers
-----------

For advanced image processing you will need one or several of these packages. For instance using the method ``clip.resize`` requires that at least one of Scipy, PIL, Pillow or OpenCV are installed.
- Zulko_ (owner)

- The Python Imaging Library (PIL) or, better, its branch Pillow_ .
- Scipy_ (for tracking, segmenting, etc.), and can be used for resizing video clips if PIL and OpenCV aren't installed on your computer.
- `Scikit Image`_ may be needed for some advanced image manipulation.
- `OpenCV 2.4.6`_ or more recent (which provides the package ``cv2``) may be needed for some advanced image manipulation.
- `@Gloin1313`_
- `@earney`_
- Kay `@kerstin`_
- `@mbeacom`_


.. MoviePy links
.. _gallery: http://zulko.github.io/moviepy/gallery.html
.. _documentation: http://zulko.github.io/moviepy/
.. _`download MoviePy`: https://github.com/Zulko/moviepy

.. Websites, Platforms
.. _Reddit: http://www.reddit.com/r/moviepy/
.. _PyPI: https://pypi.python.org/pypi/moviepy
.. _Pillow: http://pillow.readthedocs.org/en/latest/
.. _Zulko : https://github.com/Zulko
.. _Github: https://github.com/Zulko/moviepy
.. _here: http://zulko.github.io/moviepy/
.. _Gitter: https://gitter.im/movie-py/Lobby

.. Software, Tools, Libraries
.. _Pillow: http://pillow.readthedocs.org/en/latest/
.. _Scipy: http://www.scipy.org/
.. _`download MoviePy`: https://github.com/Zulko/moviepy
.. _`OpenCV 2.4.6`: http://sourceforge.net/projects/opencvlibrary/files/
.. _Pygame: http://www.pygame.org/download.shtml
.. _Numpy: http://www.scipy.org/install.html
.. _imageio: http://imageio.github.io/
.. _`Scikit Image`: http://scikit-image.org/download.html
.. _Decorator: https://pypi.python.org/pypi/decorator
.. _tqdm: https://github.com/noamraph/tqdm


.. _ffmpeg: http://www.ffmpeg.org/download.html
.. _ImageMagick: http://www.imagemagick.org/script/index.php

.. People
.. _Zulko: https://github.com/Zulko
.. _`@Gloin1313`: https://github.com/Gloin1313
.. _`@earney`: https://github.com/earney
.. _`@kerstin`: https://github.com/kerstin
.. _`@mbeacom`: https://github.com/mbeacom
2 changes: 1 addition & 1 deletion examples/moving_letters.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
txtClip = TextClip('Cool effect',color='white', font="Amiri-Bold",
kerning = 5, fontsize=100)
cvc = CompositeVideoClip( [txtClip.set_pos('center')],
size=screensize, transparent=True)
size=screensize)

# THE NEXT FOUR FUNCTIONS DEFINE FOUR WAYS OF MOVING THE LETTERS

Expand Down
4 changes: 4 additions & 0 deletions moviepy/Clip.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,10 @@ def subclip(self, t_start=0, t_end=None):
they exist.
"""

if t_start < 0: #make this more python like a negative value
#means to move backward from the end of the clip
t_start = self.duration + t_start #remeber t_start is negative

if (self.duration is not None) and (t_start>self.duration):

raise ValueError("t_start (%.02f) "%t_start +
Expand Down
17 changes: 9 additions & 8 deletions moviepy/audio/io/ffmpeg_audiowriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@
import numpy as np
import subprocess as sp

from moviepy.compat import PY3, DEVNULL

import os
try:
from subprocess import DEVNULL # py3k
except ImportError:
DEVNULL = open(os.devnull, 'wb')

from tqdm import tqdm
from moviepy.config import get_setting
Expand Down Expand Up @@ -82,14 +80,17 @@ def __init__(self, filename, fps_input, nbytes=2,

def write_frames(self,frames_array):
try:
self.proc.stdin.write(frames_array.tostring())
if PY3:
self.proc.stdin.write(frames_array.tobytes())
else:
self.proc.stdin.write(frames_array.tostring())
except IOError as err:
ffmpeg_error = self.proc.stderr.read()
error = (str(err)+ ("\n\nMoviePy error: FFMPEG encountered "
"the following error while writing file %s:"%self.filename
+ "\n\n"+ffmpeg_error))

if "Unknown encoder" in ffmpeg_error:
if b"Unknown encoder" in ffmpeg_error:

error = (error+("\n\nThe audio export failed because "
"FFMPEG didn't find the specified codec for audio "
Expand All @@ -99,7 +100,7 @@ def write_frames(self,frames_array):
" >>> to_videofile('myvid.mp4', audio_codec='libmp3lame')"
)%(self.codec))

elif "incorrect codec parameters ?" in ffmpeg_error:
elif b"incorrect codec parameters ?" in ffmpeg_error:

error = error+("\n\nThe audio export "
"failed, possibly because the codec specified for "
Expand All @@ -108,7 +109,7 @@ def write_frames(self,frames_array):
"argument in to_videofile. This would be 'libmp3lame' "
"for mp3, 'libvorbis' for ogg...")%(self.codec, self.ext)

elif "encoder setup failed":
elif b"encoder setup failed" in ffmpeg_error:

error = error+("\n\nThe audio export "
"failed, possily because the bitrate you specified "
Expand Down
13 changes: 4 additions & 9 deletions moviepy/audio/io/readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,8 @@

from moviepy.video.io.ffmpeg_reader import ffmpeg_parse_infos
from moviepy.config import get_setting

from moviepy.compat import PY3, DEVNULL
import os
try:
from subprocess import DEVNULL # py3k
except ImportError:
DEVNULL = open(os.devnull, 'wb')


class FFMPEG_AudioReader:
Expand Down Expand Up @@ -114,12 +110,14 @@ def skip_chunk(self,chunksize):


def read_chunk(self,chunksize):
# chunksize is not being autoconverted from float to int
chunksize = int(round(chunksize))
L = self.nchannels*chunksize*self.nbytes
s = self.proc.stdout.read(L)
dt = {1: 'int8',2:'int16',4:'int32'}[self.nbytes]
result = np.fromstring(s, dtype=dt)
result = (1.0*result / 2**(8*self.nbytes-1)).\
reshape((len(result)/self.nchannels,
reshape((int(len(result)/self.nchannels),
self.nchannels))
#self.proc.stdout.flush()
self.pos = self.pos+chunksize
Expand Down Expand Up @@ -238,6 +236,3 @@ def buffer_around(self,framenumber):

def __del__(self):
self.close_proc()



8 changes: 8 additions & 0 deletions moviepy/compat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import os
import sys
PY3=sys.version_info.major >= 3

if PY3:
from subprocess import DEVNULL # py3k
else:
DEVNULL = open(os.devnull, 'wb')
7 changes: 1 addition & 6 deletions moviepy/config.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import os
import subprocess as sp
try:
from subprocess import DEVNULL # py3k
except ImportError:
DEVNULL = open(os.devnull, 'wb')
from .compat import DEVNULL

if os.name == 'nt':
try:
Expand Down Expand Up @@ -103,5 +100,3 @@ def change_settings(new_settings={}, file=None):
print( "MoviePy : ImageMagick successfully found." )
else:
print( "MoviePy : can't find or access ImageMagick." )


7 changes: 2 additions & 5 deletions moviepy/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
import re

import os
try:
from subprocess import DEVNULL # py3k
except ImportError:
DEVNULL = open(os.devnull, 'wb')
from .compat import DEVNULL


def sys_write_flush(s):
Expand Down Expand Up @@ -156,4 +153,4 @@ def find_extension(codec):
for ext,infos in extensions_dict.items():
if ('codec' in infos) and codec in infos['codec']:
return ext
raise ValueError
raise ValueError
2 changes: 1 addition & 1 deletion moviepy/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.2.2.12"
__version__ = "0.2.2.13"
Loading

0 comments on commit 25ed5a4

Please sign in to comment.