moviepy
moviepy copied to clipboard
Audio gets curropted when extracting
a simple code like this is creating a curropted audio file for some reasons:
from moviepy import *
clip = VideoFileClip("cut.mp4")
audio = clip.audio
audio.to_audiofile('temp-audio.mp3')
-->
Expected Behavior
Audio should be the same as the audio in the video
Actual Behavior
audio is curropted in the end (repeats the end segment a few times like a broken record)
Steps to Reproduce the Problem
Run the code on this video with latest moviepy version (don't make fun it's just a trial lol): https://user-images.githubusercontent.com/26500236/149655475-bdd9ffa6-69dc-4d6b-ad32-5789907e42ca.mp4 and you will get this audio which is curropted (compressed it to a zip because github doesn't allow mp3 uploads): temp-audio.zip
Specifications
- Python Version: Python 3.9.9
- Moviepy Version: 1.0.3
- Platform Name: Ubuntu
- Platform Version: 20.04.3 LTS
I'd ask you to amend your issue so all the information we ask for in the Specifications
section is present, thanks.
I'd ask you to amend your issue so all the information we ask for in the
Specifications
section is present, thanks.
Added.
After someone answered my SO question here his solution seems to work - simply taking a subclip instead of the clip (in this case of one second) makes the audio function. But I still don't understand why it won't work for the given video without specifying the subclip length (I want it to be dynamic and take any video I present).
@keikoro if you think this is not a bug - i will close the issue.
The solution that worked for the case I presented in the "how to reproduce":
from moviepy import *
clip = VideoFileClip("cut.mp4").subclip(0,1)
#subclip mean video duration its from the place to start to the end
audio = clip.audio
audio.to_audiofile('temp-audio.mp3')
credit to hmody3000 from SO
Definitely a bug and still very present This doesn't seem obvious at all but thanks for the workaround Python 3.10.0 moviepy 1.0.3 Platform Name: Windows 10
anyone found a solution or workaround?
This problem has been reported many many times. https://github.com/Zulko/moviepy/issues/1854 https://github.com/Zulko/moviepy/issues/1005 https://github.com/Zulko/moviepy/issues/1717 https://github.com/Zulko/moviepy/issues/1710 https://github.com/Zulko/moviepy/issues/1936
Here's the root cause: https://github.com/Zulko/moviepy/issues/1936#issuecomment-1740785869