1

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]

Tom Burrows
  • 2,225
  • 2
  • 29
  • 46
  • What are the `cmd` and the `popen_params` in the `sp.Popen` call? If you don't know, you can run `python -m pdb -c "b /usr/local/lib/python3.2/dist-packages/moviepy/video/io/ffmpeg_reader.py:237" -c c your_script.py` per [this](http://stackoverflow.com/a/33808301/2877364), then `p cmd` and `p popen_params` at the pdb prompt when you hit the breakpoint. – cxw Oct 12 '16 at 17:28
  • It might not be a shebang at all - it might be binaries compiled for the wrong architecture ;) . Please [edit your question](https://stackoverflow.com/posts/40004639/edit) to include the commands you used to install moviepy and ffmpeg. – cxw Oct 12 '16 at 17:29
  • @cxw Your command gave the 'Error: -c does not exist' – Tom Burrows Oct 12 '16 at 17:34
  • Sorry for the confusion! Should be in pdb 3.2 per the linked answer - I just pulled it from there and haven't tried it myself :) . Oh - I should have said `python3` rather than `python`. Or else do `python3 -m pdb your_script.py` and then enter the `b` and `c` commands at the pdb prompt. – cxw Oct 12 '16 at 17:46
  • I tried the your updated commands, no luck, but I'm not sure they're needed now. – Tom Burrows Oct 12 '16 at 18:00
  • I have installed FFMPEG with 'sudo apt-get install ffmpeg'. – Tom Burrows Oct 12 '16 at 18:01

1 Answers1

2

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

Community
  • 1
  • 1
cxw
  • 16,685
  • 2
  • 45
  • 81
  • I have installed FFMPEG with 'suso apt-get install ffmpeg'. Where is the "shell prompt" is that the terminal? – Tom Burrows Oct 12 '16 at 18:05
  • I've put it in the terminal, nothing (good or bad) happened. When I ran the program, I got the error: – Tom Burrows Oct 12 '16 at 18:11
  • I got the error: 'IOError [...] file might be corrupted [...] might be using a deprecated version of FFMPEG [...] On Debian for instance the version in the repos is deprecated. Please update to a recent version from the website'. Seems fairly self explanatory and is the most helpful error message I have ever seen :) – Tom Burrows Oct 12 '16 at 18:14
  • Thank you so so so much! I had been trying to fix this for a week! After the apt-get ffmpeg install didn't work, I followed [these](http://hannes.enjoys.it/blog/2016/03/ffmpeg-on-raspbian-raspberry-pi/) instructions to the letter, and all the issues were immediately solved. – Tom Burrows Oct 12 '16 at 20:51
  • @Gloin fantastic! Glad to be able to help. – cxw Oct 13 '16 at 00:45