udacity / CarND-Term1-Starter-Kit

MIT License
495 stars 602 forks source link

Error when write_videofile with moviepy #93

Closed jacks808 closed 6 years ago

jacks808 commented 6 years ago

Hi, I check out this project, install some dependencies and run test.ipynb. But, when I run to this:

new_clip.write_videofile(filename='test_output.mp4', audio=False)

An error occurred:

MoviePy error: FFMPEG encountered the following error while writing file

the full stack trace here:

[MoviePy] >>>> Building video test_output.mp4
[MoviePy] Writing video test_output.mp4
---------------------------------------------------------------------------
BrokenPipeError                           Traceback (most recent call last)
~/anaconda3/lib/python3.6/site-packages/moviepy/video/io/ffmpeg_writer.py in write_frame(self, img_array)
    133             if PY3:
--> 134                self.proc.stdin.write(img_array.tobytes())
    135             else:

BrokenPipeError: [Errno 32] Broken pipe

During handling of the above exception, another exception occurred:

OSError                                   Traceback (most recent call last)
<timed eval> in <module>()

<decorator-gen-175> in write_videofile(self, filename, fps, codec, bitrate, audio, audio_fps, preset, audio_nbytes, audio_codec, audio_bitrate, audio_bufsize, temp_audiofile, rewrite_audio, remove_temp, write_logfile, verbose, threads, ffmpeg_params, progress_bar)

~/anaconda3/lib/python3.6/site-packages/moviepy/decorators.py in requires_duration(f, clip, *a, **k)
     52         raise ValueError("Attribute 'duration' not set")
     53     else:
---> 54         return f(clip, *a, **k)
     55 
     56 

<decorator-gen-174> in write_videofile(self, filename, fps, codec, bitrate, audio, audio_fps, preset, audio_nbytes, audio_codec, audio_bitrate, audio_bufsize, temp_audiofile, rewrite_audio, remove_temp, write_logfile, verbose, threads, ffmpeg_params, progress_bar)

~/anaconda3/lib/python3.6/site-packages/moviepy/decorators.py in use_clip_fps_by_default(f, clip, *a, **k)
    135              for (k,v) in k.items()}
    136 
--> 137     return f(clip, *new_a, **new_kw)

<decorator-gen-173> in write_videofile(self, filename, fps, codec, bitrate, audio, audio_fps, preset, audio_nbytes, audio_codec, audio_bitrate, audio_bufsize, temp_audiofile, rewrite_audio, remove_temp, write_logfile, verbose, threads, ffmpeg_params, progress_bar)

~/anaconda3/lib/python3.6/site-packages/moviepy/decorators.py in convert_masks_to_RGB(f, clip, *a, **k)
     20     if clip.ismask:
     21         clip = clip.to_RGB()
---> 22     return f(clip, *a, **k)
     23 
     24 @decorator.decorator

~/anaconda3/lib/python3.6/site-packages/moviepy/video/VideoClip.py in write_videofile(self, filename, fps, codec, bitrate, audio, audio_fps, preset, audio_nbytes, audio_codec, audio_bitrate, audio_bufsize, temp_audiofile, rewrite_audio, remove_temp, write_logfile, verbose, threads, ffmpeg_params, progress_bar)
    347                            verbose=verbose, threads=threads,
    348                            ffmpeg_params=ffmpeg_params,
--> 349                            progress_bar=progress_bar)
    350 
    351         if remove_temp and make_audio:

~/anaconda3/lib/python3.6/site-packages/moviepy/video/io/ffmpeg_writer.py in ffmpeg_write_video(clip, filename, fps, codec, bitrate, preset, withmask, write_logfile, audiofile, verbose, threads, ffmpeg_params, progress_bar)
    214             frame = np.dstack([frame,mask])
    215 
--> 216         writer.write_frame(frame)
    217 
    218     writer.close()

~/anaconda3/lib/python3.6/site-packages/moviepy/video/io/ffmpeg_writer.py in write_frame(self, img_array)
    176 
    177 
--> 178             raise IOError(error)
    179 
    180     def close(self):

OSError: [Errno 32] Broken pipe

MoviePy error: FFMPEG encountered the following error while writing file test_output.mp4:

 b"Unrecognized option 'preset'.\nError splitting the argument list: Option not found\n"

ffmpeg version:

localhost:~ Keen$ ffmpeg
ffmpeg version 3.4 Copyright (c) 2000-2017 the FFmpeg developers
  built with clang version 4.0.1 (tags/RELEASE_401/final)
  configuration: --prefix=/Users/keen/anaconda3 --disable-doc --enable-shared --extra-cflags='-fPIC -I/Users/keen/anaconda3/include' --extra-cxxflags='=-fPIC' --extra-libs='-L/Users/keen/anaconda3/lib -lz' --enable-pic --disable-static --disable-gpl --disable-nonfree --disable-openssl --enable-libvpx --cc=x86_64-apple-darwin13.4.0-clang --cxx=x86_64-apple-darwin13.4.0-clang++ --enable-libopus
  libavutil      55. 78.100 / 55. 78.100
  libavcodec     57.107.100 / 57.107.100
  libavformat    57. 83.100 / 57. 83.100
  libavdevice    57. 10.100 / 57. 10.100
  libavfilter     6.107.100 /  6.107.100
  libswscale      4.  8.100 /  4.  8.100
  libswresample   2.  9.100 /  2.  9.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

Use -h to get full help or, even better, run 'man ffmpeg'

OS info:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>ProductBuildVersion</key>
        <string>17C205</string>
        <key>ProductCopyright</key>
        <string>1983-2018 Apple Inc.</string>
        <key>ProductName</key>
        <string>Mac OS X</string>
        <key>ProductUserVisibleVersion</key>
        <string>10.13.2</string>
        <key>ProductVersion</key>
        <string>10.13.2</string>
