Problem writing files >2GB using AudioFormatWriter

#1

I am working on code to record multichannel WAV files to disk. It seems that each time my file grows to 2GB in size, I get an error writing or flushing. I’m using the AudioFormatWriter class.

The exact file size when this happens is 2147483647 bytes.

I’m using JUCE 3.1.1, commit 8b3935f12154767d37c65c1612d1bfeb93a5965f. I know we are at JUCE v5 now but I can’t upgrade (yet). I’m on Linux / ARM.

Has this issue been reported after this commit and fixed? If yes and if someone knows at what commit, that would be helpful.

Thanks
B

0 Likes

#2

I just tested that writing out a 8GB .wav file works fine with Juce 5.

Are you processing/writing the file by dividing it into smaller buffers? I think there are still some limits in Juce 5 with the size that for example AudioBuffer can use.

0 Likes

#3

Yes I am, I will report back ASAP with the size of buffer I use.

0 Likes

#4

So I use an AudioSampleBuffer to write into using my audio callback, and I read from this buffer using my background thread which does the actual writing to disk. The buffer is 51200 samples long x 16 channels x 4 bytes = 3,276,800 bytes total, so around 3.3MB.

I’m using a 512 sample buffer size so I’m writing 512 samples into the buffer most of the time. So I don’t understand why this stops working when I reach a file size of 2GB.

I’m doing this with up to 16 channels and 192kHz sample rate.

If I change the number of channels to 8 for example then I can record twice the length, again up to the 2GB file size.

0 Likes

#5

Well, I guess maybe Juce v3 file sizes were limited to 2GB or something? Really hard to tell at this point.

0 Likes

#6

I generated a file on the command line of slightly larger than 4GB using dd and the maximum file size I can get is 4GB, because I’m on a FAT32 partition (vfat).

So I should be able to record files up to 4GB in size unless JUCE v3 is using some 32-bit file I/O calls and these were changed to use the 64-bit versions later on, during the development of v4 or v5? I don’t know what the current situation is with regard to file size limitations on linux when using JUCE.

Maybe @jules or @fabian can enlighten us …

0 Likes

#7

Search the JUCE code for RF64

Rail

0 Likes

#8

I already looked at the implementation of AudioFormatWriter and WavAudioFormat.

You are correct that if you try to write a file larger than 4GB it would use the RF64 format. But I am not even able to write a file of 4GB, after 2GB I get a write error.

0 Likes

#9

Did you say what OS you’re running?

Rail

0 Likes

#10

yes, see above

0 Likes