title: How to append a video to the end of a file
body: <p>I have JS Client, that send a chucks of bytes to Flask server. I want to append this bytes to video on server side (save stream). Video format doesn't matter.</p>
  <p>Client:</p>
  <pre><code>function startStream() {
      mediaRecorder = new MediaRecorder(webcamstream);
      let chunks = [];
      mediaRecorder.ondataavailable = data =&gt; {
          chunks.push(data.data);
      }
      mediaRecorder.onstop = () =&gt; {
          const blob = new Blob(chunks, { type: 'video/mkv' });
          postVideoToServer(blob, true);
          startStream();
      }
      mediaRecorder.start();
      setTimeout(()=&gt;{mediaRecorder.stop();}, 1000)
  }
  </code></pre>
  <p>Server:</p>
  <pre><code>@app.route('/stream', methods=['POST'])
  def stream():
  f = request.files['blob']
  
  blob = BytesIO(f.stream.read())
  
  with open(&quot;video.mkv&quot;,'ab') as file:
      file.write(blob.read())
  
  return &quot;OK&quot;
  </code></pre>
  <p>I read on the Internet that the video is not recorded correctly because the first time it is recorded, headers are created with basic information about the file. Maybe there is a way to change them?</p>
  <p>I also tried not saving chunks on the client, and sending them to the server right away.</p>
  <pre><code>mediaRecorder.ondataavailable = data =&gt; {
      postVideoToServer(data.data);
  }
  </code></pre>