<commit_before>'use strict';

var FFmpeg = require('fluent-ffmpeg');
var validator = require('validator');
var url = require('url');
var colors = require('colors');
var request = require('request');
var exec = require('child_process').exec;
var fs = require('fs');
var config = require('../config/config');
var path = require('path');
var mime = require('mime');

/**
 * Removes the temporary uploaded file from the server
 * @param  {string}   filePath The path of the file
 * @param  {function} callback The callback function to send back
 * @return {function} callback ^
 */
function _removeFile(filePath, callback) {
  fs.unlink(filePath, function(err) {
    if(err) {
      return callback(err);
    }
    return callback();
  });
}

function _convertVideo(filePath, uploadDir, fileNoExt) {
  var mkvextract = 'mkvextract tracks ' + filePath + ' 2:' + uploadDir + fileNoExt.replace(/\[/g, '\\[').replace(/\]/g, '\\]') + '.ass';
  var subtitleLine;
  var child = exec(mkvextract, function (err, stdout, stderr) {
    if (err) {
      console.log('Mkvextract error: ', err.red);
    } else {
      console.log('Mkvextract completed.'.green);
      var command;
      if ('development' === config.env) {
        subtitleLine = '-vf ass=' + uploadDir + '/' + fileNoExt.replace(/\[/g, '\\[').replace(/\]/g, '\\]') + '.ass';
        // FFMPEG time!
        command = new FFmpeg({source: filePath})
          .withVideoCodec('libx264')
          .withVideoBitrate('512k')
          .withAudioCodec('libfdk_aac')
          .withAudioBitrate('128k')
          .setDuration('2:00')
          .withSize('1280x720')
          .withFps(30)<commit_msg>Fixed subtitle path when converting video.<commit_after>'use strict';

var FFmpeg = require('fluent-ffmpeg');
var validator = require('validator');
var url = require('url');
var colors = require('colors');
var request = require('request');
var exec = require('child_process').exec;
var fs = require('fs');
var config = require('../config/config');
var path = require('path');
var mime = require('mime');

/**
 * Removes the temporary uploaded file from the server
 * @param  {string}   filePath The path of the file
 * @param  {function} callback The callback function to send back
 * @return {function} callback ^
 */
function _removeFile(filePath, callback) {
  fs.unlink(filePath, function(err) {
    if(err) {
      return callback(err);
    }
    return callback();
  });
}

function _convertVideo(filePath, uploadDir, fileNoExt) {
  var mkvextract = 'mkvextract tracks ' + filePath + ' 2:' + uploadDir + '/' + fileNoExt.replace(/\[/g, '\\[').replace(/\]/g, '\\]') + '.ass';
  var subtitleLine;
  var child = exec(mkvextract, function (err, stdout, stderr) {
    if (err) {
      console.log('Mkvextract error: ', err.red);
    } else {
      console.log('Mkvextract completed.'.green);
      var command;
      if ('development' === config.env) {
        subtitleLine = '-vf ass=' + uploadDir + '/' + fileNoExt.replace(/\[/g, '\\[').replace(/\]/g, '\\]') + '.ass';
        // FFMPEG time!
        command = new FFmpeg({source: filePath})
          .withVideoCodec('libx264')
          .withVideoBitrate('512k')
          .withAudioCodec('libfdk_aac')
          .withAudioBitrate('128k')
          .setDuration('2:00')
          .withSize('1280x720')
          .withFps(30)
{'fraction_non_alphanumeric': 0.17434507678410116, 'fraction_numerical': 0.01324902137910268, 'mean_word_length': 3.1733668341708543, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5593334', 'n_tokens_mistral': 1105, 'n_tokens_neox': 1060, 'n_words': 256}