libsndfile icon indicating copy to clipboard operation
libsndfile copied to clipboard

Exit code -1073741571 (0xC00000FD) when writing OGG files with python-soundfile

Open Shararamosh opened this issue 4 months ago • 2 comments

I use python-soundfile library and trying to write OGG file to BytesIO buffer, however every time I call sf.write(format="ogg") on my audio data, I get exit code -1073741571 (0xC00000FD). Here's my function:

def attempt_convert_to_vorbis(audio_data: np.ndarray, samplerate: int, uses_librosa_format: bool) -> None | bytes:
    if uses_librosa_format:
        audio_data = audio_data.T
    vorbis_buffer = io.BytesIO()
    for i in range(0, 101):
        print(f"{i}%.")
        sf.write(vorbis_buffer, audio_data, samplerate, format="ogg", subtype="vorbis", compression_level=0.01*i)
        print("Wrote Vorbis data to buffer.")
        vorbis_buffer.seek(0)
        vorbis_data, _ = sf.read(vorbis_buffer)
        print("Read Vorbis data from buffer.")
        if np.array_equal(audio_data, vorbis_data):
            print("Vorbis data is identical to original.")
            return vorbis_buffer.read()
    return None

Even if I add try-except chunk for this call, the process just finishes with same exit code. Same thing happens if I remove compression_level, subtype and replace BytesIO buffer with actual file path. I've first opened this issue on python-soundfile issues page. The maintainer responded to it saying it's probably libsndfile issue.

Shararamosh avatar Jul 28 '25 15:07 Shararamosh

我遇到了同样的问题,我发现写入ogg格式时,只要采样频率大于22050hz就会报这个溢出错误,我无法定位到具体位置 16k数据可以写入成功

Google translate:

I had the same problem, I found that when writing to the ogg format, as long as the sampling frequency is greater than 22050hz will report this overflow error, I can not locate the specific location. 16k data can be successfully written

Wonderxin avatar Aug 23 '25 07:08 Wonderxin

Same here!

Revisto avatar Sep 04 '25 13:09 Revisto