'use strict';

// Load requirements
const ffmpeg = require('fluent-ffmpeg'),
      path = require('path');

// Configures the conversion task
module.exports = {

  config: function(file, options, metadata, details) {
    return new Promise((resolve, reject) => {

      // Combine defaults with options
      options = this.utils.assignDefaults(options);

      // Create an instance of ffmpeg
      let command = ffmpeg(file)
                      .renice(10)                          // Lower the cpu priorty for encode tasks
                      .outputOptions('-map_metadata', '0') // Keep metadata, title, cover image, etc.
                      .outputOptions('-map_chapters', '0') // Keep chapter data intact
                      .outputOptions('-hide_banner');      // Stops ffmpeg diagnostic output

      // Loop over the available methods and configure the command
      this.utils.getMethods(this).reduce((promise, method) => {
        
        // Chain the promises
        return promise.then((result) => {

          // If we got an object back, try to assign to command
          if ( typeof result === 'object' ) {
            Object.keys(result).forEach((key) => {
              if ( ! command.hasOwnProperty(key) ) { command[key] = result[key]; }
            });
          }

          // Start the next setup command
          return this[method](command, file, options, metadata, details);
        });

      // Resolve to conversion task with command
      }, Promise.resolve()).then((result) => {
        return resolve(command);

      // Reject on error
      }).catch((err) => {
        return reject(err);
      });
    });
  },

  utils: require('./utils'),

  outputPath: require('./methods/output-path'),

  videoBitrate: require('./methods/video-bitrate'),

  videoSize: require('./methods/video-size')

};

@@ -1737,101 +1737,638 @@
 %0A%0A  
-videoBitrate: require('./methods/video-bitrate'),%0A%0A  videoSize: require('./methods/video-size
+streamData: require('./methods/stream-data'),%0A%0A  assignStreams: require('./methods/assign-streams'),%0A%0A  videoCodec: require('./methods/video-codec'),%0A%0A  videoBitrate: require('./methods/video-bitrate'),%0A%0A  videoSize: require('./methods/video-size'),%0A%0A  videoBitdepth: require('./methods/video-bitdepth'),%0A%0A  codecX265: require('./methods/codec-x265'),%0A%0A  audioCodec: require('./methods/audio-codec'),%0A%0A  heAudio: require('./methods/he-audio'),%0A%0A  removeSubtitles: require('./methods/remove-subtitles'),%0A%0A  encodePreset: require('./methods/encode-preset'),%0A%0A  tune: require('./methods/tune'),%0A%0A  preview: require('./methods/preview
 ')%0A%0A

Add methods to engine