Skip to content

Video editing with Python

Fixed resize with PIL on Python3. Fixed image_write in ffmpeg_writer for Py3

Zulkoe397264ed826
diff --git a/moviepy/video/fx/resize.py b/moviepy/video/fx/resize.py
index 57370b47..eb99657f 100644
--- a/moviepy/video/fx/resize.py
+++ b/moviepy/video/fx/resize.py
@@ -15,7 +15,7 @@ except ImportError:
from PIL import Image
import numpy as np
def resizer(pic, newsize):
- newsize = map(int, newsize)[::-1]
+ newsize = list(map(int, newsize))[::-1]
shape = pic.shape
if len(shape)==3:
newshape = (newsize[0],newsize[1], shape[2] )
diff --git a/moviepy/video/io/ffmpeg_writer.py b/moviepy/video/io/ffmpeg_writer.py
index 165a8888..d6ac3734 100644
--- a/moviepy/video/io/ffmpeg_writer.py
+++ b/moviepy/video/io/ffmpeg_writer.py
@@ -98,13 +98,21 @@ def ffmpeg_write_video(clip, filename, fps, codec="libx264", bitrate=None,
def ffmpeg_write_image(filename, image):
""" Writes an image (HxWx3 or HxWx4 numpy array) to a file, using
ffmpeg. """
- proc = sp.Popen([ FFMPEG_BINARY, '-y',
- '-s', "%dx%d"%(image.shape[:2][::-1]),
- "-f", 'rawvideo',
- '-pix_fmt', "rgba" if (image.shape[2] == 4) else "rgb24",
- '-i','-', filename],
- stdin=sp.PIPE, stdout=sp.PIPE, stderr=sp.PIPE)
- image.tofile(proc.stdin)
+ cmd = [ FFMPEG_BINARY, '-y',
+ '-s', "%dx%d"%(image.shape[:2][::-1]),
+ "-f", 'rawvideo',
+ '-pix_fmt', "rgba" if (image.shape[2] == 4) else "rgb24",
+ '-i','-', filename]
+
+ proc = sp.Popen( cmd, stdin=sp.PIPE, stderr=sp.PIPE)
+ proc.stdin.write(image.tostring())
proc.stdin.close()
proc.wait()
+
+ if proc.returncode:
+ err = "\n".join(["MoviePy running : %s"%cmd,
+ "WARNING: this command returned an error:",
+ proc.stderr.read().decode('utf8')])
+ raise IOError(err)
+
del proc
diff --git a/setup.py b/setup.py
index fa5a04a9..8633bc5c 100644
--- a/setup.py
+++ b/setup.py
@@ -6,7 +6,7 @@ ez_setup.use_setuptools()
from setuptools import setup, find_packages
setup(name='moviepy',
- version='0.2.1.7.03',
+ version='0.2.1.7.04',
author='Zulko 2013',
description='Module for script-based video editing',
long_description=open('README.rst').read(),