Skip to content
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

Audio gets curropted when extracting #1717

Open
NotSoShaby opened this issue Jan 16, 2022 · 6 comments
Open

Audio gets curropted when extracting #1717

NotSoShaby opened this issue Jan 16, 2022 · 6 comments
Labels
audio Related to AudioClip, or handling of audio in general. bug Issues that report (apparent) bugs.

Comments

@NotSoShaby
Copy link

NotSoShaby commented Jan 16, 2022

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
@NotSoShaby NotSoShaby added the bug Issues that report (apparent) bugs. label Jan 16, 2022
@keikoro keikoro added the audio Related to AudioClip, or handling of audio in general. label Jan 16, 2022
@keikoro
Copy link
Collaborator

keikoro commented Jan 16, 2022

I'd ask you to amend your issue so all the information we ask for in the Specifications section is present, thanks.

@NotSoShaby
Copy link
Author

I'd ask you to amend your issue so all the information we ask for in the Specifications section is present, thanks.

Added.

@NotSoShaby
Copy link
Author

NotSoShaby commented Jan 17, 2022

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

@Jheesbrough
Copy link

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

@josqu-john
Copy link

anyone found a solution or workaround?

@jake-nz
Copy link

jake-nz commented Sep 29, 2023

This problem has been reported many many times.
#1854
#1005
#1717
#1710
#1936

Here's the root cause: #1936 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
audio Related to AudioClip, or handling of audio in general. bug Issues that report (apparent) bugs.
Projects
None yet
Development

No branches or pull requests

5 participants