python – MoviePy failing to execute because it cannot find ffmpeg on my macOS
I have a macbook pro running sonoma latest version, i have installed ffmpeg with brew and its located at /opt/homebrew/bin/ffmpeg
Im trying to run this script but i get the error :
from moviepy.editor import *
from moviepy.video.tools.subtitles import SubtitlesClip
from moviepy.config import change_settings
import os
os.environ["OMP_NUM_THREADS"] = 1
os.environ["IMAGEIO_FFMPEG_EXE"] = r"/opt/homebrew/bin/ffmpeg"
generator = lambda txt: TextClip(txt, font="Arial", fontsize=24, color="white")
subs = [((0, 4), 'subs1'),
((4, 9), 'subs2'),
((9, 12), 'subs3'),
((12, 16), 'subs4')]
subtitles = SubtitlesClip(subs, generator)
video = VideoFileClip("video.mp4")
result = CompositeVideoClip([video, subtitles.set_pos(('center', 'bottom'))])
result.write_videofile("output.mp4", fps=video.fps, temp_audiofile="temp-audio.m4a", remove_temp=True, codec="libx264",
audio_codec="aac")
error :
RuntimeError: No ffmpeg exe could be found. Install ffmpeg on your system, or set the IMAGEIO_FFMPEG_EXE environment variable.
I tried reinstalling ffmpeg and installing it in the env of the project but still no luck.
Read more here: Source link
