Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
[/"/g, ""],
[/'/g, ""],
[/\//g, ""],
[/\?/g, ""],
[/:/g, ""],
[/;/g, ""]
];
self.requestOptions =
options && options.requestOptions
? options.requestOptions
: { maxRedirects: 5 };
self.outputOptions =
options && options.outputOptions ? options.outputOptions : [];
if (options && options.ffmpegPath) {
ffmpeg.setFfmpegPath(options.ffmpegPath);
}
// Async download/transcode queue
self.downloadQueue = async.queue(function (task, callback) {
self.emit(
"queueSize",
self.downloadQueue.running() + self.downloadQueue.length()
);
self.performDownload(task, function (err, result) {
callback(err, result);
});
}, self.queueParallelism);
}
const dlQueue = async.queue((task, done) => {
// Set custom FFMPEG path if defined
if (appSettings.get('downloads.ffmepg')) ffmpeg.setFfmpegPath(appSettings.get('downloads.ffmepg'))
// Get video info
LiveMe.getVideoInfo(task).then(video => {
const path = appSettings.get('downloads.path')
const dt = new Date(video.vtime * 1000)
const mm = dt.getMonth() + 1
const dd = dt.getDate()
let filename = appSettings.get('downloads.template')
.replace(/%%broadcaster%%/g, video.uname)
.replace(/%%longid%%/g, video.userid)
.replace(/%%replayid%%/g, video.vid)
.replace(/%%replayviews%%/g, video.playnumber)
.replace(/%%replaylikes%%/g, video.likenum)
.replace(/%%replayshares%%/g, video.sharenum)
.replace(/%%replaytitle%%/g, video.title ? video.title : 'untitled')
.replace(/%%replayduration%%/g, video.videolength)
_checkDependencies() {
var silkDecoder = this._getSilkSDK("decoder"),
silkEncoder = this._getSilkSDK("encoder"),
ffmpegPath = this._ffmpegPath;
// Check if Silk SDK is available
if (!fs.existsSync(silkDecoder) || !fs.existsSync(silkEncoder)) {
throw new Error("Silk SDK not found, make sure you compiled using command: wx-voice compile");
}
if (ffmpegPath && fs.existsSync(ffmpegPath)) {
this._ffmpegPath = path.resolve(ffmpegPath);
Ffmpeg.setFfmpegPath(this._ffmpegPath);
} else if (ffmpegPath = this._getFfmpegPath()) {
this._ffmpegPath = path.resolve(ffmpegPath);
} else {
throw new Error("FFMPEG not found");
}
}
// osx: x64 / other: ia32
var arch = process.platform === 'darwin' ? 'x64' : 'ia32'
// only windows has an extension
var ext = process.platform === 'win32' ? '.exe' : ''
try {
var ffmpeg = path.join(__dirname, 'ffmpeg', process.platform, arch, 'ffmpeg' + ext)
var ffprobe = path.join(__dirname, 'ffmpeg', process.platform, arch, 'ffprobe' + ext)
// this checks if the ffmpeg folder exists in our repo, if it doesn't it will return an error
fs.accessSync(ffmpeg, fs.F_OK)
fs.accessSync(ffprobe, fs.F_OK)
// folder exists so we need to load ffmpeg and ffprobe from our repo
FfmpegCommand.setFfmpegPath(ffmpeg)
FfmpegCommand.setFfprobePath(ffprobe)
} catch (e) {
// folder does not exist, this means that ffmpeg and ffprobe
// wore found somewhere else during the install process
// fluent-ffmpeg will set the correct paths on it's own
}
module.exports = FfmpegCommand
describe: 'Where to write the conversion result'
})
.option('ffmpeg-path', {
describe: 'Location ffmpeg executable to use'
})
.option('ffprobe-path', {
describe: 'Location ffprobe executable to use'
})
.usage('Usage: $0 --in [originalfile] --out [convertedfile]')
.demandOption(['in', 'out'])
.argv;
var src = argv.in;
if (argv.ffmpegPath) {
FFmpeg.setFfmpegPath(argv.ffmpegPath);
}
if (argv.ffprobePath) {
FFmpeg.setFfprobePath(argv.ffprobePath);
}
new FFmpeg({ source: src }).ffprobe(function (err, metadata) {
if (err) {
throw err;
} else if (!metadata) {
console.error('Failed reading metadata from video');
process.exit(1);
}
var fileExt = src.split('.')[src.split('.').length - 1];
const fs = require('fs')
const ffmpeg = require('fluent-ffmpeg')
const SpeechToTextV1 = require('watson-developer-cloud/speech-to-text/v1')
const {SPEECH_TO_TEXT_USERNAME, SPEECH_TO_TEXT_PASSWORD} = process.env
if (process.env.FFMPEG_PATH) {
ffmpeg.setFfmpegPath(process.env.FFMPEG_PATH)
}
const pathToSpeechFile = process.argv[2]
if (!pathToSpeechFile) {
console.log('Usage: node bin/speech-to-text ./path/to/file.webm')
process.exit(1)
}
if (!/\.(webm|ogg)$/.test(pathToSpeechFile)) {
console.log(`Error: ${pathToSpeechFile} not supported (.webm and .ogg only)`)
process.exit(1)
}
if (!SPEECH_TO_TEXT_USERNAME || !SPEECH_TO_TEXT_PASSWORD) {
console.log('Error: SPEECH_TO_TEXT_USERNAME & SPEECH_TO_TEXT_PASSWORD must be set.')
var os = require('os'),
path = require('path'),
fs = require('fs'),
glob = require('glob'),
ffmpeg = require('fluent-ffmpeg'),
argv = require('minimist')(process.argv.slice(2));
var batch_details_json = require(path.resolve(argv.details)),
ffmpeg_cmd = ffmpeg(),
concat_output = path.join(argv.outdir, argv.outname);
if (process.platform == 'win32') {
ffmpeg.setFfmpegPath(ffmpeg_win);
ffmpeg.setFfprobePath(ffprobe_win);
} else {
ffmpeg.setFfmpegPath(ffmpeg_osx);
ffmpeg.setFfprobePath(ffprobe_osx);
}
console.log("\n\nGathering scenes and sequencing for movie");
for (var i=0; i < batch_details_json.length; i++) {
var input_file = glob.sync(batch_details_json[i]["output_asset"] + ".*", { })[0];
console.log("\n\tscene " + (i + 1));
console.log("\t" + input_file);
ffmpeg_cmd.input(path.resolve(input_file));
}
ffmpeg_cmd.on('start', (command) => {
console.log('\n\nStarting concatenation of output:\n\n\t' + command);
function convertToWav(file,audioFile,ffmpegPath, callback) {
//setting ffmpeg binary path
if(ffmpegPath) {
ffmpeg.setFfmpegPath(ffmpegPath);
} else {
console.warn("ffmpeg binary path not defined, so using system one. if available");
}
//running ffmpeg comand
var comand = ffmpeg(file)
.noVideo()
.audioCodec('libopus')
.audioChannels(1)
.audioFrequency(16000)
.output(audioFile)
.on('end',
//listener must be a function, so to return the callback wrapping it inside a function
function(){
callback(audioFile)
}
public static get() {
const ffmpeg = require('fluent-ffmpeg');
try {
const ffmpegPath = require('@ffmpeg-installer/ffmpeg').path;
ffmpeg.setFfmpegPath(ffmpegPath);
const ffprobePath = require('@ffprobe-installer/ffprobe').path;
ffmpeg.setFfprobePath(ffprobePath);
} catch (e) {
}
return ffmpeg;
}
}
var ON_DEATH = require('death');
var ffmpeg = require('fluent-ffmpeg');
var fs = require('fs-extra');
var glob = require('glob');
var path = require('path');
var randomatic = require('randomatic');
var request = require('request');
var sha1 = require('sha1');
var _ = require('underscore');
var url = require('url');
var xml2js = require('xml2js');
var settingsApi = require('./settingsapi.js');
var utils = require('./utils.js');
var ffmpegPath = require('@ffmpeg-installer/ffmpeg').path;
ffmpeg.setFfmpegPath(ffmpegPath);
var MAXWIDTH = 1920;
var MAXHEIGHT = 1080;
/**
* Frozen PlotStatus object for use as enum
*/
var PlotStatus = Object.freeze({
initialising: 'initialising',
extracting: 'extracting',
rendering: 'rendering',
complete: 'complete',
failed: 'failed'
});
var animation = {};