First I typed the following commands in the terminal to install the necessary packages:
pip install moviepy
pip install ffmpeg
Then when I tried to run the following code, I got this:
from moviepy.editor import *
Error: RuntimeError: No ffmpeg exe could be found. Install ffmpeg on your system, or set the IMAGEIO_FFMPEG_EXE environment variable.
To fix the error, I typed the following code above the previous line of code:
import os
os.environ["IMAGEIO_FFMPEG_EXE"] = "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/ffmpeg"
from moviepy.editor import *
This fixed the issue I was having earlier and I was able to import it. The location you see typed in the code was directly copied from the output from the location attribute when I typed pip show ffmpeg in the terminal. However, when I actually try and use the library, I get errors:
import os
os.environ["IMAGEIO_FFMPEG_EXE"] = "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/ffmpeg"
from moviepy.editor import *
clip = VideoFileClip("master_video.mp4")
Error:
---------------------------------------------------------------------------
PermissionError Traceback (most recent call last)
Input In [2], in <cell line: 5>()
2 os.environ["IMAGEIO_FFMPEG_EXE"] = "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/ffmpeg"
3 from moviepy.editor import *
----> 5 clip = VideoFileClip("master_video.mp4")
7 for x in range(0,10):
8 print(randint(0, 2420))
File /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/moviepy/video/io/VideoFileClip.py:88, in VideoFileClip.__init__(self, filename, has_mask, audio, audio_buffersize, target_resolution, resize_algorithm, audio_fps, audio_nbytes, verbose, fps_source)
86 # Make a reader
87 pix_fmt = "rgba" if has_mask else "rgb24"
---> 88 self.reader = FFMPEG_VideoReader(filename, pix_fmt=pix_fmt,
89 target_resolution=target_resolution,
90 resize_algo=resize_algorithm,
91 fps_source=fps_source)
93 # Make some of the reader's attributes accessible from the clip
94 self.duration = self.reader.duration
File /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/moviepy/video/io/ffmpeg_reader.py:35, in FFMPEG_VideoReader.__init__(self, filename, print_infos, bufsize, pix_fmt, check_duration, target_resolution, resize_algo, fps_source)
33 self.filename = filename
34 self.proc = None
---> 35 infos = ffmpeg_parse_infos(filename, print_infos, check_duration,
36 fps_source)
37 self.fps = infos['video_fps']
38 self.size = infos['video_size']
File /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/moviepy/video/io/ffmpeg_reader.py:257, in ffmpeg_parse_infos(filename, print_infos, check_duration, fps_source)
254 if os.name == "nt":
255 popen_params["creationflags"] = 0x08000000
--> 257 proc = sp.Popen(cmd, **popen_params)
258 (output, error) = proc.communicate()
259 infos = error.decode('utf8')
File /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/subprocess.py:969, in Popen.__init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize)
965 if self.text_mode:
966 self.stderr = io.TextIOWrapper(self.stderr,
967 encoding=encoding, errors=errors)
--> 969 self._execute_child(args, executable, preexec_fn, close_fds,
970 pass_fds, cwd, env,
971 startupinfo, creationflags, shell,
972 p2cread, p2cwrite,
973 c2pread, c2pwrite,
974 errread, errwrite,
975 restore_signals,
976 gid, gids, uid, umask,
977 start_new_session)
978 except:
979 # Cleanup if the child failed starting.
980 for f in filter(None, (self.stdin, self.stdout, self.stderr)):
File /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/subprocess.py:1845, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session)
1843 if errno_num != 0:
1844 err_msg = os.strerror(errno_num)
-> 1845 raise child_exception_type(errno_num, err_msg, err_filename)
1846 raise child_exception_type(err_msg)
PermissionError: [Errno 13] Permission denied: '/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/ffmpeg'
Thank you so much in advance