Video editing with Python
towards a numpydoc-style documentation
Zulkocf6d3f7be340
diff --git a/docs/_themes/flask/layout.html b/docs/_themes/flask/layout.htmldeleted file mode 100644index 0039546d..00000000--- a/docs/_themes/flask/layout.html+++ /dev/null@@ -1,27 +0,0 @@-{%- extends "basic/layout.html" %}-{%- block extrahead %}- {{ super() }}- {% if theme_touch_icon %}- <link rel="orange-touch-icon" href="{{ pathto('_static/' ~ theme_touch_icon, 1) }}" />- {% endif %}- <link media="only screen and (max-device-width: 480px)" href="{{- pathto('_static/small_flask.css', 1) }}" type= "text/css" rel="stylesheet" />-{% endblock %}--{%- block relbar2 %}{% endblock %}--{% block header %}- {{ super() }}- {% if pagename == 'index' %}- <div class=indexwrapper>- {% endif %}-{% endblock %}-{%- block footer %}- <div class="footer">- © Copyright {{ copyright }}.- Created using <a href="http://sphinx.pocoo.org/">Sphinx</a>.- </div>- {% if pagename == 'index' %}- </div>- {% endif %}-{%- endblock %}diff --git a/docs/_themes/flask/relations.html b/docs/_themes/flask/relations.htmldeleted file mode 100644index 3bbcde85..00000000--- a/docs/_themes/flask/relations.html+++ /dev/null@@ -1,19 +0,0 @@-<h3>Related Topics</h3>-<ul>- <li><a href="{{ pathto(master_doc) }}">Documentation overview</a><ul>- {%- for parent in parents %}- <li><a href="{{ parent.link|e }}">{{ parent.title }}</a><ul>- {%- endfor %}- {%- if prev %}- <li>Previous: <a href="{{ prev.link|e }}" title="{{ _('previous chapter')- }}">{{ prev.title }}</a></li>- {%- endif %}- {%- if next %}- <li>Next: <a href="{{ next.link|e }}" title="{{ _('next chapter')- }}">{{ next.title }}</a></li>- {%- endif %}- {%- for parent in parents %}- </ul></li>- {%- endfor %}- </ul></li>-</ul>diff --git a/docs/_themes/flask/static/flasky.css_t b/docs/_themes/flask/static/flasky.css_tdeleted file mode 100644index 08bb88c0..00000000--- a/docs/_themes/flask/static/flasky.css_t+++ /dev/null@@ -1,398 +0,0 @@-/*- * flasky.css_t- * ~~~~~~~~~~~~- *- * :copyright: Copyright 2010 by Armin Ronacher.- * :license: Flask Design License, see LICENSE for details.- */--{% set page_width = '940px' %}-{% set sidebar_width = '220px' %}--@import url("basic.css");--/* -- page layout ----------------------------------------------------------- */--body {- font-family: 'Georgia', serif;- font-size: 17px;- background-color: white;- color: #000;- margin: 0;- padding: 0;-}--div.document {- width: {{ page_width }};- margin: 30px auto 0 auto;-}--div.documentwrapper {- float: left;- width: 100%;-}--div.bodywrapper {- margin: 0 0 0 {{ sidebar_width }};-}--div.sphinxsidebar {- width: {{ sidebar_width }};-}--hr {- border: 1px solid #B1B4B6;-}--div.body {- background-color: #ffffff;- color: #3E4349;- padding: 0 30px 0 30px;-}--img.floatingflask {- padding: 0 0 10px 10px;- float: right;-}--div.footer {- width: {{ page_width }};- margin: 20px auto 30px auto;- font-size: 14px;- color: #888;- text-align: right;-}--div.footer a {- color: #888;-}--div.related {- display: none;-}--div.sphinxsidebar a {- color: #444;- text-decoration: none;- border-bottom: 1px dotted #999;-}--div.sphinxsidebar a:hover {- border-bottom: 1px solid #999;-}--div.sphinxsidebar {- font-size: 14px;- line-height: 1.5;-}--div.sphinxsidebarwrapper {- padding: 18px 10px;-}--div.sphinxsidebarwrapper p.logo {- padding: 0 0 20px 0;- margin: 0;- text-align: center;-}--div.sphinxsidebar h3,-div.sphinxsidebar h4 {- font-family: 'Garamond', 'Georgia', serif;- color: #444;- font-size: 24px;- font-weight: normal;- margin: 0 0 5px 0;- padding: 0;-}--div.sphinxsidebar h4 {- font-size: 20px;-}--div.sphinxsidebar h3 a {- color: #444;-}--div.sphinxsidebar p.logo a,-div.sphinxsidebar h3 a,-div.sphinxsidebar p.logo a:hover,-div.sphinxsidebar h3 a:hover {- border: none;-}--div.sphinxsidebar p {- color: #555;- margin: 10px 0;-}--div.sphinxsidebar ul {- margin: 10px 0;- padding: 0;- color: #000;-}--div.sphinxsidebar input {- border: 1px solid #ccc;- font-family: 'Georgia', serif;- font-size: 1em;-}--/* -- body styles ----------------------------------------------------------- */--a {- color: #004B6B;- text-decoration: underline;-}--a:hover {- color: #6D4100;- text-decoration: underline;-}--div.body h1,-div.body h2,-div.body h3,-div.body h4,-div.body h5,-div.body h6 {- font-family: 'Garamond', 'Georgia', serif;- font-weight: normal;- margin: 30px 0px 10px 0px;- padding: 0;-}---div.body h1 { margin-top: 0; padding-top: 0; font-size: 240%; }-div.body h2 { font-size: 180%; }-div.body h3 { font-size: 150%; }-div.body h4 { font-size: 130%; }-div.body h5 { font-size: 100%; }-div.body h6 { font-size: 100%; }---{% if theme_index_logo %}-div.indexwrapper h1 {- text-indent: -999999px;- background: url({{ theme_index_logo }}) no-repeat center center;- height: {{ theme_index_logo_height }};-}-{% endif %}---a.headerlink {- color: #ddd;- padding: 0 4px;- text-decoration: none;-}--a.headerlink:hover {- color: #444;- background: #eaeaea;-}--div.body p, div.body dd, div.body li {- line-height: 1.4em;-}--div.admonition {- background: #fafafa;- margin: 20px -30px;- padding: 10px 30px;- border-top: 1px solid #ccc;- border-bottom: 1px solid #ccc;-}--div.admonition tt.xref, div.admonition a tt {- border-bottom: 1px solid #fafafa;-}--dd div.admonition {- margin-left: -60px;- padding-left: 60px;-}--div.admonition p.admonition-title {- font-family: 'Garamond', 'Georgia', serif;- font-weight: normal;- font-size: 24px;- margin: 0 0 10px 0;- padding: 0;- line-height: 1;-}--div.admonition p.last {- margin-bottom: 0;-}--div.highlight {- background-color: white;-}--dt:target, .highlight {- background: #FAF3E8;-}--div.note {- background-color: #eee;- border: 1px solid #ccc;-}--div.seealso {- background-color: #ffc;- border: 1px solid #ff6;-}--div.topic {- background-color: #eee;-}--p.admonition-title {- display: inline;-}--p.admonition-title:after {- content: ":";-}--pre, tt {- font-family: 'Consolas', 'Menlo', 'Deja Vu Sans Mono', 'Bitstream Vera Sans Mono', monospace;- font-size: 0.9em;-}--img.screenshot {-}--tt.descname, tt.descclassname {- font-size: 0.95em;-}--tt.descname {- padding-right: 0.08em;-}--img.screenshot {- -moz-box-shadow: 2px 2px 4px #eee;- -webkit-box-shadow: 2px 2px 4px #eee;- box-shadow: 2px 2px 4px #eee;-}--table.docutils {- border: 1px solid #888;- -moz-box-shadow: 2px 2px 4px #eee;- -webkit-box-shadow: 2px 2px 4px #eee;- box-shadow: 2px 2px 4px #eee;-}--table.docutils td, table.docutils th {- border: 1px solid #888;- padding: 0.25em 0.7em;-}--table.field-list, table.footnote {- border: none;- -moz-box-shadow: none;- -webkit-box-shadow: none;- box-shadow: none;-}--table.footnote {- margin: 15px 0;- width: 100%;- border: 1px solid #eee;- background: #fdfdfd;- font-size: 0.9em;-}--table.footnote + table.footnote {- margin-top: -15px;- border-top: none;-}--table.field-list th {- padding: 0 0.8em 0 0;-}--table.field-list td {- padding: 0;-}--table.footnote td.label {- width: 0px;- padding: 0.3em 0 0.3em 0.5em;-}--table.footnote td {- padding: 0.3em 0.5em;-}--dl {- margin: 0;- padding: 0;-}--dl dd {- margin-left: 30px;-}--blockquote {- margin: 0 0 0 30px;- padding: 0;-}--ul, ol {- margin: 10px 0 10px 30px;- padding: 0;-}--pre {- background: #eee;- padding: 7px 30px;- margin: 15px -30px;- line-height: 1.3em;-}--dl pre, blockquote pre, li pre {- margin-left: -60px;- padding-left: 60px;-}--dl dl pre {- margin-left: -90px;- padding-left: 90px;-}--tt {- background-color: #ecf0f3;- color: #222;- /* padding: 1px 2px; */-}--tt.xref, a tt {- background-color: #FBFBFB;- border-bottom: 1px solid white;-}--a.reference {- text-decoration: none;- border-bottom: 1px dotted #004B6B;-}--a.reference:hover {- border-bottom: 1px solid #6D4100;-}--a.footnote-reference {- text-decoration: none;- font-size: 0.7em;- vertical-align: top;- border-bottom: 1px dotted #004B6B;-}--a.footnote-reference:hover {- border-bottom: 1px solid #6D4100;-}--a:hover tt {- background: #EEE;-}diff --git a/docs/_themes/flask/static/small_flask.css b/docs/_themes/flask/static/small_flask.cssdeleted file mode 100644index 1c6df309..00000000--- a/docs/_themes/flask/static/small_flask.css+++ /dev/null@@ -1,70 +0,0 @@-/*- * small_flask.css_t- * ~~~~~~~~~~~~~~~~~- *- * :copyright: Copyright 2010 by Armin Ronacher.- * :license: Flask Design License, see LICENSE for details.- */--body {- margin: 0;- padding: 20px 30px;-}--div.documentwrapper {- float: none;- background: white;-}--div.sphinxsidebar {- display: block;- float: none;- width: 102.5%;- margin: 50px -30px -20px -30px;- padding: 10px 20px;- background: #333;- color: white;-}--div.sphinxsidebar h3, div.sphinxsidebar h4, div.sphinxsidebar p,-div.sphinxsidebar h3 a {- color: white;-}--div.sphinxsidebar a {- color: #aaa;-}--div.sphinxsidebar p.logo {- display: none;-}--div.document {- width: 100%;- margin: 0;-}--div.related {- display: block;- margin: 0;- padding: 10px 0 20px 0;-}--div.related ul,-div.related ul li {- margin: 0;- padding: 0;-}--div.footer {- display: none;-}--div.bodywrapper {- margin: 0;-}--div.body {- min-height: 0;- padding: 0;-}diff --git a/docs/_themes/flask/theme.conf b/docs/_themes/flask/theme.confdeleted file mode 100644index 26b77e51..00000000--- a/docs/_themes/flask/theme.conf+++ /dev/null@@ -1,9 +0,0 @@-[theme]-inherit = basic-stylesheet = flasky.css-pygments_style = flask_theme_support.FlaskyStyle--[options]-index_logo = 'logo.png'-index_logo_height = 120px-github_fork = 'http://github.com/zulko/moviepy'diff --git a/docs/_themes/flask_small/layout.html b/docs/_themes/flask_small/layout.htmldeleted file mode 100644index aa1716aa..00000000--- a/docs/_themes/flask_small/layout.html+++ /dev/null@@ -1,22 +0,0 @@-{% extends "basic/layout.html" %}-{% block header %}- {{ super() }}- {% if pagename == 'index' %}- <div class=indexwrapper>- {% endif %}-{% endblock %}-{% block footer %}- {% if pagename == 'index' %}- </div>- {% endif %}-{% endblock %}-{# do not display relbars #}-{% block relbar1 %}{% endblock %}-{% block relbar2 %}- {% if theme_github_fork %}- <a href="http://github.com/{{ theme_github_fork }}"><img style="position: fixed; top: 0; right: 0; border: 0;"- src="http://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub" /></a>- {% endif %}-{% endblock %}-{% block sidebar1 %}{% endblock %}-{% block sidebar2 %}{% endblock %}diff --git a/docs/_themes/flask_small/static/flasky.css_t b/docs/_themes/flask_small/static/flasky.css_tdeleted file mode 100644index fe2141c5..00000000--- a/docs/_themes/flask_small/static/flasky.css_t+++ /dev/null@@ -1,287 +0,0 @@-/*- * flasky.css_t- * ~~~~~~~~~~~~- *- * Sphinx stylesheet -- flasky theme based on nature theme.- *- * :copyright: Copyright 2007-2010 by the Sphinx team, see AUTHORS.- * :license: BSD, see LICENSE for details.- *- */--@import url("basic.css");--/* -- page layout ----------------------------------------------------------- */--body {- font-family: 'Georgia', serif;- font-size: 17px;- color: #000;- background: white;- margin: 0;- padding: 0;-}--div.documentwrapper {- float: left;- width: 100%;-}--div.bodywrapper {- margin: 40px auto 0 auto;- width: 700px;-}--hr {- border: 1px solid #B1B4B6;-}--div.body {- background-color: #ffffff;- color: #3E4349;- padding: 0 30px 30px 30px;-}--img.floatingflask {- padding: 0 0 10px 10px;- float: right;-}--div.footer {- text-align: right;- color: #888;- padding: 10px;- font-size: 14px;- width: 650px;- margin: 0 auto 40px auto;-}--div.footer a {- color: #888;- text-decoration: underline;-}--div.related {- line-height: 32px;- color: #888;-}--div.related ul {- padding: 0 0 0 10px;-}--div.related a {- color: #444;-}--/* -- body styles ----------------------------------------------------------- */--a {- color: #004B6B;- text-decoration: underline;-}--a:hover {- color: #6D4100;- text-decoration: underline;-}--div.body {- padding-bottom: 40px; /* saved for footer */-}--div.body h1,-div.body h2,-div.body h3,-div.body h4,-div.body h5,-div.body h6 {- font-family: 'Garamond', 'Georgia', serif;- font-weight: normal;- margin: 30px 0px 10px 0px;- padding: 0;-}--{% if theme_index_logo %}-div.indexwrapper h1 {- text-indent: -999999px;- background: url({{ theme_index_logo }}) no-repeat center center;- height: {{ theme_index_logo_height }};-}-{% endif %}--div.body h2 { font-size: 180%; }-div.body h3 { font-size: 150%; }-div.body h4 { font-size: 130%; }-div.body h5 { font-size: 100%; }-div.body h6 { font-size: 100%; }--a.headerlink {- color: white;- padding: 0 4px;- text-decoration: none;-}--a.headerlink:hover {- color: #444;- background: #eaeaea;-}--div.body p, div.body dd, div.body li {- line-height: 1.4em;-}--div.admonition {- background: #fafafa;- margin: 20px -30px;- padding: 10px 30px;- border-top: 1px solid #ccc;- border-bottom: 1px solid #ccc;-}--div.admonition p.admonition-title {- font-family: 'Garamond', 'Georgia', serif;- font-weight: normal;- font-size: 24px;- margin: 0 0 10px 0;- padding: 0;- line-height: 1;-}--div.admonition p.last {- margin-bottom: 0;-}--div.highlight{- background-color: white;-}--dt:target, .highlight {- background: #FAF3E8;-}--div.note {- background-color: #eee;- border: 1px solid #ccc;-}--div.seealso {- background-color: #ffc;- border: 1px solid #ff6;-}--div.topic {- background-color: #eee;-}--div.warning {- background-color: #ffe4e4;- border: 1px solid #f66;-}--p.admonition-title {- display: inline;-}--p.admonition-title:after {- content: ":";-}--pre, tt {- font-family: 'Consolas', 'Menlo', 'Deja Vu Sans Mono', 'Bitstream Vera Sans Mono', monospace;- font-size: 0.85em;-}--img.screenshot {-}--tt.descname, tt.descclassname {- font-size: 0.95em;-}--tt.descname {- padding-right: 0.08em;-}--img.screenshot {- -moz-box-shadow: 2px 2px 4px #eee;- -webkit-box-shadow: 2px 2px 4px #eee;- box-shadow: 2px 2px 4px #eee;-}--table.docutils {- border: 1px solid #888;- -moz-box-shadow: 2px 2px 4px #eee;- -webkit-box-shadow: 2px 2px 4px #eee;- box-shadow: 2px 2px 4px #eee;-}--table.docutils td, table.docutils th {- border: 1px solid #888;- padding: 0.25em 0.7em;-}--table.field-list, table.footnote {- border: none;- -moz-box-shadow: none;- -webkit-box-shadow: none;- box-shadow: none;-}--table.footnote {- margin: 15px 0;- width: 100%;- border: 1px solid #eee;-}--table.field-list th {- padding: 0 0.8em 0 0;-}--table.field-list td {- padding: 0;-}--table.footnote td {- padding: 0.5em;-}--dl {- margin: 0;- padding: 0;-}--dl dd {- margin-left: 30px;-}--pre {- padding: 0;- margin: 15px -30px;- padding: 8px;- line-height: 1.3em;- padding: 7px 30px;- background: #eee;- border-radius: 2px;- -moz-border-radius: 2px;- -webkit-border-radius: 2px;-}--dl pre {- margin-left: -60px;- padding-left: 60px;-}--tt {- background-color: #ecf0f3;- color: #222;- /* padding: 1px 2px; */-}--tt.xref, a tt {- background-color: #FBFBFB;-}--a:hover tt {- background: #EEE;-}diff --git a/docs/_themes/flask_small/theme.conf b/docs/_themes/flask_small/theme.confdeleted file mode 100644index 542b4625..00000000--- a/docs/_themes/flask_small/theme.conf+++ /dev/null@@ -1,10 +0,0 @@-[theme]-inherit = basic-stylesheet = flasky.css-nosidebar = true-pygments_style = flask_theme_support.FlaskyStyle--[options]-index_logo = ''-index_logo_height = 120px-github_fork = ''diff --git a/docs/_themes/flask_theme_support.py b/docs/_themes/flask_theme_support.pydeleted file mode 100644index 33f47449..00000000--- a/docs/_themes/flask_theme_support.py+++ /dev/null@@ -1,86 +0,0 @@-# flasky extensions. flasky pygments style based on tango style-from pygments.style import Style-from pygments.token import Keyword, Name, Comment, String, Error, \- Number, Operator, Generic, Whitespace, Punctuation, Other, Literal---class FlaskyStyle(Style):- background_color = "#f8f8f8"- default_style = ""-- styles = {- # No corresponding class for the following:- #Text: "", # class: ''- Whitespace: "underline #f8f8f8", # class: 'w'- Error: "#a40000 border:#ef2929", # class: 'err'- Other: "#000000", # class 'x'-- Comment: "italic #8f5902", # class: 'c'- Comment.Preproc: "noitalic", # class: 'cp'-- Keyword: "bold #004461", # class: 'k'- Keyword.Constant: "bold #004461", # class: 'kc'- Keyword.Declaration: "bold #004461", # class: 'kd'- Keyword.Namespace: "bold #004461", # class: 'kn'- Keyword.Pseudo: "bold #004461", # class: 'kp'- Keyword.Reserved: "bold #004461", # class: 'kr'- Keyword.Type: "bold #004461", # class: 'kt'-- Operator: "#582800", # class: 'o'- Operator.Word: "bold #004461", # class: 'ow' - like keywords-- Punctuation: "bold #000000", # class: 'p'-- # because special names such as Name.Class, Name.Function, etc.- # are not recognized as such later in the parsing, we choose them- # to look the same as ordinary variables.- Name: "#000000", # class: 'n'- Name.Attribute: "#c4a000", # class: 'na' - to be revised- Name.Builtin: "#004461", # class: 'nb'- Name.Builtin.Pseudo: "#3465a4", # class: 'bp'- Name.Class: "#000000", # class: 'nc' - to be revised- Name.Constant: "#000000", # class: 'no' - to be revised- Name.Decorator: "#888", # class: 'nd' - to be revised- Name.Entity: "#ce5c00", # class: 'ni'- Name.Exception: "bold #cc0000", # class: 'ne'- Name.Function: "#000000", # class: 'nf'- Name.Property: "#000000", # class: 'py'- Name.Label: "#f57900", # class: 'nl'- Name.Namespace: "#000000", # class: 'nn' - to be revised- Name.Other: "#000000", # class: 'nx'- Name.Tag: "bold #004461", # class: 'nt' - like a keyword- Name.Variable: "#000000", # class: 'nv' - to be revised- Name.Variable.Class: "#000000", # class: 'vc' - to be revised- Name.Variable.Global: "#000000", # class: 'vg' - to be revised- Name.Variable.Instance: "#000000", # class: 'vi' - to be revised-- Number: "#990000", # class: 'm'-- Literal: "#000000", # class: 'l'- Literal.Date: "#000000", # class: 'ld'-- String: "#4e9a06", # class: 's'- String.Backtick: "#4e9a06", # class: 'sb'- String.Char: "#4e9a06", # class: 'sc'- String.Doc: "italic #8f5902", # class: 'sd' - like a comment- String.Double: "#4e9a06", # class: 's2'- String.Escape: "#4e9a06", # class: 'se'- String.Heredoc: "#4e9a06", # class: 'sh'- String.Interpol: "#4e9a06", # class: 'si'- String.Other: "#4e9a06", # class: 'sx'- String.Regex: "#4e9a06", # class: 'sr'- String.Single: "#4e9a06", # class: 's1'- String.Symbol: "#4e9a06", # class: 'ss'-- Generic: "#000000", # class: 'g'- Generic.Deleted: "#a40000", # class: 'gd'- Generic.Emph: "italic #000000", # class: 'ge'- Generic.Error: "#ef2929", # class: 'gr'- Generic.Heading: "bold #000080", # class: 'gh'- Generic.Inserted: "#00A000", # class: 'gi'- Generic.Output: "#888", # class: 'go'- Generic.Prompt: "#745334", # class: 'gp'- Generic.Strong: "bold #000000", # class: 'gs'- Generic.Subheading: "bold #800080", # class: 'gu'- Generic.Traceback: "bold #a40000", # class: 'gt'- }diff --git a/docs/conf.py b/docs/conf.pyindex d20e6018..ff5cf805 100644--- a/docs/conf.py+++ b/docs/conf.py@@ -25,7 +25,9 @@ import sys, os# Add any Sphinx extension module names here, as strings. They can be extensions# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.-extensions = ['sphinx.ext.autodoc', 'sphinx.ext.todo', 'sphinx.ext.viewcode']+extensions = ['sphinx.ext.autodoc', 'sphinx.ext.todo',+ 'sphinx.ext.viewcode', 'numpydoc', 'sphinx.ext.autosummary']+autosummary_generate = True# Add any paths that contain templates here, relative to this directory.templates_path = ['_templates']diff --git a/docs/crash_course/crash_course.rst b/docs/crash_course/crash_course.rstindex 622d8825..a45840f5 100644--- a/docs/crash_course/crash_course.rst+++ b/docs/crash_course/crash_course.rst@@ -29,6 +29,18 @@ So let us load a movie of my last holidays, lower the volume, add a title in the# Write the result to a filevideo.to_videofile("myHolidays_edited.avi",fps=24, codec='mpeg4')+How it works, in a nutshell+~~~~~~~~~~~~~~~~~~~~~~~~~~~~++MoviePy uses mainly ``ffmpeg`` for reading/writing multimedia files, and Numpy/Scipy for image and sound manipulations.++.. image:: explanations.jpeg+ :width: 570px+ :align: center++You can do pretty much any effect you want with MoviePy, but it is just a framework, and in many cases you will need to code a little (or find someone who will !) to come to your goal.++Classes of video clips~~~~~~~~~~~~~~~~~~~~~~diff --git a/docs/explications.jpeg b/docs/explications.jpegdeleted file mode 100644index cd71e587..00000000Binary files a/docs/explications.jpeg and /dev/null differdiff --git a/docs/index.rst b/docs/index.rstindex 9eb9d531..a1cd7e7a 100644--- a/docs/index.rst+++ b/docs/index.rst@@ -1,9 +1,9 @@MoviePy=======-MoviePy is a Python module for script-based movie editing. It enables basic operations (cuts, concatenations, title insertions) to be done in a few lines, and can be used for advanced compositing and special effects.+MoviePy is a Python module for script-based movie editing. It enables basic operations (cuts, concatenations, title insertions) to be done in a few lines, and can be used for advanced compositing and special effects. It can read and save to many formats, including `animated GIFs <http://zulko.github.io/blog/2014/01/23/making-animated-gifs-from-video-files-with-python>`_.-Let us put together a few demonstration clips (you will find the code for most clips in the :ref:`examples`): ::+Let us put together a few demonstration clips (you will find the code for most of these in the :ref:`examples`): ::import osfrom moviepy.editor import *@@ -21,10 +21,30 @@ Let us put together a few demonstration clips (you will find the code for most cname="allowscriptaccess" value="always"></param><embedsrc="http://www.youtube.com/v/zGhoZ4UBxEQ&hl=en_US&fs=1&rel=0"type="application/x-shockwave-flash" allowscriptaccess="always"- allowfullscreen="true" width="550" height="450"></embed></object>+ allowfullscreen="true" width="490" height="390"></embed></object></center>--You can also do animated GIFs with MoviePy (`examples <http://zulko.github.io/blog/2014/01/23/making-animated-gifs-from-video-files-with-python>`_).++MoviePy is an open source software originally written by Zulko_ and released under the MIT licence.+It is hosted on Github_, where you can push improvements or ask for help.++.. raw:: html++ <a href="https://twitter.com/share" class="twitter-share-button"+ data-text="MoviePy, script-based video editing" data-size="large" data-hashtags="MoviePy">Tweet+ </a>+ <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';+ if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';+ fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');+ </script>++ <iframe src="http://ghbtns.com/github-btn.html?user=Zulko&repo=moviepy&type=watch&count=true&size=large"+ allowtransparency="true" frameborder="0" scrolling="0" width="152px" height="30px"></iframe>++ <a href="https://github.com/Zulko/moviepy">+ <img style="position: absolute; top: 0; right: 0; border: 0;"+ src="https://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png"+ alt="Fork me on GitHub"></a>+User's Guide--------------@@ -37,41 +57,10 @@ User's Guideexamples/examplesref/ref-How it works, in a nutshell--------------------------------MoviePy uses mainly ``ffmpeg`` for reading/writing multimedia files, and Numpy/Scipy for image and sound manipulations.--.. image:: explications.jpeg- :width: 570px- :align: center--You can do pretty much any effect you want with MoviePy, but it is just a framework, and in many cases you will need to code a little (or find someone who will !) to come to your goal.-----Contribute !----------------MoviePy is a (still experimental) open source software written by Zulko_ and released on Github_ and PyPI_ under the MIT licence. Everyone is very welcome to help improve the project, fork it, blog on it, share code for new effects, etc... The more, the merrier !--For troubleshooting and bug reports, the best for now is to ask on Stackoverflow_ (it will advertize for the project :) ) or on the Github project page.--Indices and tables---------------------* :ref:`genindex`-* :ref:`modindex`-* :ref:`search`-.. raw:: html- <a href="https://github.com/Zulko/moviepy">- <img style="position: absolute; top: 0; right: 0; border: 0;"- src="https://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png"- alt="Fork me on GitHub"></a>+.. _PyPI: https://pypi.python.org/pypi/moviepy.. _Github: https://github.com/Zulko/moviepydiff --git a/docs/install.rst b/docs/install.rstindex 6b3b85a2..d64dded1 100644--- a/docs/install.rst+++ b/docs/install.rst@@ -1,73 +1,51 @@Download and Installation==========================-Core dependencies--------------------MoviePy cannot run without these dependencies:+MoviePy requires the Python modules Numpy_, Decorator_, and tqdm_. All of these will all be automatically installed during MoviePy's installation.-- The software ffmpeg_ is needed for writing, reading, converting the sound and the video.-- `Numpy`_ is needed for image and sound manipulation-- The Decorator_ module is used in the MoviePy code for better code readability+You will also need a **recent version** of the software ffmpeg_ , preferably downloaded directly from the ffmpeg website.-**Make sure to use a recent version of ffmpeg**. You can either install it or save the binary files in any folder and specify the path to these folders before installing MoviePy (for the latter, see `Manual installation`_ below).+Installation+---------------**Debian and Ubuntu users**, you certainly have an out-of-date version of FFMPEG, you *must* download a recent version from the ffmpeg_ website.+First method : if you have ``pip`` installed, just type this in a terminal (sudo is optional on some systems) ::++ (sudo) pip install moviepy++Second method : 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 ::++ (sudo) python setup.py install++Linking to ffmpeg+~~~~~~~~~~~~~~~~~~-Normally Numpy and Decorator will be automatically installed when you install MoviePy. In case of doubt/problem they can also be installed manually.-Numpy can be installed with most software managers on Linux distributions. Both Numpy and Decorator can be installed as follows with pip: ::+If you put have a ffmpeg binary in you executable folder (on Linux it will be ``/usr/bin``) it will be detected automatically by MoviePy. Else make sure that MoviePy can locate ffmpeg on your computer by running the script ``moviepy/conf.py`` that is in the sources. It it fails, then you must enter the path to the FFMPEG executable in the first line of this file ::++ FFMPEG_BINARY = path/to/your/ffmpeg- (sudo) pip install decorator- (sudo) pip install numpy-(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.+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).-- PyGame_ is needed for video and sound previews (really essential for advanced editing).-- imageMagick_ is needed for all text generation, GIF support, and much more in the future.+ImageMagick_ is needed for all text generation, GIF import/export, and much more .-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.+For advanced image processing you will need one or several of these packages. for instance ``clip.resize`` requires that at least one of Scipy, PIL, Pillow or OpenCV are installed.-- Scipy is needed for many advanced functionalities (tracking, segmenting, etc.), and can be used for resizing video clips if PIL and OpenCV aren't installed on your computer.+- 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.-- The Python Imaging Library is not used yet (I don't like the copyright) but it is coming.-- `OpenCV 2.4.6`_ (which provides the python package ``cv2``) or more recent may be needed for some advanced image manipulation. See below for the installation of OpenCV.+- `OpenCV 2.4.6`_ (provides the package ``cv2``) or more recent may be needed for some advanced image manipulation. See below.If you are on linux, these softwares will surely be in your repos.--.. _pip_install:--Installation with PIP---------------------------If you have ``pip`` installed, just type this in a terminal ::-- (sudo) pip install moviepy--.. _manual_install:--Manual installation-------------------------You can install moviepy manually by downloading the sources, either on PYPI_ or (if you want the development version) on Github_ .--Then just unzip everything in one folder, open a terminal and type ::-- sudo python setup.py install--Before doing that, you should make sure that MoviePy can locate ffmpeg on your computer. To do that, run the script ``moviepy/conf.py``. It it fails, then you must enter the path to the FFMPEG executable in the first line of this file ::-- FFMPEG_BINARY = path/to/your/ffmpeg---Installing OpenCV 2.4.6-~~~~~~~~~~~~~~~~~~~~~~~~~+So you want to install 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:@@ -101,17 +79,22 @@ You can check if it worked by opeing a Python console and typing ::Advice: do not throw your ``release`` folder away. If later you have strange bugs with OpenCV involving ``.so`` files, just redo the ``sudo make install`` step.+.. _`Numpy`: http://www.scipy.org/install.html+.. _Decorator: https://pypi.python.org/pypi/decorator+.. _tqdm: https://pypi.python.org/pypi/tqdm+.. _ffmpeg: http://www.ffmpeg.org/download.html-.. _PYPI https://pypi.python.org/pypi/moviepy-.. _Github: https://github.com/Zulko/moviepy-.. _`OpenCV 2.4.6`: http://sourceforge.net/projects/opencvlibrary/files/+.. _imageMagick: http://www.imagemagick.org/script/index.php.. _Pygame: http://www.pygame.org/download.shtml-.. _`Numpy`: http://www.scipy.org/install.html+++.. _Pillow: http://pillow.readthedocs.org/en/latest/+.. _Scipy: http://www.scipy.org/.. _`Scikit Image`: http://scikit-image.org/download.html-.. _Decorator: https://pypi.python.org/pypi/decorator++.. _Github: https://github.com/Zulko/moviepy+.. _`OpenCV 2.4.6`: http://sourceforge.net/projects/opencvlibrary/files/-.. _ffmpeg: http://www.ffmpeg.org/download.html-.. _imageMagick: http://www.imagemagick.org/script/index.phpdiff --git a/examples/star_worms.py b/examples/star_worms.pyindex b97374f5..3d688638 100644--- a/examples/star_worms.py+++ b/examples/star_worms.py@@ -55,7 +55,7 @@ clip_txt = TextClip(txt,color='white', align='West',fontsize=25,txt_speed = 27fl = lambda gf,t : gf(t)[int(txt_speed*t):int(txt_speed*t)+h,:]-moving_txt= clip_txt.fl(fl, applyto=['mask'])+moving_txt= clip_txt.fl(fl, apply_to=['mask'])# ADD A VANISHING EFFECT ON THE TEXT WITH A GRADIENT MASKdiff --git a/moviepy/Clip.py b/moviepy/Clip.pyindex 51abeb8e..bb3e76fc 100644--- a/moviepy/Clip.py+++ b/moviepy/Clip.py@@ -18,15 +18,20 @@ class Clip:Base class of all clips (VideoClips and AudioClips).-- :ivar start: When the clip is included in a composition, time of the- composition at which the clip starts playing (in seconds).+ Attributes+ -----------++ start:+ When the clip is included in a composition, time of the+ composition at which the clip starts playing (in seconds).- :ivar end: When the clip is included in a composition, time of the- composition at which the clip starts playing (in seconds).+ end:+ When the clip is included in a composition, time of the+ composition at which the clip starts playing (in seconds).- :ivar duration: duration of the clip (in seconds). Some clips- are infinite and do not have any duration.+ duration:+ Duration of the clip (in seconds). Some clips are infinite, in+ this case their duration will be ``None``."""@@ -42,46 +47,67 @@ class Clip:self.end = Noneself.duration = None++def copy(self):+ """+ Shallow copy of the clip. This method is intensively used+ to produce new clips every time there is an outplace+ transformation of the clip (clip.resize, clip.subclip, etc.)+ """+return copy(self)- def fl(self, fl, applyto=[], keep_duration=True):+++ def fl(self, fun, apply_to=[] , keep_duration=True):"""- Returns a clip whose frames are a transformation (through ``fl``)- of the frames of the current clip.-- :param fl: a function with signature (gf,t -> frame) where:- - `gf` is a clip ``get_frame`` method, i.e. a function (t->image).- - `t` is a time in seconds- - `frame` is a picture (=Numpy array), and is the frame of the- returned clip at time ``t``.+ Returns a new Clip whose frames are a transformation+ (through function ``fun``) of the frames of the current clip.++ Parameters+ -----------++ fun+ A function with signature (gf,t -> frame) where ``gf`` will+ represent the current clip's ``get_frame`` method,+ i.e. ``gf`` is a function (t->image). Parameter `t` is a time+ in seconds, `frame` is a picture (=Numpy array) which will be+ returned by the transformed clip (see examples below).- :param applyto: can be either 'mask', or 'audio', or ['mask','audio'].- Specifies if the filter ``fl`` should also be applied to the- audio or the mask of the clip, if any.+ apply_to+ Can be either ``'mask'``, or ``'audio'``, or+ ``['mask','audio']``.+ Specifies if the filter ``fl`` should also be applied to the+ audio or the mask of the clip, if any.++ keep_duration+ Set to True if the transformation does not change the clip's+ ``duration``.++ Examples+ --------- :param keep_duration: Should the attributes ``duration`` and ``end``- of the clip be discarded.+ In the following ``newclip`` a 100 pixels-high clip whose video+ content scrolls from the top to the bottom of the frames of+ ``clip``.- >>> # ``newclip``, made from ``clip``, will be a 100 pixels-high- >>> # whose video content scrolls from the top to the bottom of- >>> # the frames of ``clip``.- >>> fl = lambda gf,t : gf(t)[int(t):int(t)+50,:]- >>> newclip = clip.fl(fl,applyto='mask')+ >>> fl = lambda gf,t : gf(t)[int(t):int(t)+50, :]+ >>> newclip = clip.fl(fl, apply_to='mask')"""gf = copy(self.get_frame)- newclip = self.set_get_frame(lambda t: fl(gf, t))+ newclip = self.set_get_frame(lambda t: fun(gf, t))if not keep_duration:newclip.duration = Nonenewclip.end = None- if isinstance(applyto, str):- applyto = [applyto]+ if isinstance(apply_to, str):+ apply_to = [apply_to]- for attr in applyto:+ for attr in apply_to:if hasattr(newclip, attr):a = getattr(newclip, attr)if a != None:@@ -90,47 +116,60 @@ class Clip:return newclip- def fl_time(self, t_func, applyto=[], keep_duration=False):++ def fl_time(self, t_func, apply_to=[], keep_duration=False):"""- Returns a clip playing the content of the current clip but with a- modified timeline, time ``t`` being replaced by another- time `t_func(t)`. By default the attributes ``duration`` and ``end``- of the returned clip are discarded.+ Returns a Clip instance playing the content of the current clip+ but with a modified timeline, time ``t`` being replaced by another+ time `t_func(t)`.- :param applyto: can be either 'mask', or 'audio', or ['mask','audio'].- Specifies if the filter ``fl`` should also be applied to the- audio or the mask of the clip, if any.+ Parameters+ ------------ :param keep_duration: Should the attributes ``duration`` and ``end``- of the clip be discarded.+ t_func:+ A function ``t-> new_t``++ apply_to:+ Can be either 'mask', or 'audio', or ['mask','audio'].+ Specifies if the filter ``fl`` should also be applied to the+ audio or the mask of the clip, if any.++ keep_duration:+ ``False`` (default) if the transformation modifies the+ ``duration`` of the clip.++ Examples+ -------->>> # plays the clip (and its mask and sound) twice faster- >>> newclip = clip.fl_time(lambda: 2*t, applyto=['mask','audio'])+ >>> newclip = clip.fl_time(lambda: 2*t, apply_to=['mask','audio'])>>>>>> # plays the clip starting at t=3, and backwards:>>> newclip = clip.fl_time(lambda: 3-t)"""- return self.fl(lambda gf, t: gf(t_func(t)), applyto,+ return self.fl(lambda gf, t: gf(t_func(t)), apply_to,keep_duration=keep_duration)++def fx(self, func, *args, **kwargs):"""Returns the result of ``func(self, *args, **kwargs)``.for instance- >>> newclip = clip.fx(resize,0.2,method='bilinear')+ >>> newclip = clip.fx(resize, 0.2, method='bilinear')is equivalent to- >>> newclip = resize(clip,0.2, method='bilinear')+ >>> newclip = resize(clip, 0.2, method='bilinear')The motivation of fx is to keep the name of the effect near itsparameters, when the effects are chained:- >>> from moviepy.fx import volumex, resize, mirrorx+ >>> from moviepy.video.fx import volumex, resize, mirrorx>>> clip.fx( volumex, 0.5).fx( resize, 0.3).fx( mirrorx )>>> # Is equivalent, but clearer than>>> resize( volumex( mirrorx( clip ), 0.5), 0.3)@@ -139,16 +178,26 @@ class Clip:return func(self, *args, **kwargs)-++@apply_to_mask@apply_to_audio@time_can_be_tupledef set_start(self, t, change_end=True):"""- Returns a copy of the clip, with the ``start`` attribute set to ``t``.- Automatically changes the end of the clip if the clip has a duration- and ``change_end`` is True. Else, sets the duration of the- returned clip's mask and audio, if any.+ Returns a copy of the clip, with the ``start`` attribute set+ to ``t`` (in seconds).++ If ``change_end=True`` and the clip has a ``duration`` attribute,+ the ``end`` atrribute of the clip will be updated to+ ``start+duration``.++ If ``change_end=False`` and the clip has a ``end`` attribute,+ the ``duration`` attribute of the clip will be updated to+ ``end-start``++ These changes are also applied to the ``audio`` and ``mask``+ clips of the current clip, if they exist."""newclip = self.copy()newclip.start = t@@ -158,7 +207,9 @@ class Clip:newclip.duration = newclip.end - newclip.startreturn newclip-+++@apply_to_mask@apply_to_audio@time_can_be_tuple@@ -177,59 +228,77 @@ class Clip:return newclip++@apply_to_mask@apply_to_audio@time_can_be_tuple- def set_duration(self, t):+ def set_duration(self, t, change_end=True):"""- Returns a copy of the clip, with the ``duration`` attribute set- to ``t``.- Also sets the duration of the returned clip's mask and audio, if any.+ Returns a copy of the clip, with the ``duration`` attribute+ set to ``t``.+ Also sets the duration of the returned clip's mask and audio,+ if any."""newclip = copy(self)newclip.duration = t- if (newclip.start is None):- if newclip.end != None:- newclip.start = max(0, newclip.end - t)- else:+ if change_end:newclip.end = newclip.start + t+ else:+ newclip.start = newclip.end - t+return newclip++def set_get_frame(self, gf):+ """+ Sets a ``get_frame`` attribute for the clip. Useful for setting+ arbitrary/complicated videoclips.+ """+newclip = copy(self)newclip.get_frame = gfreturn newclip++@time_can_be_tupledef is_playing(self, t):"""- Return true if t is between the start and the end of the clip """+ Return true if t is between the start and the end of the clip.+ """if isinstance(t, np.ndarray):t = t.max()return (((self.end is None) and (t >= self.start)) or(self.start <= t <= self.end))++@time_can_be_tuple@apply_to_mask@apply_to_audiodef subclip(self, ta=0, tb=None):"""Returns a clip playing the content of the current clip- between times ``ta`` and ``tb`` (in seconds). If ``tb`` is not- provided, plays until the end of the clip, potentially forever.- If ``tb`` is a negative value, ``tb`` is set to- `` clip.duration - tb. ``, for instance:+ between times ``ta`` and ``tb`` (in seconds).+ If ``tb`` is not provided, it is assumed to be the duration of+ the clip (potentially infinite).+ If ``tb`` is a negative value, it is reset to+ ``clip.duration - tb. ``. For instance: ::- >>> # cut the last two seconds of the clip:- >>> newclip = clip.subclip(0,-2)+ >>> # cut the last two seconds of the clip:+ >>> newclip = clip.subclip(0,-2)If ``tb`` is provided or if the clip has a duration attribute,the duration of the returned clip is set automatically.- The same effect is applied to the clip's audio and mask if any.++ The resulting subclip's ``mask`` and ``audio`` will be subclips+ of the original clip's ``mask`` and ``audio``, if they exist."""- newclip = self.fl_time(lambda t: t + ta, applyto=[])+ newclip = self.fl_time(lambda t: t + ta, apply_to=[])if (tb is None) and (self.duration != None):tb = self.durationelif tb<0:@@ -242,7 +311,9 @@ class Clip:return newclip.set_duration(tb - ta)else:return newclip-+++@apply_to_mask@apply_to_audio@time_can_be_tuple@@ -250,10 +321,14 @@ class Clip:"""Returns a clip playing the content of the current clip butskips the extract between ``ta`` and ``tb`` (in seconds).- If the original clip clip has a ``duration`` attribute set,- the returned clip's duration is automatically computed.- The same effect is applied to the clip's audio and mask if any.+ If the original clip has a ``duration`` attribute set,+ the returned clip's duration is automatically computed as+ `` duration - (tb - ta)``.++ The resulting clip's ``audio`` and ``mask`` will also be cutout+ if they exist."""+fl = lambda t: t + (0 if (t < ta) else tb - ta)newclip = self.fl_time(fl)if self.duration != None:diff --git a/moviepy/__init__.py b/moviepy/__init__.pyindex 8b137891..58f3ace6 100644--- a/moviepy/__init__.py+++ b/moviepy/__init__.py@@ -1 +1 @@-+from .version import __version__diff --git a/moviepy/audio/AudioClip.py b/moviepy/audio/AudioClip.pyindex 0d2bf251..c4ce8b63 100644--- a/moviepy/audio/AudioClip.py+++ b/moviepy/audio/AudioClip.py@@ -1,12 +1,9 @@-import time-import osimport sys-import wavefrom copy import copyimport numpy as npfrom moviepy.audio.io.ffmpeg_audiowriter import ffmpeg_audiowrite-from moviepy.decorators import requires_duration+from moviepy.decorators import requires_durationfrom moviepy.Clip import Clip@@ -23,25 +20,31 @@ class AudioClip(Clip):Base class for audio clips. See ``SoundClip`` and ``CompositeSoundClip``for usable classes.An audio clip is a special clip with a ``get_frame`` attribute of- the form ` t -> [ f_t ]` for mono sound and `t -> [ f1_t, f2_t ]`- for stereo sound. The `f_t` are floats between -1 and 1. These- bounds can be trespassed wihtout problems (the program will put the+ the form `` t -> [ f_t ]`` for mono sound and ``t -> [ f1_t, f2_t ]``+ for stereo sound (the arrays are Numpy arrays).+ The `f_t` are floats between -1 and 1. These bounds can be+ trespassed wihtout problems (the program will put thesound back into the bounds at conversion time, without much impact).- Example :+ Attributes+ -----------++ get_frame+ A function `t-> frame at time t`. The frame does not mean much+ for a sound, it is just a float. What 'makes' the sound are+ the variations of that float in the time.++ nchannels:+ Number of channels (one or two for mono or stereo).++ Examples+ --------->>> # Plays the note A (a sine wave of frequency 404HZ)>>> import numpy as np>>> gf = lambda t : 2*[ np.sin(404 * 2 * np.pi * t) ]>>> clip = AudioClip().set_get_frame(gf)>>> clip.set_duration(5).preview()--- :ivar get_frame: A function `t-> frame at time t`. The frame does not- mean much for a sound, it is just a float. What 'makes' the sound- are the variations of that float in the time.-- :ivar nchannels: Number of channels (one or two for mono or stereo)."""@@ -54,10 +57,16 @@ class AudioClip(Clip):Transforms the sound into an array that can be played by pygameor written in a wav file. See ``AudioClip.preview``.- :param fps: frame rate of the sound. 44100 gives top quality.+ Parameters+ ------------++ fps+ Frame rate of the sound for the conversion.+ 44100 for top quality.- :param nbytes: number of bytes to encode the sound: 1 for 8bit- sound, 2 for 16bit, 4 for 32bit sound.+ nbytes+ Number of bytes to encode the sound: 1 for 8bit sound,+ 2 for 16bit, 4 for 32bit sound."""if tt is None:tt = np.arange(0,self.duration, 1.0/fps)@@ -81,7 +90,6 @@ class AudioClip(Clip):codec, bitrate, verbose)try:-# Add method preview (only if pygame installed)from moviepy.audio.io.preview import previewAudioClip.preview = preview@@ -95,7 +103,16 @@ class AudioArrayClip(AudioClip):An audio clip made from a sound array.- :param fps: Frames per rate+ Parameters+ -------------++ array+ A Numpy array representing the sound, of size Nx1 for mono,+ Nx2 for stereo.++ fps+ Frames per second : speed at which the sound is supposed to be+ played."""@@ -133,10 +150,13 @@ class CompositeAudioClip(AudioClip):An audio clip made by putting together several audio clips.- :param clips: a list of audio clips, which may start playing at- different times or together. If all have their ``duration``- attribute set, the duration of the composite clip is computed- automatically.+ Parameters+ ------------++ clips+ List of audio clips, which may start playing at different times or+ together. If all have their ``duration`` attribute set, the+ duration of the composite clip is computed automatically."""diff --git a/moviepy/audio/io/AudioFileClip.py b/moviepy/audio/io/AudioFileClip.pyindex 05bf3d97..e838057e 100644--- a/moviepy/audio/io/AudioFileClip.py+++ b/moviepy/audio/io/AudioFileClip.py@@ -1,9 +1,7 @@from __future__ import division-import waveimport numpy as np-from moviepy.Clip import Clipfrom moviepy.audio.AudioClip import AudioClipfrom moviepy.audio.io.readers import FFMPEG_AudioReader@@ -16,20 +14,38 @@ class AudioFileClip(AudioClip):and after the last frames read, so that it is fast to read the soundbackward and forward.+ Parameters+ ------------- :param snd: Either a soundfile or an array representing a sound. If- the soundfile is not a .wav, it will be converted to .wav first,- using the ``fps`` and ``bitrate`` arguments.+ snd+ Either a soundfile name (of any extension supported by ffmpeg)+ or an array representing a sound. If the soundfile is not a .wav,+ it will be converted to .wav first, using the ``fps`` and+ ``bitrate`` arguments.- :param buffersize: Size to load in memory (in number of frames)- :param temp_wav: name for the temporary wav file in case conversion- is required. If not provided, the default will be filename.wav- with some prefix. If the temp_wav already exists it will not- be rewritten.+ buffersize:+ Size to load in memory (in number of frames)++ temp_wav:+ Name for the temporary wav file in case conversion is required.+ If not provided, the default will be filename.wav with some prefix.+ If the temp_wav already exists it will not be rewritten.+- :ivar nbytes: Number of bits per frame of the original audio file- (the more the better).- :ivar fps, buffersize: see above.+ Attributes+ ------------++ nbytes+ Number of bits per frame of the original audio file.++ fps+ Number of frames per second in the audio file++ buffersize+ See Parameters.++ Examples+ ---------->>> snd = SoundClip("song.wav")>>> snd = SoundClip("song.mp3", fps = 44100, bitrate=3000)@@ -40,7 +56,7 @@ class AudioFileClip(AudioClip):def __init__(self, filename, buffersize=200000, nbytes=2, fps=44100):- Clip.__init__(self)+ AudioClip.__init__(self)self.filename = filenameself.reader = FFMPEG_AudioReader(filename,fps=fps,nbytes=nbytes,@@ -97,14 +113,14 @@ class AudioFileClip(AudioClip):@propertydef nchannels(self):"""- returns the number of channels of the reader+ R eturns the number of channels of the reader(1: mono, 2: stereo)"""return self.reader.nchannelsdef _buffer_around(self,framenumber):"""- fill the buffer with frames, centered on ``framenumber``+ Fills the buffer with frames, centered on ``framenumber``if possible"""diff --git a/moviepy/audio/io/ffmpeg_audiowriter.py b/moviepy/audio/io/ffmpeg_audiowriter.pyindex 5fbd64e1..3c8b6301 100644--- a/moviepy/audio/io/ffmpeg_audiowriter.py+++ b/moviepy/audio/io/ffmpeg_audiowriter.py@@ -1,7 +1,6 @@from __future__ import divisionimport sys-import waveimport numpy as npimport subprocess as sp@@ -11,28 +10,29 @@ from moviepy.decorators import requires_durationclass FFMPEG_AudioWriter:- """ A class to read videos using ffmpeg. ffmpeg will read any kind- of videos and transform them into raw data (a long string that- can be reshaped into a RGB array).-- :param filename: Any filename like 'video.mp4' etc. but if you- want to avoid complications it is recommended to use the- generic extension '.avi' for all your videos.- :param size: size (width,height) of the output video.- :param fps: frames per second of the output video.- :param codec: ffmpeg codec. It seems that in terms of quality- the hierarchy is-- 'rawvideo' = 'png' > 'mpeg4' > 'libx264'-- 'png' manages the same lossless quality as 'rawvideo' but- yields smaller files.-- (type ffmpeg -codecs in a terminal)- :param bitrate: only relevant for codecs which accept a bitrate- bitrate = "5000k" offers nice results in general- :param withmask: True if there is a mask in the video to be- decoded.+ """+ A class to write an AudioClip into an audio file.++ Parameters+ ------------++ filename+ Name of any video or audio file, like ``video.mp4`` or ``sound.wav`` etc.++ size+ Size (width,height) in pixels of the output video.++ fps_input+ Frames per second of the input audio (given by the AUdioClip being+ written down).++ codec+ Name of the ffmpeg codec to use for the output.++ bitrate:+ A string indicating the bitrate of the final video. Only+ relevant for codecs which accept a bitrate.+"""@@ -52,14 +52,15 @@ class FFMPEG_AudioWriter:+ ['-acodec', codec]+ (['-b',bitrate] if (bitrate!=None) else [])+ [ filename ])- self.proc = sp.Popen(cmd,stdin=sp.PIPE, stderr=sp.PIPE)+ self.proc = sp.Popen(cmd,stdin=sp.PIPE,+ stderr=sp.PIPE)def write_frames(self,frames_array):self.proc.stdin.write(frames_array.tostring())- #frames_array.tofile(self.proc.stdin) # only python 2.7def close(self):self.proc.stdin.close()+ self.proc.stderr.close()del self.proc@@ -67,6 +68,11 @@ class FFMPEG_AudioWriter:@requires_durationdef ffmpeg_audiowrite(clip, filename, fps, nbytes, buffersize,codec='libvorbis', bitrate=None, verbose=True):+ """+ A function that wraps the FFMPEG_AudioWriter to write an AudioClip+ to a file.+ """+if verbose:def verbose_print(s):sys.stdout.write(s)@@ -74,7 +80,7 @@ def ffmpeg_audiowrite(clip, filename, fps, nbytes, buffersize,else:verbose_print = lambda *a : None- verbose_print("Rendering audio %s\n"%filename)+ verbose_print("Writing audio in %s\n"%filename)writer = FFMPEG_AudioWriter(filename, fps, nbytes, clip.nchannels,codec=codec, bitrate=bitrate)@@ -89,4 +95,4 @@ def ffmpeg_audiowrite(clip, filename, fps, nbytes, buffersize,writer.write_frames(sndarray)writer.close()- verbose_print("audio done !")+ verbose_print("Done writing Audio in %s !\n"%filename)diff --git a/moviepy/audio/io/preview.py b/moviepy/audio/io/preview.pyindex 1547c5c8..70fe8620 100644--- a/moviepy/audio/io/preview.py+++ b/moviepy/audio/io/preview.py@@ -1,11 +1,8 @@import time-import numpy as np-import threading-import sys-import numpy as npfrom moviepy.decorators import requires_duration+import pygame as pgpg.init()@@ -18,24 +15,29 @@ def preview(clip, fps=22050, buffersize=50000, nbytes= 2,"""Plays the sound clip with pygame.- :param fps: frame rate of the sound. 44100 gives top quality, but- may cause problems if your computer is not fast enough and- your clip is complicated. If the sound jumps during the- preview lower it (11025 is still fine, 5000 is tolerable).+ Parameters+ -----------++ fps+ Frame rate of the sound. 44100 gives top quality, but may cause+ problems if your computer is not fast enough and your clip is+ complicated. If the sound jumps during the preview, lower it+ (11025 is still fine, 5000 is tolerable).- :param buffersize: The sound is not generated all at once, but- rather made by bunches of frames (chunks). ``buffersize``- is the size of such a chunk. Try varying it if you meet- audio problems (but you shouldn't have to).+ buffersize+ The sound is not generated all at once, but rather made by bunches+ of frames (chunks). ``buffersize`` is the size of such a chunk.+ Try varying it if you meet audio problems (but you shouldn't+ have to).++ nbytes:+ Number of bytes to encode the sound: 1 for 8bit sound, 2 for+ 16bit, 4 for 32bit sound. 2 bytes is fine.- :param nbytes: number of bytes to encode the sound: 1 for 8bit- sound, 2 for 16bit, 4 for 32bit sound. 2 bytes is fine.+ audioFlag, videoFlag:+ Instances of class threading events that are used to synchronize+ video and audio during ``VideoClip.preview()``.- :param audioFlag, videoFlag: parameters whose sole purpose is to- enable a good synchronization of the start of video and sound- when the audio clip is played as the background of a video- clip. ``audioFlag`` and ``videoFlag`` are threading.Event- objects (from Python's standard threading module)."""pg.mixer.quit()diff --git a/moviepy/audio/io/readers.py b/moviepy/audio/io/readers.pyindex d3f18c7a..79af1e8c 100644--- a/moviepy/audio/io/readers.py+++ b/moviepy/audio/io/readers.py@@ -7,8 +7,34 @@ from moviepy.conf import FFMPEG_BINARYclass FFMPEG_AudioReader:- """ streams any file (audio or video) and outputs a 16bit 44100HZ- wav that can be read by the moviepy AudioFileClip. """+ """+ A class to read the audio in either video files or audio files+ using ffmpeg. ffmpeg will read any audio and transform them into+ raw data.++ Parameters+ ------------++ filename+ Name of any video or audio file, like ``video.mp4`` or+ ``sound.wav`` etc.++ bufsize+ The size of the buffer to use. Should be bigger than the buffer+ used by ``to_audiofile``++ print_infos+ Print the ffmpeg infos on the file being read (for debugging)++ fps+ Desired frames per second in the decoded signal that will be+ received from ffmpeg++ nbytes+ Desired number of bytes (1,2,4) in the signal that will be+ received from ffmpeg++ """def __init__(self, filename, bufsize, print_infos=False,fps=44100, nbytes=2):@@ -74,7 +100,6 @@ class FFMPEG_AudioReader:'-ar', "%d"%self.fps,'-ac', '%d'%self.nchannels, '-'])self.proc = sp.Popen( cmd, bufsize=self.bufsize,- stdin=sp.PIPE,stdout=sp.PIPE,stderr=sp.PIPE)self.pos = int(self.fps*starttime)@@ -101,12 +126,13 @@ class FFMPEG_AudioReader:return resultdef seek(self,pos):- """ Reads a frame at time t. Note for coders:- getting an arbitrary frame in the video with ffmpeg can be- painfully slow if some decoding has to be done. This- function tries to avoid fectching arbitrary frames whenever- possible, by moving between adjacent frames.- """+ """+ Reads a frame at time t. Note for coders: getting an arbitrary+ frame in the video with ffmpeg can be painfully slow if some+ decoding has to be done. This function tries to avoid fectching+ arbitrary frames whenever possible, by moving between adjacent+ frames.+ """if (pos < self.pos) or (pos> (self.pos+1000000)):t = 1.0*pos/self.fpsself.initialize(t)@@ -118,16 +144,17 @@ class FFMPEG_AudioReader:def close_proc(self):if self.proc is not None:self.proc.terminate()- for std in [self.proc.stdin,- self.proc.stdout,+ for std in [ self.proc.stdout,self.proc.stderr]:std.close()del self.proc++ def __del__(self):+ self.close_proc()+ del self.lastread---+class WaveReader:""" DEPRECATED - Do not use if you can avoid. """diff --git a/moviepy/audio/io/wav_writer.py b/moviepy/audio/io/wav_writer.pydeleted file mode 100644index c6c8ddb7..00000000--- a/moviepy/audio/io/wav_writer.py+++ /dev/null@@ -1,38 +0,0 @@-import sys-import wave-import numpy as np-import subprocess as sp--def wave_write(clip, filename,fps, nbytes, buffersize, verbose):- """ Writes an audioclip down to a wav file. Deprecated if the- ffmpeg writer works as expected. Otherwise, a good safety wheel- """- if verbose:- def verbose_print(s):- sys.stdout.write(s)- sys.stdout.flush()- else:- verbose_print = lambda *a : None-- verbose_print("Rendering audio %s\n"%filename)-- totalsize = int(fps*clip.duration)- # initialize the wave file with Python's wave module- wavf = wave.open(filename, 'wb')- wavf.setnchannels(clip.nchannels)- wavf.setsampwidth(nbytes)- wavf.setframerate(fps)- wavf.setnframes(totalsize)-- # Simply append chunks with Python's open- nchunks = totalsize / buffersize + 1- pospos = np.array(list(range(0, totalsize, buffersize))+[totalsize])- ifeedback = max(1,nchunks/10)- for i in range(nchunks):- if ( (i% ifeedback) == 0): verbose_print("=")- tt = (1.0/fps)*np.arange(pospos[i],pospos[i+1])- sndarray = clip.to_soundarray(tt,nbytes)- wavf.writeframes(sndarray.tostring())- wavf.close()-- verbose_print("audio done!")diff --git a/moviepy/video/VideoClip.py b/moviepy/video/VideoClip.pyindex 24eaa8d8..2ce42fc0 100644--- a/moviepy/video/VideoClip.py+++ b/moviepy/video/VideoClip.py@@ -5,12 +5,9 @@ main subclasses:- Static image clips: ImageClip, ColorClip, TextClip,"""-import timeimport os-import sysimport subprocessimport multiprocessing-import threadingfrom copy import copyfrom tqdm import tqdm@@ -35,85 +32,122 @@ from ..conf import FFMPEG_BINARYclass VideoClip(Clip):-- """+ """Base class for video clips++ See ``VideofileClip``, ``ImageClip`` etc. for more user-friendly+ classes.+++ Parameters+ ------------ Base class for video clips. See ``VideofileClip``, ``ImageClip`` etc. for- more user-friendly classes.+ ismask :+ `True` if the clip is going to be used as a mask.- :param ismask: `True` if the clip is going to be used as a mask.- :ivar size: the size of the clip, (width,heigth), in pixels.- :ivar w: te width of the clip, in pixels.- :ivar h: te height of the clip, in pixels.+ Attributes+ ----------+ size+ The size of the clip, (width,heigth), in pixels.++ w, h+ The width and height of the clip, in pixels.++ ismask+ Boolean set to `True` if the clip is a mask.- :ivar get_frame: A function ( t-> frame at time t )+ get_frame+ A function ``t-> frame at time t`` where ``frame`` is a+ w*h*3 RGB array.- :ivar mask: VideoClip mask attached to this clip. If mask is ``None``,+ mask (default None)+ VideoClip mask attached to this clip. If mask is ``None``,The video clip is fully opaque.- :ivar audio: A :class:AudioClip attached to the video clip.+ audio (default None)+ An AudioClip instance containing the audio of the video clip.- :ivar pos: a function ``t->(x,y)`` where ``x,y`` is the position- in pixels of the clip when it is composed with other clips.- See ``VideoClip.set_pos``+ pos+ A function ``t->(x,y)`` where ``x,y`` is the position+ of the clip when it is composed with other clips.+ See ``VideoClip.set_pos`` for more details- :ivar relative_pos: see variable ``pos``.-- :ivar ismask: Boolean set to `True` if the clip is a mask.--+ relative_pos+ See variable ``pos``.+"""- def __init__(self, ismask=False):+ def __init__(self, ismask=False, get_frame=None):Clip.__init__(self)self.mask = Noneself.audio = Noneself.pos = lambda t: (0, 0)self.relative_pos = False+ if get_frame:+ self.get_frame = get_frame+ newclip.size = newclip.get_frame(0).shape[:2][::-1]self.ismask = ismask-+++@propertydef w(self):return self.size[0]-+++@propertydef h(self):return self.size[1]++def save_frame(self, filename, t=0, savemask=False):- """+ """Save a clip's frame to an image file.+Saves the frame of clip corresponding to time ``t`` in'filename'. If ``savemask`` is ``True`` the mask is saved in thealpha layer of the picture.+"""im = self.get_frame(t)if savemask and self.mask is not None:mask = 255 * self.mask.get_frame(t)im = np.dstack([im, mask]).astype('uint8')ffmpeg_write_image(filename, im)++@requires_durationdef to_directory(self, foldername, fps, transparent=True,overwrite=True, startFrame=0):- """+ """Writes the frames of the clip into a folder.+Writes the frames of the clip into a folder as png format,and returns the :class:DirectoryClip associated with thisfolder- :param foldername: name of the folder (what did you expect ?)+ Parameters+ ----------++ foldername+ Name of the folder (what did you expect ?)- :param fps: Number of frames per second of movie.+ fps+ Number of frames per second of movie.- :param transparent: If `True`, the png images generated will- possess an alpha layer representing the mask of the clip.+ transparent+ If `True`, the png images generated will possess an alpha+ layer representing the mask of the clip.- :param overwrite: If `True`, will overwrite the content of- `folder` if already existing.+ overwrite+ If `True`, will overwrite the content of `folder`+ if already existing.- :param startFrame: Useless for the moment, but may come in handy- once parallelization is implemented.+ startFrame:+ Useless for the moment, but may come in handy once+ parallelization is fully implemented."""print( "writing frames in [%s]" % foldername )@@ -148,39 +182,40 @@ class VideoClip(Clip):temp_audiofile=None,rewrite_audio = True, remove_temp = True,para = False, verbose = True):- """- Makes a video file out of the clip.- First the clip is transformed into a directory clip, which means- that the frames of the future movie are computed and stored in a- folder as png files.- Then a ``DirectoryClip`` is made out of this folder and- transformed into a movie using ffmpeg (see DirectoryClip.to_videofile)+ """ Write the clip to a videofile.- Returns the directory clip.+ Parameters+ ------------ :param filename: name of the video file. Whatever the codec used,- it is best to write the movie name as .avi+ filename+ Name of the video file. The extension must correspond to the+ codec used (see below), ar simply be '.avi'.- :param fps: Frames per second in the final movie.-- :param codec: Codec to use for image encoding. Can be- - 'rawvideo','png' : will produce a raw video, of perfect quality,- but possibly very huge size. 'png' is still lossless but produces- smaller files.- - 'mpeg4' : For nice quality, very well compressed videos.- - 'libx264' : A little better than 'mpeg4', a little heavier.- - Any of the (many) other codec supported by ffmpeg.+ fps+ Number of frames per second in the resulting video file.++ codec+ Codec to use for image encoding. Can be+ - 'rawvideo','png' : will produce a raw video, of perfect+ quality, but possibly very huge size. 'png' is still+ lossless but produces smaller files.+ - 'mpeg4' : For nice quality, very well compressed videos.+ - 'libx264' : A little better than 'mpeg4', a little heavier.+ - Any of the (many) other codec supported by ffmpeg.- :param audio: Either ``True``, ``False``, or a file name.- If ``True`` and the clip has an audio clip attached, this- audio clip will be incorporated as a soundtrack in the movie.- If ``audio`` is the name of a .wav file, this wav file will- be incorporated as a soundtrack in the movie.+ audio+ Either ``True``, ``False``, or a file name.+ If ``True`` and the clip has an audio clip attached, this+ audio clip will be incorporated as a soundtrack in the movie.+ If ``audio`` is the name of an audio file, this audio file will+ be incorporated as a soundtrack in the movie.- :param audiofps: frame rate to use when writing the sound.+ audiofps+ frame rate to use when writing the sound.- :param temp_wav: the name of the temporary audiofile to be- generated and incorporated in the the movie, if any.+ temp_wav+ the name of the temporary audiofile to be generated and+ incorporated in the the movie, if any."""@@ -189,8 +224,8 @@ class VideoClip(Clip):elif audio_codec == 'raw32':audio_codec = 'pcm_s32le'- verbose_print = (sys_write_flush if verbose- else (lambda *a : None) )+ def verbose_print(s):+ if verbose: sys_write_flush(s)if isinstance(audio, str):# audio is some audiofile it is maybe not a wav file. It is@@ -248,7 +283,8 @@ class VideoClip(Clip):# enough cpu for multiprocessing ?enough_cpu = (multiprocessing.cpu_count() > 2)- verbose_print("Making file %s ...\n"%filename)+ verbose_print("\nMoviePy: building video file %s\n"%filename+ +40*"-"+"\n")if para and make_audio and enough_cpu:# Parallelize@@ -277,7 +313,7 @@ class VideoClip(Clip):# Merge with audio if any and trash temporary files.if merge_audio:- verbose_print("\nNow merging video and audio...\n")+ verbose_print("\n\nNow merging video and audio:\n")ffmpeg_merge_video_audio(videofile,temp_audiofile,filename, ffmpeg_output=True)@@ -285,8 +321,8 @@ class VideoClip(Clip):os.remove(videofile)if not isinstance(audio,str):os.remove(temp_audiofile)- verbose_print("\nYour video is ready ! Fingers crossed"+- " for the Oscars !")+ verbose_print("\nYour video is ready ! Fingers crossed"+ " for the Oscars !\n")def blit_on(self, picture, t):@@ -348,34 +384,49 @@ class VideoClip(Clip):def to_gif(self, filename, fps=None, program= 'ImageMagick',opt="OptimizeTransparency", fuzz=1, verbose=True,loop=0, dispose=False):- """+ """ Write the VideoClip to a GIF fileConverts a VideoClip into an animated GIF using ImageMagick orffmpeg.- :param clip: the VideoClip to be converted.- :param filename: name of the gif, like 'myAnimation.gif'- :param fps: number of frames per second (see note below). If it+++ Parameters+ -----------++ filename+ Name of the resulting gif file.++ fps+ Number of frames per second (see note below). If itisn't provided, then the function will look for the clip's``fps`` attribute (VideoFileClip, for instance, have one).- :param program: software to use for the conversion, either- 'ImageMagick' or 'ffmpeg'.- :param opt: (ImageMagick only) optimalization to apply, either- 'optimizeplus' or 'OptimizeTransparency'.- :param fuzz: (ImageMagick only) Compresses the GIF by considering- that the colors that are less than fuzz% different are in fact- the same.--- *Note:* The gif will be playing the clip in real time (you can- only change the frame rate). If you want the gif to be slower- than the clip you will write++ program+ Software to use for the conversion, either 'ImageMagick' or+ 'ffmpeg'.++ opt+ (ImageMagick only) optimalization to apply, either+ 'optimizeplus' or 'OptimizeTransparency'.++ fuzz+ (ImageMagick only) Compresses the GIF by considering that the+ colors that are less than fuzz% different are in fact the same.+++ Notes+ -----++ The gif will be playing the clip in real time (you can+ only change the frame rate). If you want the gif to be played+ slower than the clip you will use ::>>> # slow down clip 50% and make it a gif- >>> myClip.speedx(0.5).+ >>> myClip.speedx(0.5).to_gif('myClip.gif')"""- def verboseprint(s):- if verbose: print( "MoviePy: " + s )+ def verbose_print(s):+ if verbose: sys_write_flush(s)if fps is None:fps = self.fps@@ -384,14 +435,20 @@ class VideoClip(Clip):tt = np.arange(0,self.duration, 1.0/fps)tempfiles = []- verboseprint( "Generating GIF frames" )+ verbose_print("\nMoviePy: building GIF file %s\n"%filename+ +40*"-"+"\n")++ verbose_print("Generating GIF frames.\n")- for i, t in enumerate(tt):+ total = int(self.duration/fps)+1+ for i, t in tqdm(enumerate(tt), total=total):- name = "%s_GIFTEMP%04d.png"%(fileName,i+1)+ name = "%s_GIFTEMP%04d.png"%(fileName, i+1)tempfiles.append(name)self.save_frame(name, t, savemask=True)-++ verbose_print("Done generating GIF frames.\n")+delay = int(100.0/fps)if program == "ImageMagick":@@ -419,17 +476,24 @@ class VideoClip(Clip):for f in tempfiles:os.remove(f)-+++#-----------------------------------------------------------------# F I L T E R I N G+def subfx(self, fx, ta=0, tb=None, **kwargs):- """+ """ Apply a transformation to a part of the clip.+Returns a new clip in which the function ``fun`` (clip->clip) hasbeen applied to the subclip between times `ta` and `tb` (inseconds).+ Examples+ ---------+>>> # The scene between times t=3s and t=6s in ``clip`` will be>>> # be played twice slower in ``newclip``>>> newclip = clip.subapply(lambda c:c.speedx(0.5) , 3,6)@@ -447,48 +511,69 @@ class VideoClip(Clip):return cc+# IMAGE FILTERS- def fl_image(self, image_func, applyto=[]):- """ Modifies the images of a clip by replacing the frame- `get_frame(t)` by another frame, `image_func(get_frame(t))`++ def fl_image(self, image_func, apply_to=[]):+ """+ Modifies the images of a clip by replacing the frame+ `get_frame(t)` by another frame, `image_func(get_frame(t))`"""- return self.fl(lambda gf, t: image_func(gf(t)), applyto)+ return self.fl(lambda gf, t: image_func(gf(t)), apply_to)#--------------------------------------------------------------# C O M P O S I T I N G+def add_mask(self, constant_size=True):- """+ """ Add a mask VideoClip to the VideoClip.+Returns a copy of the clip with a completely opaque mask- (made of ones). This makes computations slow compared to having- a None mask but can be useful in many cases. Choose+ (made of ones). This makes computations slower compared to+ having a None mask but can be useful in many cases. Choose- :param constant_size: `False` for clips with moving image size.+ Set ``constant_size`` to `False` for clips with moving+ image size."""if constant_size:mask = ColorClip(self.size, 1.0, ismask=True)return self.set_mask( mask.set_duration(self.duration))else:- mask = VideoClip(ismask=True).set_get_frame(- lambda t: np.ones(self.get_frame(t).shape))+ get_frame = lambda t: np.ones(self.get_frame(t).shape)+ mask = VideoClip(ismask=True, get_frame = get_frame)return self.set_mask(mask.set_duration(self.duration))-+++def on_color(self, size=None, color=(0, 0, 0), pos=None,col_opacity=None):- """+ """ Place the clip on a colored background.+Returns a clip made of the current clip overlaid on a colorclip of a possibly bigger size. Can serve to flatten transparent- clips+ clips.++ Parameters+ -----------++ size+ Size (width, height) in pixels of the final clip.+ By default it will be the size of the current clip.- :param size: size of the final clip. By default it will be the- size of the current clip.- :param bg_color: the background color of the final clip- :param pos: the position of the clip in the final clip.- :param col_opacity: should the added zones be transparent ?+ bg_color+ Background color of the final clip ([R,G,B]).++ pos+ Position of the clip in the final clip.++ col_opacity+ Parameter in 0..1 indicating the opacity of the colored+ background.+"""- from compositing.CompositeVideoClip import CompositeVideoClip+ from .compositing.CompositeVideoClip import CompositeVideoClipif size is None:size = self.sizeif pos is None:@@ -506,27 +591,46 @@ class VideoClip(Clip):return result+def set_get_frame(self, gf):+ """ Change the clip's ``get_frame``.++ Returns a copy of the VideoClip instance, with the get_frame+ attribute set to `gf`.+ """newclip = Clip.set_get_frame(self, gf)newclip.size = newclip.get_frame(0).shape[:2][::-1]return newclip-+++def set_audio(self, audioclip):- """ Returns a copy of the clip with the audio set to ``audio``,- which must be a VideoClip. """+ """ Attach an AudioClip to the VideoClip.++ Returns a copy of the VideoClip instance, with the `audio`+ attribute set to ``audio``, hich must be an AudioClip instance.+ """newclip = copy(self)newclip.audio = audioclipreturn newclip-+++def set_mask(self, mask):- """ Returns a copy of the clip with the mask set to ``mask``,- which must be a greyscale (values in 0-1) VideoClip"""+ """ Set the clip's mask.++ Returns a copy of the VideoClip with the mask attribute set to+ ``mask``, which must be a greyscale (values in 0-1) VideoClip"""+ assert mask.ismasknewclip = copy(self)newclip.mask = maskreturn newclip-+++def set_opacity(self, op):- """+ """ Set the opacity/transparency level of the clip.+Returns a semi-transparent copy of the clip where the mask ismultiplied by ``op`` (any float, normally between 0 and 1)."""@@ -537,15 +641,21 @@ class VideoClip(Clip):newclip.mask = newclip.mask.fl_image(lambda pic: op * pic)return newclip-+++@apply_to_maskdef set_pos(self, pos, relative=False):- """+ """ Set the clip's position in compositions.+Sets the position that the clip will have when includedin compositions. The argument ``pos`` can be either a couple``(x,y)`` or a function ``t-> (x,y)``. `x` and `y` mark thelocation of the top left corner of the clip, and can be- of several types:+ of several types.++ Examples+ ---------->>> clip.set_pos((45,150)) # x=45, y=150>>>@@ -572,28 +682,38 @@ class VideoClip(Clip):#--------------------------------------------------------------# CONVERSIONS++def to_ImageClip(self,t=0):"""Return an ImageClip made out of the clip's frame at time ``t``"""return ImageClip(self.get_frame(t))++def to_mask(self, canal=0):- """ Returns a mask a video clip made from the clip. """+ """+ Return a mask a video clip made from the clip.+ """if self.ismask:return selfelse:- newclip = self.fl_image(lambda pic: 1.0 * pic[:, :, canal] / 255)+ newclip = self.fl_image(lambda pic:+ 1.0 * pic[:, :, canal] / 255)newclip.ismask = Truereturn newclip-+++def to_RGB(self):"""- Returns a non-mask video clip made from the mask video clip.+ Return a non-mask video clip made from the mask video clip."""if self.ismask:newclip = self.fl_image(- lambda pic: np.dstack(3 * [255 * pic]).astype('uint8'))+ lambda pic: np.dstack(3 * [255 * pic]+ ).astype('uint8'))newclip.ismask = Falsereturn newclipelse:@@ -603,15 +723,25 @@ class VideoClip(Clip):#----------------------------------------------------------------# Audio++def without_audio(self):- """ Returns a copy of the clip with audio set to None. """+ """ Remove the clip's audio.++ Return a copy of the clip with audio set to None.++ """newclip = copy(self)newclip.audio = Nonereturn newclip++def afx(self, fun, *a, **k):- """- Returns a new clip whose audio has been transformed by ``fun``.+ """ Transform the clip's audio.++ Return a new clip whose audio has been transformed by ``fun``.+"""newclip = self.copy()newclip.audio = newclip.audio.fx(fun, *a, **k)@@ -651,27 +781,42 @@ VideoClip.show = showclass ImageClip(VideoClip):- """+ """ Class for non-moving VideoClips.A video clip originating from a picture. This clip will simply- display the given picture at all times. For instance:+ display the given picture at all times.++ Examples+ --------->>> 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).+ Parameters+ -----------++ img+ Any picture file (png, tiff, jpeg, etc.) or any array representing+ an RGB image (for instance a frame from a VideoClip).- :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.+ ismask+ Set this parameter to `True` if the clip is a mask.++ transparent+ Set this parameter to `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.+ Attributes+ -----------++ img+ Array representing the image of the clip."""-- def __init__(self, img, ismask=False, transparent=True, fromalpha=False):+++ def __init__(self, img, ismask=False, transparent=True,+ fromalpha=False):VideoClip.__init__(self, ismask=ismask)@@ -697,21 +842,27 @@ class ImageClip(VideoClip):self.size = img.shape[:2][::-1]self.img = img- def fl(self, fl, applyto=[], keep_duration=True):- """+++ def fl(self, fl, apply_to=[], keep_duration=True):+ """ General filter+Equivalent to VideoClip.fl . The result is no more an- ImageClip, it has the class VideoClip (as it may be animated)+ ImageClip, it has the class VideoClip (since 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,+ newclip = VideoClip.fl(self,fl, apply_to=apply_to,keep_duration=keep_duration)newclip.__class__ = VideoClipreturn newclip- def fl_image(self, image_func, applyto= []):- """- Similar to VideoClip.fl_image, but for ImageClip the+++ def fl_image(self, image_func, apply_to= []):+ """ Image-transformation filter.++ Does the same as VideoClip.fl_image, but for ImageClip thetranformed clip is computed once and for all at the beginning,and not for each 'frame'."""@@ -722,7 +873,7 @@ class ImageClip(VideoClip):newclip.get_frame = lambda t: arrnewclip.img = arr- for attr in applyto:+ for attr in apply_to:if hasattr(newclip, attr):a = getattr(newclip, attr)if a != None:@@ -730,14 +881,20 @@ class ImageClip(VideoClip):return newclip- def fl_time(self, timefun, applyto =['mask', 'audio']):- """+++ def fl_time(self, timefun, apply_to =['mask', 'audio']):+ """ Time-transformation filter.++ Applies a transformation to the clip's timeline+ (see Clip.fl_time).+This method does nothing for ImageClips (but it may affect their- masks of their audios). The result is still an ImageClip+ masks of their audios). The result is still an ImageClip."""newclip = self.copy()- for attr in applyto:+ for attr in apply_to:if hasattr(newclip, attr):a = getattr(newclip, attr)if a != None:@@ -748,18 +905,24 @@ class ImageClip(VideoClip):class ColorClip(ImageClip):- """- An ImageClip showing just one color.+ """ An ImageClip showing just one color.++ Parameters+ ------------ :param size: Size (width, height) in pixels of the clip+ size+ Size (width, height) in pixels of the clip.- :param color: If argument ``ismask`` is False, ``color`` indicates+ color+ If argument ``ismask`` is False, ``color`` indicatesthe 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 ?-+ ismask+ Set to true if the clip will be used as a mask."""++def __init__(self,size, col=(0, 0, 0), ismask=False):w, h = sizeshape = (h, w) if np.isscalar(col) else (h, w, len(col))@@ -770,59 +933,74 @@ class ColorClip(ImageClip):class TextClip(ImageClip):- """+ """ Class for autogenerated text clips.++ Creates an ImageClip originating from a script-generated text image.+ Requires ImageMagick.- An image clip originating from a script-generated text image.- Makes a text PNG using ImageMagick.+ Parameters+ ------------ :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`` .+ 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.+ 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.+ 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.+ 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.+ 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.+ 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.+ stroke_width+ Width of the stroke, 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``).+ method+ Either 'label' (default, 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.+ kerning+ Changes the default spacing between letters. For+ nstance ``kerning=-1`` will make the letters 1 pixel nearer from+ ach other compared to the default spacing.- :param align: center | East | West | South | North . Will work if- ``method`` is set to ``caption``+ align+ center | East | West | South | North . Will only work if ``method``+ is set to ``caption``- :param transparent: ``True`` (default) if you want to take into account- the transparency in the image.+ 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='Courier',+ def __init__(self, txt, size=None, color='black',+ bg_color='transparent', fontsize=None, font='Courier',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,+ tempfile='temp.png', temptxt='temp.txt',+ transparent=True, remove_temp=True,print_cmd=False):if not txt.startswith('@'):@@ -875,12 +1053,14 @@ class TextClip(ImageClip):os.remove(temptxt)except:pass-++@staticmethoddef list(arg):- """ Returns the list of all valid entries for the argument given- (can be ``font``, ``color``, etc...)- argument of ``TextClip`` """+ """+ 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]diff --git a/moviepy/video/fx/crop.py b/moviepy/video/fx/crop.pyindex 29d3b475..77a335eb 100644--- a/moviepy/video/fx/crop.py+++ b/moviepy/video/fx/crop.py@@ -61,4 +61,4 @@ def crop(clip, x1=None, y1=None, x2=None, y2=None,return clip.fl_image(lambda pic: pic[int(y1):int(y2), int(x1):int(x2)],- applyto=['mask'])+ apply_to=['mask'])diff --git a/moviepy/video/fx/mirror_x.py b/moviepy/video/fx/mirror_x.pyindex 217d1c50..5dab6966 100644--- a/moviepy/video/fx/mirror_x.py+++ b/moviepy/video/fx/mirror_x.py@@ -1,5 +1,5 @@-def mirror_x(clip, applyto= "mask"):+def mirror_x(clip, apply_to= "mask"):""" flips the clip horizontally (and its mask too, by default) """return clip.fl_image(lambda gf, t: gf(t)[:,::-1],- applyto = applyto)+ apply_to = apply_to)diff --git a/moviepy/video/fx/mirror_y.py b/moviepy/video/fx/mirror_y.pyindex 2414cb24..fe714bfb 100644--- a/moviepy/video/fx/mirror_y.py+++ b/moviepy/video/fx/mirror_y.py@@ -1,4 +1,4 @@def mirror_y(clip, apply_to= "mask"):""" flips the clip vertically (and its mask too, by default) """return clip.fl_image(lambda gf, t : gf(t)[::-1],- applyto = applyto)+ apply_to = apply_to)diff --git a/moviepy/video/fx/resize.py b/moviepy/video/fx/resize.pyindex eb99657f..b96d9e28 100644--- a/moviepy/video/fx/resize.py+++ b/moviepy/video/fx/resize.py@@ -1,7 +1,7 @@resize_possible = Truetry:-+ # TRY USING OpenCV AS RESIZERimport cv2resizer = lambda pic, newsize : cv2.resize(pic.astype('uint8'),tuple(map(int, newsize)),@@ -11,7 +11,7 @@ except ImportError:try:-+ # TRY USING PIL/PILLOW AS RESIZERfrom PIL import Imageimport numpy as npdef resizer(pic, newsize):@@ -28,11 +28,11 @@ except ImportError:return arr.reshape(newshape)except ImportError:-+ # TRY USING SCIPY AS RESIZERtry:from scipy.misc import imresizeresizer = lambda pic, newsize : imresize(pic,- map(int, newsize[::-1]))+ map(int, newsize[::-1]))except ImportError:resize_possible = False@@ -41,21 +41,32 @@ except ImportError:from moviepy.decorators import apply_to_mask+@apply_to_maskdef resize(clip, newsize=None, height=None, width=None):"""Returns a video clip that is a resized version of the clip.- :param newsize: can be either ``(height,width)`` in pixels or- a float representing a scaling factor. Or a function of time- returning one of these.+ Parameters+ ------------++ newsize:+ Can be either+ - ``(height,width)`` in pixels or a float representing+ - A scaling factor, like 0.5+ - A function of time returning one of these.- :param width: width of the new clip in pixel. The height is- then computed so that the width/height ratio is conserved.+ width:+ width of the new clip in pixel. The height is then computed so+ that the width/height ratio is conserved.- :param height: height of the new clip in pixel. The width is- then computed so that the width/height ratio is conserved.+ height:+ height of the new clip in pixel. The width is then computed so+ that the width/height ratio is conserved.++ Examples+ ---------->>> myClip.resize( (460,720) ) # New resolution: (460,720)>>> myClip.resize(0.6) # width and heigth multiplied by 0.6@@ -66,37 +77,55 @@ def resize(clip, newsize=None, height=None, width=None):w, h = clip.sizeif newsize != None:+def trans_newsize(ns):+if isinstance(ns, (int, float)):return [ns * w, ns * h]else:return ns+if hasattr(newsize, "__call__"):+newsize2 = lambda t : trans_newsize(newsize(t))+if clip.ismask:- fl = lambda gf,t: 1.0*resizer((255 * gf(t)).astype('uint8'),- newsize2(t))/255++ fun = lambda gf,t: (1.0*resizer((255 * gf(t))+ .astype('uint8'),+ newsize2(t))/255)else:- fl = lambda gf,t: resizer(gf(t).astype('uint8'),newsize2(t))- return clip.fl(fl)+ fun = lambda gf,t: resizer(gf(t).astype('uint8'),+ newsize2(t))++ return clip.fl(fun, keep_duration=True, apply_to='mask')else:+newsize = trans_newsize(newsize)elif height != None:+newsize = [w * height / h, height]+elif width != None:+newsize = [width, h * width / w]-+++if clip.ismask:+fl = lambda pic: 1.0*resizer((255 * pic).astype('uint8'),newsize)/255+else:+fl = lambda pic: resizer(pic.astype('uint8'), newsize)- return clip.fl_image(fl)+ return clip.fl_image(fl, apply_to='mask')if not resize_possible:diff --git a/moviepy/video/fx/rotation.py b/moviepy/video/fx/rotation.pyindex 77d54d56..9a92b9e1 100644--- a/moviepy/video/fx/rotation.py+++ b/moviepy/video/fx/rotation.py@@ -6,12 +6,12 @@ def rotation(clip, angle, apply_to_mask=True, unit='deg'):angle = 360*angle/(2*3.14159)if angle ==90:return clip.fl_image(lambda im : im.T[::-1],- applyto='mask' if apply_to_mask else [])+ apply_to='mask' if apply_to_mask else [])elif angle == -90:return clip.fl_image(lambda im : im.T,- applyto='mask' if apply_to_mask else [])+ apply_to='mask' if apply_to_mask else [])elif angle == 180:return clip.fl_image(lambda im : im[::-1,::-1],- applyto='mask' if apply_to_mask else [])+ apply_to='mask' if apply_to_mask else [])else:raise 'Angle not supported, only 90, -90, 180'diff --git a/moviepy/video/fx/scroll.py b/moviepy/video/fx/scroll.pyindex e7ff18c6..66ef5935 100644--- a/moviepy/video/fx/scroll.py+++ b/moviepy/video/fx/scroll.py@@ -1,6 +1,6 @@def scroll(clip, h=None, w=None, x_speed=0, y_speed=0,- x_start=0, y_start=0, applyto="mask"):+ x_start=0, y_start=0, apply_to="mask"):""" Scrolls horizontally or vertically a clip, e.g. to make endcredits """if h is None: h = clip.h@@ -9,4 +9,4 @@ def scroll(clip, h=None, w=None, x_speed=0, y_speed=0,x = x_start+int(x_speed*t)y = y_start+ int(y_speed*t)return gf(t)[y:y+h, x:x+w]- return clip.fl(f, applyto = applyto)+ return clip.fl(f, apply_to = apply_to)diff --git a/moviepy/video/io/VideoFileClip.py b/moviepy/video/io/VideoFileClip.pyindex 8b37213a..3711c4cd 100644--- a/moviepy/video/io/VideoFileClip.py+++ b/moviepy/video/io/VideoFileClip.py@@ -9,22 +9,41 @@ class VideoFileClip(VideoClip):"""- A video clip originating from a movie file. For instance:+ A video clip originating from a movie file. For instance: ::- >>> clip = VideofileClip("myHolidays.mp4")- >>> clip2 = VideofileClip("myMaskVideo.avi",ismask = True)+ >>> clip = VideofileClip("myHolidays.mp4")+ >>> clip2 = VideofileClip("myMaskVideo.avi",ismask = True)- :param filename: Any video file: .ogv, .mp4, .mpeg, .avi, .mov etc.- :param ismask: `True` if the clip is a mask.- :param has_mask: 'True' if there is a mask included in the videofile.- Commonly, video files don't have mask, but you can save the mask- for the videos that you make with MoviePy (see the doc from++ Parameters+ ------------++ filename:+ The name of the video file. It can have any extension supported+ by ffmpeg: .ogv, .mp4, .mpeg, .avi, .mov etc.++ ismask:+ Set this to `True` if the clip is going to be used as a mask.++ has_mask:+ Set this to 'True' if there is a mask included in the videofile.+ Video files rarely contain masks, but some video codecs enable+ that. For istance if you have a MoviePy VideoClip with a mask you+ can save it to a videofile with a mask. (see also``VideoClip.to_videofile`` for more details).- :param audio: If `True`, then the audio is extracted from the video- file, in wav format, and it attributed to the clip.- :ivar filename: Name of the original video file- :ivar fps: Frames per second in the original file.+ audio:+ Set to `False` if the clip doesn't have any audio or if you do not+ wish to read the audio.++ Attributes+ -----------++ filename:+ Name of the original video file.++ fps:+ Frames per second in the original file."""@@ -61,8 +80,17 @@ class VideoFileClip(VideoClip):nbytes = audio_nbytes)def coreader(self, audio=True):- """ Returns a copy of the AudioFileClip, i.e. a- new entrance point to the video file. Use copy- when you have different clips watching the same- video file at different times. """+ """+ Returns a copy of the AudioFileClip with an autonomous reader.+ Maybe REMOVED in the coming versions. Wait and see. ::++ >>> clip = VideofileClip("myHolidays.mp4", ismask=True)+ >>> clip2 = VideofileClip("myHolidays.mp4", ismask=True)++ is equivalent to ::++ >>> clip = VideofileClip("myHolidays.mp4", ismask=True)+ >>> clip2 = clip.coreader()+ """+return VideoFileClip(**self.parameters)diff --git a/moviepy/video/io/ffmpeg_reader.py b/moviepy/video/io/ffmpeg_reader.pyindex 1a989034..5e715d59 100644--- a/moviepy/video/io/ffmpeg_reader.py+++ b/moviepy/video/io/ffmpeg_reader.py@@ -34,7 +34,7 @@ class FFMPEG_VideoReader:self.lastread = self.read_frame()def initialize(self, starttime=0):- """ Opens the file, creates the pipe. """+ """Opens the file, creates the pipe. """self.close_proc() # if any@@ -54,16 +54,19 @@ class FFMPEG_VideoReader:self.proc = sp.Popen(cmd, bufsize= self.bufsize,- stdin=sp.PIPE,stdout=sp.PIPE,stderr=sp.PIPE)-+def load_infos(self, print_infos=False):- """ reads the FFMPEG info on the file and sets self.size- and self.fps """+ """Get file infos using ffmpeg.++ Grabs the FFMPEG info on the file and use them to set the+ attributes ``self.size`` and ``self.fps`` """+# open the file in a pipe, provoke an error, read outputproc = sp.Popen([FFMPEG_BINARY, "-i", self.filename, "-"],+ bufsize=10**6,stdin=sp.PIPE,stdout=sp.PIPE,stderr=sp.PIPE)@@ -96,17 +99,8 @@ class FFMPEG_VideoReader:self.duration = cvsecs(*hms)self.nframes = int(self.duration*self.fps)- def close_proc(self):- if self.proc is not None:- self.proc.terminate()- for std in (self.proc.stdin,- self.proc.stdout,- self.proc.stderr):- std.close()- del self.proc-def skip_frames(self, n=1):- """ Reads and throws away n frames """+ """Reads and throws away n frames """w, h = self.sizefor i in range(n):self.proc.stdout.read(self.depth*w*h)@@ -116,18 +110,18 @@ class FFMPEG_VideoReader:def read_frame(self):w, h = self.size+ nbytes= self.depth*w*htry:- # Normally, the readr should not read after the last frame...+ # Normally, the reader should not read after the last frame.# if it does, raise an error.- nbytes= self.depth*w*hs = self.proc.stdout.read(nbytes)- #self.proc.terminate()- #print( self.proc.stderr.read(10000))assert len(s) == nbytesresult = np.fromstring(s,dtype='uint8').reshape((h, w, len(s)//(w*h)))self.proc.stdout.flush()+except IOError:+self.proc.terminate()serr = self.proc.stderr.read()print( "error: string: %s, stderr: %s" % (s, serr))@@ -138,11 +132,12 @@ class FFMPEG_VideoReader:return resultdef get_frame(self, t):- """ Reads a frame at time t. Note for coders:- getting an arbitrary frame in the video with ffmpeg can be- painfully slow if some decoding has to be done. This- function tries to avoid fectching arbitrary frames whenever- possible, by moving between adjacent frames.+ """ Read a file video frame at time t.++ Note for coders: getting an arbitrary frame in the video with+ ffmpeg can be painfully slow if some decoding has to be done.+ This function tries to avoid fectching arbitrary frames whenever+ possible, by moving between adjacent frames."""if t < 0:t = 0@@ -160,13 +155,42 @@ class FFMPEG_VideoReader:result = self.read_frame()self.pos = posreturn result++ def close_proc(self):+ if self.proc is not None:+ self.proc.terminate()+ self.proc.stdout.close()+ self.proc.stderr.close()+ del self.proc++ def __del__(self):+ self.close_proc()+ del self.lastread+def ffmpeg_read_image(filename, with_mask=True):+ """ Read one image from a file.++ Wraps FFMPEG_Videoreader to read just one image. Returns an+ ImageClip.++ Parameters+ -----------++ filename+ Name of the image file. Can be of any format supported by ffmpeg.++ with_mask+ If the image has a transparency layer, ``with_mask=true`` will save+ this layer as the mask of the returned ImageClip++ """if with_mask:pix_fmt = 'rgba'else:pix_fmt = "rgb24"- vf = FFMPEG_VideoReader(filename, pix_fmt=pix_fmt)- vf.close_proc()- return vf.lastread+ reader = FFMPEG_VideoReader(filename, pix_fmt=pix_fmt)+ im = reader.lastread+ del reader+ return imdiff --git a/moviepy/video/io/ffmpeg_writer.py b/moviepy/video/io/ffmpeg_writer.pyindex d6ac3734..f59458db 100644--- a/moviepy/video/io/ffmpeg_writer.py+++ b/moviepy/video/io/ffmpeg_writer.py@@ -54,9 +54,7 @@ class FFMPEG_VideoWriter:['-b',bitrate] if (bitrate!=None) else []) + ['-r', "%d"%fps,filename ]- self.proc = sp.Popen(cmd,stdin=sp.PIPE,- stdout=sp.PIPE,- stderr=sp.PIPE)+ self.proc = sp.Popen(cmd,stdin=sp.PIPE, stderr=sp.PIPE)def write_frame(self,img_array):self.proc.stdin.write(img_array.tostring())@@ -77,7 +75,7 @@ def ffmpeg_write_video(clip, filename, fps, codec="libx264", bitrate=None,else:verbose_print = lambda *a : None- verbose_print("Rendering video %s\n"%filename)+ verbose_print("\nWriting video into %s\n"%filename)writer = FFMPEG_VideoWriter(filename, clip.size, fps, codec = codec,bitrate=bitrate)@@ -92,7 +90,7 @@ def ffmpeg_write_video(clip, filename, fps, codec="libx264", bitrate=None,writer.write_frame(frame.astype("uint8"))writer.close()- verbose_print("video done !")+ verbose_print("Done writing video in %s !"%filename)def ffmpeg_write_image(filename, image):diff --git a/moviepy/video/tools/credits.py b/moviepy/video/tools/credits.pyindex 367549e0..7ca7875c 100644--- a/moviepy/video/tools/credits.py+++ b/moviepy/video/tools/credits.py@@ -13,7 +13,12 @@ def credits1(creditfile,width,stretch=30,color='white',font='Impact-Normal',fontsize=60):"""- The first credits I imagined. They take as argument a file like: ::++ Parameters+ -----------++ creditfile:+ A text file whose content must be as follows: ::# This is a comment# The next line says : leave 4 blank lines@@ -28,18 +33,30 @@ def credits1(creditfile,width,stretch=30,color='white',..Music SupervisorJEAN DIDIER++ width:+ Total width of the credits text in pixels++ gap:+ Gap in pixels between the jobs and the names.++ **txt_kw:+ Additional argument passed to TextClip (font, colors, etc.)+++- And produce an ImageClip that looks like :+ Returns+ ---------++ An ImageClip instance that looks like this and can be scrolled+ to make some credits :Executive Story Editor MARCEL DURANDAssociate Producers MARTIN MARCELDIDIER MARTINMusic Supervisor JEAN DIDIER-- :param width: total width of the credits text- :param stretch: stretch in pixels between the jobs and the names.-- The other keywords are passed to the ``TextClip``s+"""@@ -76,8 +93,8 @@ def credits1(creditfile,width,stretch=30,color='white',for txt,al in [(left,'East'),(right,'West')]]- cc = CompositeVideoClip( [left, right.set_pos((left.w+stretch,0))],- size = (left.w+right.w+stretch,right.h),+ cc = CompositeVideoClip( [left, right.set_pos((left.w+gap,0))],+ size = (left.w+right.w+gap,right.h),transparent=True)# SCALE TO THE REQUIRED SIZEdiff --git a/setup.py b/setup.pyindex 9b8a4dc2..522eab94 100644--- a/setup.py+++ b/setup.py@@ -3,11 +3,13 @@import ez_setupez_setup.use_setuptools()+exec(open('moviepy/version.py').read()) # loads __version__+from setuptools import setup, find_packagessetup(name='moviepy',- version='0.2.1.7.05',- author='Zulko 2013',+ version=__version__,+ author='Zulko 2013',description='Module for script-based video editing',long_description=open('README.rst').read(),license='see LICENSE.txt',