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

Fix audio segment export bigger 4gb #734

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

inatuwe
Copy link

@inatuwe inatuwe commented Jun 21, 2023

This pull request adds the possibility to export an AudioSegment, which is bigger than 4 GB to any compressed format. It does not allow to export the AudioSegment directly to a WAV file bigger than 4 GB.
Apparently it's not even allowed from the specification of the WAV file to be bigger than 4 GB.
The strategy for the compressed formats is to split the audio segment into Wave Files smaller 4 GB and then to combine them with FFMPEG.
Note:
I also added a test with an audio segment > 4 GB, which is taking quite some time. On my machine (Lenovo P50), it takes 26 seconds.
Additionally on the infrastructure, it's impossible to run it due to memory limitation:

ERROR: test_audio_segment_export_bigger_than_4gb (main.AudioSegmentTests)
Traceback (most recent call last):
File "test/test.py", line 1104, in test_audio_segment_export_bigger_than_4gb
original_segment += original_segment
File "c:\projects\pydub\pydub\audio_segment.py", line 364, in add
return self.append(arg, crossfade=0)
File "c:\projects\pydub\pydub\audio_segment.py", line 1280, in append
return seg1._spawn(seg1._data + seg2._data)
MemoryError

=> This test is there, it can be used to verify the issue and the fix, but I have to disable it.

@cvillela
Copy link

Any help on this? I am facing the exact same issue.....

@aedocw
Copy link

aedocw commented Jan 7, 2024

Would love to see this merged, it would help with an issue some folks hit when making audiobooks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants