# Problem writing files \>2GB using AudioFormatWriter

**URL:** <https://forum.juce.com/t/problem-writing-files-2gb-using-audioformatwriter/32050>\
**Category:** General JUCE discussion\
**Created:** [March 1, 2019, 9:18pm UTC](https://forum.juce.com/t/problem-writing-files-2gb-using-audioformatwriter/32050 "2019-03-01T21:18:31Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![bschiett](https://avatars.discourse-cdn.com/v4/letter/b/779978/32.png) [@bschiett](https://forum.juce.com/u/bschiett)\
**Post date:** [March 1, 2019, 9:18pm UTC](https://forum.juce.com/t/problem-writing-files-2gb-using-audioformatwriter/32050/1 "2019-03-01T21:18:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![xenakios](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/xenakios/32/4047_2.png) [@xenakios](https://forum.juce.com/u/xenakios)\
**Post date:** [March 1, 2019, 9:30pm UTC](https://forum.juce.com/t/problem-writing-files-2gb-using-audioformatwriter/32050/2 "2019-03-01T21:30:12Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![bschiett](https://avatars.discourse-cdn.com/v4/letter/b/779978/32.png) [@bschiett](https://forum.juce.com/u/bschiett)\
**Post date:** [March 1, 2019, 9:31pm UTC](https://forum.juce.com/t/problem-writing-files-2gb-using-audioformatwriter/32050/3 "2019-03-01T21:31:15Z")

</div>

> [@Xenakios](#):
>
> 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.

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

---

<div class="post-metadata">

**Author:** ![bschiett](https://avatars.discourse-cdn.com/v4/letter/b/779978/32.png) [@bschiett](https://forum.juce.com/u/bschiett)\
**Post date:** [March 2, 2019, 1:12am UTC](https://forum.juce.com/t/problem-writing-files-2gb-using-audioformatwriter/32050/4 "2019-03-02T01:12:25Z")

</div>

> [@Xenakios](#):
>
> 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.

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.

---

<div class="post-metadata">

**Author:** ![xenakios](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/xenakios/32/4047_2.png) [@xenakios](https://forum.juce.com/u/xenakios)\
**Post date:** [March 2, 2019, 1:30am UTC](https://forum.juce.com/t/problem-writing-files-2gb-using-audioformatwriter/32050/5 "2019-03-02T01:30:59Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![bschiett](https://avatars.discourse-cdn.com/v4/letter/b/779978/32.png) [@bschiett](https://forum.juce.com/u/bschiett)\
**Post date:** [March 2, 2019, 1:50am UTC](https://forum.juce.com/t/problem-writing-files-2gb-using-audioformatwriter/32050/6 "2019-03-02T01:50:54Z")

</div>

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 …

---

<div class="post-metadata">

**Author:** ![railjonrogut](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/railjonrogut/32/505_2.png) [@railjonrogut](https://forum.juce.com/u/railjonrogut)\
**Post date:** [March 2, 2019, 7:25am UTC](https://forum.juce.com/t/problem-writing-files-2gb-using-audioformatwriter/32050/7 "2019-03-02T07:25:55Z")

</div>

Search the JUCE code for RF64

Rail

---

<div class="post-metadata">

**Author:** ![bschiett](https://avatars.discourse-cdn.com/v4/letter/b/779978/32.png) [@bschiett](https://forum.juce.com/u/bschiett)\
**Post date:** [March 3, 2019, 12:26am UTC](https://forum.juce.com/t/problem-writing-files-2gb-using-audioformatwriter/32050/8 "2019-03-03T00:26:33Z")

</div>

> [@Rail\_Jon\_Rogut](#):
>
> Search the JUCE code for RF64

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.

---

<div class="post-metadata">

**Author:** ![railjonrogut](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/railjonrogut/32/505_2.png) [@railjonrogut](https://forum.juce.com/u/railjonrogut)\
**Post date:** [March 3, 2019, 1:04am UTC](https://forum.juce.com/t/problem-writing-files-2gb-using-audioformatwriter/32050/9 "2019-03-03T01:04:35Z")

</div>

Did you say what OS you’re running?

Rail

---

<div class="post-metadata">

**Author:** ![bschiett](https://avatars.discourse-cdn.com/v4/letter/b/779978/32.png) [@bschiett](https://forum.juce.com/u/bschiett)\
**Post date:** [March 3, 2019, 1:18am UTC](https://forum.juce.com/t/problem-writing-files-2gb-using-audioformatwriter/32050/10 "2019-03-03T01:18:37Z")

</div>

> [@Rail\_Jon\_Rogut](#):
>
> Did you say what OS you’re running?

yes, see above
