title: node js & videogular loading video using node
body: <p>So i have the following node code for uploading video to my node server:</p>
  
  <pre><code>    var fs = require('fs');
  
  var videoExtensions = ['mp4','flv', 'mov'];
  //Media object
  function Media(file, targetDirectory) {
     this.file = file;
     this.targetDir = targetDirectory;
  }
  
  Media.prototype.isVideo = function () {
      return this.file.mimetype.indexOf('video') &gt;= 0;
  };
  Media.prototype.getName = function () {
      return this.file.originalname.substr(0, this.file.originalname.indexOf('.'))
  };
  
  router.route('/moduleUpload')
      .post(function (request, response) {
          var media = new Media(request.files.file, '../user_resources/module/'+request.body.module_id+'/');
          if(!fs.existsSync('../user_resources/module/'+request.body.module_id+'/')){
              fs.mkdirSync('../user_resources/module/'+request.body.module_id+'/', 0766, function(err){
                  if(err){
                      console.log(err);
                      response.send("ERROR! Can't make the directory! \n");    // echo the result back
                  }
              });
          }
          convertVideos(media);
          response.status(200).json('user_resources/module/' + request.body.module_id + '/' + request.files.file.name);
  
      });
  
  
  function convertVideos (media){
      var ffmpeg = require('fluent-ffmpeg');
      videoExtensions.forEach(function(extension){
          var proc = new ffmpeg({source: media.file.path, nolog: false})
              .withVideoCodec('libx264')
              .withVideoBitrate(800)
              .withAudioCodec('libvo_aacenc')
              .withAudioBitrate('128k')
              .withAudioChannels(2)
              .toFormat(extension)
              .saveToFile(media.targetDir+media.getName()+'.'+extension,
              function (retcode, error) {
                  console.log('file has been converted succesfully');
              });
      });
  
  }
  </code></pre>
  
  <p>Now instead of loading the video using an direct path i wish to load it using node </p>
  
  <p>However i am not quite sure how to do this</p>
  
  <p>Using direct path i would do something like this:</p>
  
  <pre><code>$scope.videos.push(
  {
      sources: [
          {src: $sce.trustAsResourceUrl($scope.component.video_mp4_path), type: "video/mp4"}
      ]
  }
  </code></pre>
  
  <p>where the video_mp4_path variable would be the direct path to the video ie: <code>myproject/resources/video.mp4</code></p>
  
  <p>However somehow i need to call node instead of an instant path.</p>
  
  <p>as i said im not quite sure how to do this could someone point me in the right direction</p>