-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inaccurate audio clip duration for MP3 files causing OSError
#2004
Comments
I'm having this same issue on Endeavour OS. Moviepy version: 1.0.3-4 I too have a program that tries to add the audio track to a video and apparently the length is different. ChatGPT suggested I do this:
but it doesn't actually fix it and I still get this error: |
Any updates on this? I am having the same issue. |
In Moviepy any set method is not Working. Temp Way Around. |
I'm having this issue as well. I've used various approaches to changing the duration of an audio clip to fill a longer video clip duration. Here's everything I've tried and they all result in the same video_file = VideoFileClip("video.mp4") # video of length 10 seconds
audio_file = AudioFileClip("audio.mp3") # audio of length ~3 seconds
target_duration = video_file.duration
# approach 1
audio = audio_file.set_duration(target_duration)
# approach 2
audio = audio_file.set_end(target_duration)
# approach 3
audio = audio_file.subclip(0, target_duration)
audio.write_audiofile() # Throws the same error regardless of which approach above is used I've also tried manipulating the Here's a little more about the error.
Edit: I worked around this by using the video_file = VideoFileClip("video.mp4") # video of length 10 seconds
audio_file = AudioFileClip("audio.mp3") # audio of length ~3 seconds
target_duration = video_file.duration
audio = CompositeAudioClip([ audio_file ])
audio.write_audiofile() |
I ended up fixing this by using the WAV file format type. I am not sure what caused the issue with MP3 but if it's an option I recommend switching. |
Use py version 3.8 it will be fixed. Or there is problem with the codec which is used. |
Any update on this one? |
Thank you for your contributions and for reporting issues in this repository. With the release of v2, which introduces significant changes to the codebase and API, we’ve reviewed the backlog of open PRs and issues. Due to the length of the backlog and the likelihood that many of these are either fixed or no longer applicable, we’ve made the decision to close all previous PRs and issues. If you believe that any of these are still relevant to the current version or if you'd like to reopen a related discussion, please feel free to create a new issue or pull request, referencing the old one. Thank you for your understanding and continued support! |
still present in v2 with python 3.10.12 |
When using
moviepy
to process certain MP3 audio files, the reported duration of the audio clip is less than the actual duration. This discrepancy leads to anOSError
whenmoviepy
tries to access a part of the audio file that exceeds the reported duration.Steps to reproduce:
AudioFileClip
frommoviepy.editor
.duration
attribute.eyed3
for .mp3 files).Expected behavior:
The reported duration of the audio clip should match the actual duration of the MP3 audio file.
Actual behavior:
The reported duration of the audio clip is less than the actual duration of the MP3 audio file. This leads to an
OSError
whenmoviepy
tries to access a part of the audio file that exceeds the reported duration.Environment:
Additional context:
The issue seems to be related to how the duration of the MP3 audio file is extracted from the file's metadata in the
FFMPEG_AudioReader
class. The reported duration is used to calculate the number of frames in the file, which can lead to an attempt to access non-existent frames if the reported duration is less than the actual duration.Error Message:
... AppData\Local\Programs\Python\Python310\lib\site-packages\moviepy\audio\io\readers.py", line 170, in get_frame
raise IOError("Error in file %s, "%(self.filename)+
OSError: Error in file D:\Video Editing\music.mp3, Accessing time t=184.04-184.08 seconds, with clip duration=184 seconds,
Example code:
The text was updated successfully, but these errors were encountered: