title: nodejs join two videos together?
body: <p>So I am working on a concept and while I understand I could use FFMPEG to do what I need to do I was hoping that there would be a way to use nodejs Request to join a video onto the end of another video.</p>
  
  <p>The following code does work for audio, and the video file I am using is an MP4 (note I am trying to join the same video together so instead of 9seconds it should be 18 seconds.</p>
  
  <p>the URL = <a href="https://storage.googleapis.com/ad-system/testfolder/Video/10%20second%20video%20FAIL.mp4" rel="noreferrer">https://storage.googleapis.com/ad-system/testfolder/Video/10%20second%20video%20FAIL.mp4</a></p>
  
  <pre><code>const express = require('express');
  request = require('request');
  
  
  const router = new express.Router();
  
  router.get(':url(*)', (req, res) =&gt;{
  
  
      var url = req.params.url.substr(1); 
      res.set({
          "Content-Type": "video/mp4",
          'Transfer-Encoding': 'chunked'
      });
  
  
      var clients = [];
      ASystem();
      var ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress;
      console.log;(req.params.url);
      /* START A FUNCTION */
      function ASystem(){
  
                  var remote = "https://storage.googleapis.com/ad-system/testfolder/Video/10%20second%20video%20FAIL.mp4";
                  var streama = request.get(remote);
                  streama.on("connect", function() {
                      console.error(" connected!");
                      console.error(streama.headers);
                  });
  
                  streama.on("end", function() {
                      console.error(" END");
                      console.log(url);
                     if(url !== ""){getVideo();}
                      console.error(streama.headers);
                  // test = true;
  
                  });
  
                  // Fired after the HTTP response headers have been received.
                  streama.on('response', function(res) {
                  console.error(" Completed");
                      console.error(res.headers);
                  });
  
  
                  // When a chunk of data is received on the stream, push it to all connected clients
                  streama.on("data", function (chunk) {
                          // console.log(clients.length);
                          if (clients.length &gt; 0){
                              for (client in clients){
                                  clients[client].write(chunk);
                              };
                          }
  
                  });
      };
  /* END A FUNCTION */
  /* FETCHING URLVIDEO */
      function getVideo(){
          var remote = url;   
          var streama = request.get(remote);
          streama.on("connect", function() {
              console.error(" Stream connected!");
              //console.error(stream.headers);
          });
  
          streama.on("end", function() {
              console.error(" Stream END");
          // setTimeout(function(){ test = true; console.error('yep yep yep')},29000);
              //console.error(stream.headers);
          // test = true;
          //getVideo();
          });
  
          // Fired after the HTTP response headers have been received.
          streama.on('response', function(res) {
          // console.error("Stream response!");
              console.error(res.headers);
          });
  
  
          // When a chunk of data is received on the stream, push it to all connected clients
          streama.on("data", function (chunk) {
                  // console.log(clients.length);
                  if (clients.length &gt; 0){
                      for (client in clients){
                          clients[client].write(chunk);
                      };
                  }
  
          });
  
      }
      /* END VIDEO*/
  
      /* CORE SYSTEM */
  
        clients.push(res);
  
      /* END CORE SYSTEM */
  });
  module.exports = router;
  </code></pre>