Moviepy OSError Exec format error - Missing Shebang?

廉价感情. 提交于 2019-12-13 17:34:31

问题


I am attempting to use MoviePy with Python 3.2.3 on Raspian. I have installed it (for Python 2.7, 3.2 and 3.5... long story) and the line

from moviepy.editor import *

works fine. When I try

clip = VideoFileClip("vid.mov")

which is the most basic command, it gives the error

Traceback (most recent call last):
File "/home/pi/QuickFlicsPics/moviepytest.py", line 8, in <module>
  clip = VideoFileClip("vid.mov")
File "/usr/local/lib/python3.2/distpackages/moviepy/video/io/VideoFileClip.py", line 55, in __init__
  reader = FFMPEG_VideoReader(filename, pix_fmt=pix_fmt)
File "/usr/local/lib/python3.2/dist-packages/moviepy/video/io/ffmpeg_reader.py", line 32, in __init__
   infos = ffmpeg_parse_infos(filename, print_infos, check_duration)
File "/usr/local/lib/python3.2/dist-packages/moviepy/video/io/ffmpeg_reader.py", line 237, in ffmpeg_parse_infos
  proc = sp.Popen(cmd, **popen_params)
File "/usr/lib/python3.2/subprocess.py", line 745, in __init__
  restore_signals, start_new_session)
File "/usr/lib/python3.2/subprocess.py", line 1371, in _execute_child
  raise child_exception_type(errno_num, err_msg)

OSError: [Errno 8] Exec format error

I have researched this error, and it appears to be something to do with a shebang line missing somewhere. Is this correct, if so, how do I go about finding where it is missing, and what do I add? Thanks

Edit: As per cxw's comment, I installed moviepy using the command

pip-3.2 install moviepy

(I may have used 'sudo' as well)

FFMPEG was supposed to download automatically when I first used moviepy:

MoviePy depends on the software FFMPEG for video reading and writing. > You don’t need to worry about that, as FFMPEG should be automatically > downloaded/installed by ImageIO during your first use of MoviePy (it takes a few seconds). If you want to use a specific version of FFMPEG, follow the instructions in file config_defaults.py.

[Quote from installation guide here]


回答1:


Manually download ffmpeg, then before running your Python code, do

export FFMPEG_BINARY=path/to/ffmpeg

at the shell/terminal prompt.

As far as I can tell from the source, the automatic download of ffmpeg does not know about Raspberry Pis. The auto-download code pulls from the imageio github repo, which only knows "linux32" vs. "linux64". It doesn't look like it has an ARM-linux option. When the ARM kernel sees a non-ARM image, it throws the error you see.

Rather than using the environment variable, you can edit your moviepy config-defaults.py file to specify FFMPEG_BINARY = r"/path/to/ffmpeg".

Edit to find the path/to/ffmpeg after installing it with apt-get, do

dpkg -L ffmpeg | grep bin

at the shell/terminal prompt. It will probably be in /bin or /usr/bin, and will probably be called ffmpeg or ffmpeg-x.xx (with some version number).
Thanks to this answer for dpkg



来源:https://stackoverflow.com/questions/40004639/moviepy-oserror-exec-format-error-missing-shebang

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!