question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error Manipulating Big (1Gb) MP3 File

See original GitHub issue

I am trying to split a 12 hour mp3 audio file into 103 tracks. Basically, I am following the instructions to open, split and export a mp3 file, using something like:

pydub.AudioSegment.from_mp3(audio_file_name)[start:finish].export(new_track, format='mp3')

When I test with a small mp3 file it works just fine, but when I try to load the 1Gb file it crashes with the following error after about 30min running:

Traceback (most recent call last): File “c:\Users\20006083\Downloads\YoutubeMusic\split_audio.py”, line 61, in <module> song = AS.from_mp3(audio_file) File “C:\Users\40000438\AppData\Local\Continuum\Anaconda3\lib\site-packages\pydub\audio_segment.py”, line 707, in from_mp3 return cls.from_file(file, ‘mp3’, parameters) File “C:\Users\40000438\AppData\Local\Continuum\Anaconda3\lib\site-packages\pydub\audio_segment.py”, line 698, in from_file fix_wav_headers(p_out) File “C:\Users\40000438\AppData\Local\Continuum\Anaconda3\lib\site-packages\pydub\audio_segment.py”, line 141, in fix_wav_headers data[4:8] = struct.pack(‘<I’, len(data) - 8) struct.error: argument out of range

I was monitoring the memory usage while running my code, It got quite high, almost to the full 16Gb or RAM availiable in my computer. I am not sure if this is an issue with the library or it might be a crash related to memory overflow. Either way, I thought it would be nice to open this thread so the developers can verify this.

I am using python 3.6.1, the latest version of pydub (I installed today using the pip command) and also the latest version of ffmpeg (I got this file: ffmpeg-20180619-a990184-win64-shared). The audio file I am using is the audio from this youtube link:

https://www.youtube.com/watch?v=F__LuHDJko0&t=11595s

Any help solving this issue would be much appreciated.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:16 (4 by maintainers)

github_iconTop GitHub Comments

5reactions
kmahelonacommented, Dec 11, 2018

Is it possible for pydub to support file streaming? Rather than loading a whole file into memory, just load it’s information and provide an iterator in case you need to process the audio bits.

4reactions
JPerycommented, Feb 11, 2019

With pull request #345 you could open little AudioSegments so you don’t have to load the entire audio file into memory

Read more comments on GitHub >

github_iconTop Results From Across the Web

Developers - Error Manipulating Big (1Gb) MP3 File - - Bountysource
I am trying to split a 12 hour mp3 audio file into 103 tracks. Basically, I am following the instructions to open, split...
Read more >
How do I fix my MP3 player file format not supported ... - Quora
Can you open it in Audacity and export it to an MP3 file with a different name? ... Changing the file extension doesn't...
Read more >
FFMPEG MP3 file size much larger than expected on ...
The large file size is a problem as the sample MP3s are to be put on a website for people to listen to...
Read more >
problem opening large file [SOLVED] - Audacity Forum
I have a realtive big mp3 file (54 minutes, 105Mb). ... so for a stereo 54 minute file at 44100 Hz project rate...
Read more >
6 Ways to Fix the “Download Failed Network Error” on Chrome
These solutions might fix your problem. Network Error Message. Download errors are common on Google Chrome, and they come in many forms.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found