</dict>
</plist>

python version:

Python 3.6.3 |Anaconda custom (x86_64)| (default, Oct  6 2017, 12:04:38)
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

python dependencies:

localhost:~ Keen$ pip freeze
alabaster==0.7.10
anaconda-client==1.6.5
anaconda-navigator==1.6.10
anaconda-project==0.8.0
appnope==0.1.0
appscript==1.0.1
asn1crypto==0.22.0
astroid==1.5.3
astropy==2.0.2
Babel==2.5.0
backports.shutil-get-terminal-size==1.0.0
beautifulsoup4==4.6.0
bitarray==0.8.1
bkcharts==0.2
blaze==0.11.3
bleach==2.0.0
bokeh==0.12.10
boto==2.48.0
Bottleneck==1.2.1
bz2file==0.98
certifi==2016.2.28
cffi==1.10.0
chardet==3.0.4
click==6.7
cloudpickle==0.4.0
clyent==1.2.2
colorama==0.3.9
conda==4.4.9
conda-build==3.0.27
conda-verify==2.0.0
contextlib2==0.5.5
cryptography==2.0.3
cycler==0.10.0
Cython==0.26.1
cytoolz==0.8.2
dask==0.15.3
datashape==0.5.4
decorator==4.0.11
distributed==1.19.1
docutils==0.14
entrypoints==0.2.3
et-xmlfile==1.0.1
fastcache==1.0.2
filelock==2.0.12
Flask==0.12.2
Flask-Cors==3.0.3
gensim==2.3.0
gevent==1.2.2
glob2==0.5
gmpy2==2.0.8
greenlet==0.4.12
h5py==2.7.1
heapdict==1.0.0
html5lib==0.999999999
idna==2.6
imageio==2.1.2
imagesize==0.7.1
ipykernel==4.6.1
ipython==6.1.0
ipython-genutils==0.2.0
ipywidgets==7.0.0
isort==4.2.15
itsdangerous==0.24
jdcal==1.3
jedi==0.10.2
jieba==0.39
Jinja2==2.9.6
jsonschema==2.6.0
jupyter-client==5.1.0
jupyter-console==5.2.0
jupyter-core==4.3.0
jupyterlab==0.27.0
jupyterlab-launcher==0.4.0
lazy-object-proxy==1.3.1
llvmlite==0.20.0
locket==0.2.0
lxml==4.1.0
MarkupSafe==1.0
matplotlib==2.1.0
mccabe==0.6.1
mistune==0.7.4
moviepy==0.2.3.2
mpmath==0.19
msgpack-python==0.4.8
multipledispatch==0.4.9
navigator-updater==0.1.0
nb-anacondacloud==1.4.0
nb-conda==2.2.0
nb-conda-kernels==2.1.0
nbconvert==5.3.1
nbformat==4.4.0
nbpresent==3.0.2
networkx==2.0
nltk==3.2.4
nose==1.3.7
notebook==5.0.0
numba==0.35.0
numexpr==2.6.2
numpy==1.12.1
numpydoc==0.7.0
odo==0.5.1
olefile==0.44
opencv-python==3.4.0.12
openpyxl==2.4.8
packaging==16.8
pandas==0.20.3
pandocfilters==1.4.2
partd==0.3.8
path.py==10.3.1
pathlib2==2.3.0
patsy==0.4.1
pep8==1.7.0
pexpect==4.2.1
pickleshare==0.7.4
Pillow==4.2.1
pkginfo==1.4.1
ply==3.10
prompt-toolkit==1.0.15
protobuf==3.4.1
psutil==5.4.0
ptyprocess==0.5.2
py==1.4.34
pycodestyle==2.3.1
pycosat==0.6.3
pycparser==2.18
pycrypto==2.6.1
pycurl==7.43.0
pyflakes==1.6.0
Pygments==2.2.0
pylint==1.7.4
pyodbc==4.0.17
pyOpenSSL==17.2.0
pyparsing==2.2.0
PySocks==1.6.7
pytest==3.2.1
python-dateutil==2.6.1
pytz==2017.2
PyWavelets==0.5.2
PyYAML==3.12
pyzmq==16.0.2
QtAwesome==0.4.4
qtconsole==4.3.1
QtPy==1.3.1
requests==2.14.2
rope==0.10.5
ruamel-yaml==0.11.14
scikit-image==0.13.0
scikit-learn==0.19.1
scipy==0.19.1
seaborn==0.8
simplegeneric==0.8.1
singledispatch==3.4.0.3
six==1.11.0
smart-open==1.5.3
snowballstemmer==1.2.1
sortedcollections==0.5.3
sortedcontainers==1.5.7
Sphinx==1.6.3
sphinxcontrib-websupport==1.0.1
spyder==3.2.4
SQLAlchemy==1.1.13
statsmodels==0.8.0
sympy==1.1.1
tables==3.4.2
tblib==1.3.2
tensorflow==1.1.0
terminado==0.6
testpath==0.3.1
toolz==0.8.2
tornado==4.5.2
tqdm==4.11.2
traitlets==4.3.2
typing==3.6.2
unicodecsv==0.14.1
urllib3==1.22
wcwidth==0.1.7
webencodings==0.5.1
Werkzeug==0.12.2
widgetsnbextension==3.0.2
wrapt==1.10.11
xlrd==1.1.0
XlsxWriter==1.0.2
xlwings==0.11.4
xlwt==1.2.0
zict==0.1.3

source code at here

Any one who can help me?

jacks808 commented 6 years ago

run

conda install -c conda-forge ffmpeg

will fix this

xsqian commented 6 years ago

Hi Jack, thank you for the info, this solved my problem!