You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using pydub on a RPi 4 model B with 4GB RAM, running Raspbian Buster Lite.
Reading a flac or ape file larger than 200-220MB raises a MemoryError exception, always at the same line of code.
Steps to reproduce
`import sys
import os
from pydub import AudioSegment
pi@raspberrypi:~/flask_app $ python3 testpydub.py "/mnt/musiclib/Bach, J.S/L'Arte della fuga/Bach, J. S. - L'arte della Fuga BWV 1080 - Glenn Gould/CDImage.ape" ape.mp3 Reading audio file: /mnt/musiclib/Bach, J.S/L'Arte della fuga/Bach, J. S. - L'arte della Fuga BWV 1080 - Glenn Gould/CDImage.ape Traceback (most recent call last): File "testpydub.py", line 6, in <module> full_wav = AudioSegment.from_file(sys.argv[1], os.path.splitext(sys.argv[1])[1][1:]) File "/home/pi/.local/lib/python3.7/site-packages/pydub/audio_segment.py", line 729, in from_file obj = cls._from_safe_wav(BytesIO(p_out)) File "/home/pi/.local/lib/python3.7/site-packages/pydub/audio_segment.py", line 761, in _from_safe_wav obj = cls(data=file) File "/home/pi/.local/lib/python3.7/site-packages/pydub/audio_segment.py", line 222, in __init__ wav_data = read_wav_audio(data) File "/home/pi/.local/lib/python3.7/site-packages/pydub/audio_segment.py", line 132, in read_wav_audio data[pos:pos + data_hdr.size]) MemoryError
Your System configuration
Python version: 3.7
Pydub version: 0.24.0
ffmpeg or avlib?: ffmpeg
ffmpeg/avlib version: ffmpeg version N-97723-gfc99a24782 Copyright (c) 2000-2020 the FFmpeg developers built with gcc 8 (Raspbian 8.3.0-6+rpi1)
The text was updated successfully, but these errors were encountered:
I'm getting this error as well on the Raspberry Pi Zero W, which only has 512 MB RAM. I'm trying to load/decompress ~5 MB mp3 files, which decompress to ~50-60 MB.
This callstack duplicates the raw audio data several times. This spikes the Python instance's memory usage, maxes out the 512 MB, hits swap memory causing the program to slow to a crawl, then finally hits the MemoryError.
If some of these memory copies could be eliminated we'd be all gucci.
I'm using pydub on a RPi 4 model B with 4GB RAM, running Raspbian Buster Lite.
Reading a flac or ape file larger than 200-220MB raises a MemoryError exception, always at the same line of code.
Steps to reproduce
`import sys
import os
from pydub import AudioSegment
print ('Reading audio file:', sys.argv[1])
full_wav = AudioSegment.from_file(sys.argv[1], os.path.splitext(sys.argv[1])[1][1:])
print ("Done!")`
Expected behavior
'Done!' should be printed
Actual behavior
pi@raspberrypi:~/flask_app $ python3 testpydub.py "/mnt/musiclib/Bach, J.S/L'Arte della fuga/Bach, J. S. - L'arte della Fuga BWV 1080 - Glenn Gould/CDImage.ape" ape.mp3 Reading audio file: /mnt/musiclib/Bach, J.S/L'Arte della fuga/Bach, J. S. - L'arte della Fuga BWV 1080 - Glenn Gould/CDImage.ape Traceback (most recent call last): File "testpydub.py", line 6, in <module> full_wav = AudioSegment.from_file(sys.argv[1], os.path.splitext(sys.argv[1])[1][1:]) File "/home/pi/.local/lib/python3.7/site-packages/pydub/audio_segment.py", line 729, in from_file obj = cls._from_safe_wav(BytesIO(p_out)) File "/home/pi/.local/lib/python3.7/site-packages/pydub/audio_segment.py", line 761, in _from_safe_wav obj = cls(data=file) File "/home/pi/.local/lib/python3.7/site-packages/pydub/audio_segment.py", line 222, in __init__ wav_data = read_wav_audio(data) File "/home/pi/.local/lib/python3.7/site-packages/pydub/audio_segment.py", line 132, in read_wav_audio data[pos:pos + data_hdr.size]) MemoryError
Your System configuration
ffmpeg version N-97723-gfc99a24782 Copyright (c) 2000-2020 the FFmpeg developers built with gcc 8 (Raspbian 8.3.0-6+rpi1)
The text was updated successfully, but these errors were encountered: