-
Notifications
You must be signed in to change notification settings - Fork 113
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
Cannot write Ogg files over 96 seconds long at 44.1 kHz #426
Comments
Thank you for the bug report. How did you install soundfile? Is there an error message? |
I've done
No error message that I can see, but perhaps it's librosa that misses a transitive dependency for soundfile? |
Thank you. This is probably an issue with upstream libsndfile. You will need to check with them if they have a fix for this issue. They may already have fixed it actually, as soundfile is one version behind libsndfile at the moment. |
I ran into this issue, and after looking around a bit it seems that this limitation has existed since at least 2014. One workaround that I discovered from a GNU Octave bug report is to write the file out in chunks of size 2^20 instead of writing it out all at once with def write_chunked(file, data, samplerate, subtype=None, endian=None, format=None,
closefd=True, chunk_size=0x100000):
import numpy as np
data = np.asarray(data)
if data.ndim == 1:
channels = 1
else:
channels = data.shape[1]
with SoundFile(file, 'w', samplerate, channels,
subtype, endian, format, closefd) as f:
num_chunks = (len(data) + chunk_size - 1) // chunk_size
for chunk in np.array_split(data, num_chunks, axis=0):
f.write(chunk) From my limited testing it seems to work fine for writing vorbis files. |
Not entirely sure how this happens, but I've been observing program crashes with
sf.write
for any Ogg file over a duration of 95-96 seconds at 44.1 kHz.This works:
While this crashes:
on 0.12.1 macOS M1, 32 GB RAM.
The text was updated successfully, but these errors were encountered: