fluent-ffmpeg to convert audio chunks to mp3 and append them to an mp3 file
<h3>What?</h3>

<p>Passing an appending write stream, <code>fs.createWriteStream(filePath, { flags: 'a' })</code>, as an output doesn't seem to work.</p>

<h3>The code I tried to run</h3>

<pre><code>const stream = require('stream');
let bufferReadStream = new stream.PassThrough();
bufferReadStream.end(Buffer.concat(largeChunk));

ffmpeg(bufferReadStream)
.format('mp3')
.output(fs.createWriteStream(filePath, { flags: 'a' }))
.on('end', () =&gt; {
  console.log('formatting finished!');
})
.on('error', err =&gt; {
  console.log('format buffer error: ', err);
})
.run();
</code></pre>

<h3>What I expected to happen and what actually happened</h3>

<p>I was uploading an audio stream (.webm) to node which is accepted as an array of buffers.  I am trying to avoid saving a very large audio file to disk and then formatting it to an .mp3 file because of the wait time for large audio files. </p>

<p>I tried take chunks of an audio file and directly convert them into an mp3 and append them to an mp3 file. The code successfully runs the first time, creating an mp3 file, but after the 2nd time, it throws an error instead of appending it to the existing mp3 file.</p>

<pre><code>format buffer error:  
Error: ffmpeg exited with code 1: pipe:0: Invalid data found when processing input

at ChildProcess.&lt;anonymous&gt; (/Users/inspiredtolive/Desktop/HackReactor/Picky-Notes/node_modules/fluent-ffmpeg/lib/processor.js:177:22)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
</code></pre>