0

I am trying to use python to convert files from mp4 to mp3. After some research most places recommend moviepy. I used the command pip install moviepy and it seemed to go off without a hitch. I go to VS Code and enter what a youtube video told me to enter (I know its not recommended to do that, I just wanted to see if it would work). This is what I have

#This code should convert a .mp4 file into a .mp3 file

#This imports the moviepy package
from moviepy.editor import *

#here are the names of my files (I have subbed out actual files names)
mp4_file = "file_name.mp4"

mp3_file = "file_name.mp3

#Here is the the audio being stripped from the .mp4 file
video_clip = VideoFileClip(mp4_file)
audio_clip = video_clip.audio

#this is writing the audio to a .mp3 file at the path that is specified.
audio_clip.write_audiofile(mp3_file)

#this closes the conversion code
audio_clip.close()
VideoClip.close()

After running the code I get this error:

RuntimeError: No ffmpeg exe could be found. Install ffmpeg on your system, or set the IMAGEIO_FFMPEG_EXE environment variable.

There is a bunch of gibberish above it but that is the final line that gets spit out.

After looking up what the issue is I tried to input:

from moviepy.config import change_settings
change_settings({"FFMPEG_BINARY": "/usr/bin/ffmpeg"})

And it also did not work. I have tried searching for where ffmpeg is and it is not in /usr/bin/ffmepg or /usr/local/bin/ffmpeg like most sources I have looked at tell me it should be.

I have tried installing ffmpeg on its own by doing pip install ffmpeg and 'brew install ffmpeg'. Both of those go off without a hitch as well but the error still pops.

I am using a macbook air m1 and I have I think everything I need installed already so I am so lost on what is causing this error to pop.

Can someone please help?

I have tried installing ffmpeg on its own as well as searching for the file directly.

I should expect to get the .py file to run fine.

I instead get the error seen above:

RuntimeError: No ffmpeg exe could be found. Install ffmpeg on your system, or set the IMAGEIO_FFMPEG_EXE environment variable.
Yevhen Kuzmovych
  • 10,940
  • 7
  • 28
  • 48
Enspist
  • 11
  • 3
  • 1
    You need to download and install FFmpeg yourself (www.ffmpeg.org). You can try my downloader which might make your life a bit easier: https://github.com/python-ffmpegio/python-ffmpeg-downloader – kesh Oct 31 '22 at 23:52

1 Answers1

1

try to use this code which is i got

import moviepy.editor
import os
os.environ["IMAGEIO_FFMPEG_EXE"] = "/usr/bin/ffmpeg"
mp4_file = "file_name.mp4"

mp3_file = "file_name.mp3"
# Replace the parameter with the location of the video

video = moviepy.editor.VideoFileClip("mp4_file")
audio = video.audio

# Replace the parameter with the location along with filename

audio.write_audiofile("mp3_file")

if it is still not find the ffmpeg then find its actual path and note that

r4vanan
  • 51
  • 5