macOS Ventura 13.5
I'm trying to split an audio mp4 file into few chunks to add one of them to a video clip. Here is the code:
from moviepy.editor import *
audio = AudioFileClip('/Users/User1/Desktop/video_creating/my_music.mp4')
clip = audio.subclip(1, 25)
clip.write_audiofile('samples/sample_1.mp4')
But its shows me an error message reporting:
OSError: [Errno 32] Broken pipe
MoviePy error: FFMPEG encountered the following error while writing file sample_1.mp4:
b"[aost#0:0 @ 0x131e39240] Invalid encoder type 'libx264'\n"
What am i doing wrong?
Is there any other ways to edit audio/video files in Python?
I tried to uninstall ffmpeg then install it again. Tried to do brew install lightgbm. But still nothing seems to be work.
I tested and I believe the file type
mp4is incorrect and the foldersamplesdoes not exist which causes the errorYou have to pass a
.mp3file to theAudioFileClip()function and make sure you have a folder calledsamplesHowever you can use
moviepy.video.io.ffmpeg_tools.ffmpeg_extract_audioto extract sound from an.mp4