Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix issue #401 #403

Merged
merged 3 commits into from Feb 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions moviepy/audio/io/ffmpeg_audiowriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
import numpy as np
import subprocess as sp

import sys
PY3=sys.version_info.major >= 3

import os
try:
from subprocess import DEVNULL # py3k
Expand Down Expand Up @@ -82,14 +85,17 @@ def __init__(self, filename, fps_input, nbytes=2,

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

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

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

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

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

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

error = error+("\n\nThe audio export "
"failed, possily because the bitrate you specified "
Expand Down
17 changes: 12 additions & 5 deletions moviepy/video/io/ffmpeg_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
import os
import numpy as np

import sys

PY3 = sys.version_info.major >=3

try:
from subprocess import DEVNULL # py3k
except ImportError:
Expand Down Expand Up @@ -134,14 +138,17 @@ def __init__(self, filename, size, fps, codec="libx264", audiofile=None,
def write_frame(self, img_array):
""" Writes one frame in the file."""
try:
self.proc.stdin.write(img_array.tostring())
if PY3:
self.proc.stdin.write(img_array.tobytes())
else:
self.proc.stdin.write(img_array.tostring())
except IOError as err:
ffmpeg_error = self.proc.stderr.read()
error = (str(err) + ("\n\nMoviePy error: FFMPEG encountered "
"the following error while writing file %s:"
"\n\n %s" % (self.filename, ffmpeg_error)))

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

error = error+("\n\nThe video export "
"failed because FFMPEG didn't find the specified "
Expand All @@ -150,7 +157,7 @@ def write_frame(self, img_array):
"write_videofile. For instance:\n"
" >>> clip.write_videofile('myvid.webm', codec='libvpx')")%(self.codec)

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

error = error+("\n\nThe video export "
"failed, possibly because the codec specified for "
Expand All @@ -164,13 +171,13 @@ def write_frame(self, img_array):
"video codec."
)%(self.codec, self.ext)

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

error = error+("\n\nThe video export "
"failed, possibly because the bitrate you specified "
"was too high or too low for the video codec.")

elif "Invalid encoder type" in ffmpeg_error:
elif b"Invalid encoder type" in ffmpeg_error:

error = error + ("\n\nThe video export failed because the codec "
"or file extension you provided is not a video")
Expand Down