pydub icon indicating copy to clipboard operation
pydub copied to clipboard

speedup hangs indefinitely

Open jaypinho opened this issue 2 years ago • 1 comments
trafficstars

Steps to reproduce

  1. Download a podcast episode (I used https://27083.mc.tritondigital.com/OMNY_ODDLOTS_PODCAST_P/media-session/f155044e-aa39-4c0c-ada7-581d92b80798/d/clips/e73c998e-6e60-432f-8610-ae210140c5b1/8a94442e-5a74-4fa2-8b8d-ae27003a8d6b/33372447-ffe8-4b9d-8a2a-b031012c3f03/audio/direct/t1688371276/Bridgewater's_Greg_Jensen_on_AI,_Inflation_and_What_Markets_Are_Getting_Wrong.mp3).

  2. Try:

from pydub import AudioSegment, effects
sound_file = AudioSegment.from_mp3(filename)
so = sound_file.speedup(playback_speed=1.25, chunk_size=150, crossfade=25)
so.export("faster_file.mp3", format="mp3")

Expected behavior

I should get a new mp3 file (faster_file.mp3) that's shorter than the original.

Actual behavior

The code hangs indefinitely and I have to manually cut it off after 5+ minutes.

Your System configuration

  • Python version: 3.9.6
  • Pydub version: 0.25.1
  • ffmpeg or avlib?: ffmpeg
  • ffmpeg/avlib version: 6.0

Is there an audio file you can include to help us reproduce?

See URL above.

jaypinho avatar Jul 03 '23 18:07 jaypinho

I can reproduce: While the speedup function doesn't actually "hang", it becomes really slow due to internal repeated copying of the audio, which for long audio files/segments becomes prohibitive. In PR #746 I have a much more performant but not quite as general re-implementation to start a discussion on how to improve this.

lumip avatar Jul 25 '23 10:07 lumip