I'm trying to extract some audio from a video and combine it with another audio file to create a 'background noise' on the original video. When I extract the audio from the video, it speeds up and skips. For example, if the audio on the video were to say 'Can't pay the rent', the extracted audio would say 'Can't pay the rent nt nt nt nt'.
The out_audio.mp3 has the skips in it, but when I play out.mp4 on a video player, there are no issues.
from pydub import AudioSegment
import sys
from moviepy.editor import *
import os
#extract audio from out.mp4
videoclip = VideoFileClip("out.mp4")
videoclip.audio.write_audiofile('out_audio.mp3')
#overlay sound1 and sound2
sound1 = AudioSegment.from_mp3("background_track.mp3")
sound2 = AudioSegment.from_mp3("out_audio.mp3")
output = sound1.overlay(sound2)
output.export("mixed_sounds.mp3", format="mp3")
Expected result: mp3 file of original video audio and background audio mixed. Actual result: audio that skips.