Fix audio segment export bigger 4gb #734
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.