You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to use MoviePy to process a video file, detect scenes, and save subclips. Everything works fine when I disable audio (audio=False in write_videofile), but when I enable audio, I get the following error:
MoviePy - Writing video new1.mp4
MoviePy - Done !
MoviePy - video ready new1.mp4
Proc not detected chunk: 0%| | 0/388 [00:00<?, ?it/s, now=None]
MoviePy - Writing audio in new2TEMP_MPY_wvf_snd.mp3
Traceback (most recent call last):
MoviePy - Writing audio in new2TEMP_MPY_wvf_snd.mp3
Traceback (most recent call last):
File "/Users/ahmadnaser/PycharmProjects/Sawt/Frame Detection.py", line 19, in <module>
SubClip.write_videofile(OutputClip)
Here’s the code I’m using:
from moviepy.video.io.VideoFileClip import VideoFileClip
from moviepy.video.tools.cuts import detect_scenes
# Load the video and subclip for faster processing
clip = VideoFileClip("/Users/ahmadnaser/Documents/podcast1.mp4").subclip(0, 30) # Process first 30 seconds
fps = clip.fps
# Detect scenes
SceneTimes = detect_scenes(clip, logger="bar", fps=fps)
FrameChangeTimes = [(float(start), float(end)) for start, end in SceneTimes[0]]
# Process subclips
for i, (start, end) in enumerate(FrameChangeTimes):
if end - start < 3: # Skip very short clips
continue
SubClip = clip.subclip(start, end)
OutputClip = f"new{i+1}.mp4"
# Write the subclip
SubClip.write_videofile(OutputClip, audio=True) # Error occurs when audio=True
SubClip.close()
# Close the main clip
clip.close()
What I’ve Tried
Setting audio=False works, but I need the audio in the output videos.
I verified that ffmpeg is installed and works. Running ffmpeg -version confirms it's available.
The source video has an audio stream, confirmed with ffprobe.
Why does enabling audio in write_videofile cause this error, and how can I fix it? Is there a specific issue with my code or setup? Any help would be appreciated.
The text was updated successfully, but these errors were encountered:
I'm trying to use MoviePy to process a video file, detect scenes, and save subclips. Everything works fine when I disable audio (audio=False in write_videofile), but when I enable audio, I get the following error:
Here’s the code I’m using:
What I’ve Tried
Setting audio=False works, but I need the audio in the output videos.
I verified that ffmpeg is installed and works. Running ffmpeg -version confirms it's available.
The source video has an audio stream, confirmed with ffprobe.
Environment
Python version: 3.9.6
MoviePy version: 1.0.3
Operating system: macOS
Question
Why does enabling audio in write_videofile cause this error, and how can I fix it? Is there a specific issue with my code or setup? Any help would be appreciated.
The text was updated successfully, but these errors were encountered: