Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.output(tmpFile)
.audioFrequency(POST_SAMPLE_RATE)
.toFormat('flac')
.run();
}
var file = options.file || options;
var segments = options.segments;
var maxDuration = options.maxDuration | MAX_SEG_DUR;
var maxRetries = options.maxRetries | 1;
var limitConcurrent = options.limitConcurrent | MAX_CONCURRENT;
var retries = 0;
// Get file information and divide into segments
// Then process each of these segments individually, and combine results at the end
ffmpeg.ffprobe(file, function (err, info) {
var audioSegments = []
var totalDuration = info.format.duration;
if (segments) {
for (var i = 0; i < segments.length; i++) {
var duration = (i == segments.length-1) ? totalDuration-segments[i]: segments[i+1]-segments[i];
if (duration < 0) {
callback(new Error("segments must be a sorted array of start times, \
each less than the total length of your audio"));
}
var curStart = segments[i];
while (duration > maxDuration + .001) {
audioSegments.push({
'start': curStart,
'duration': maxDuration
});
duration -= maxDuration;
var id = movie._id;
var outpath = './public/videos/';
var des = outpath + id;
var videoarr = path.split(".");
videoarr.pop();
var srtpath = videoarr.join(".")+".srt";
fs.exists(des, function(exists){
if(!exists){
fs.mkdir(des,function(err) {
if(err) {
console.log(err);
}
})
}
});
ffmpeg.ffprobe(path,function(err,metadata){
if(err) {
console.log(err);
}
Setting.find()
.exec(function(err, setting) {
var wmimage = setting[0].wmpath;
var hd = setting[0].hd*1;
var wd = 0;
var markdir = "./public/mark/mark.png";
var videometa = metadata.format;
var videostreams = metadata.streams;
var bitrate = Math.floor(videometa.bit_rate / 1000);
var size = "";
var bv = 500;
var bufsize = 1000;
var maxrate = 500;
var id = movie._id;
var outpath = './public/videos/';
var des = outpath + id;
var videoarr = path.split(".");
videoarr.pop();
var srtpath = videoarr.join(".") + ".srt";
fs.exists(des, function (exists) {
if (!exists) {
fs.mkdir(des, function (err) {
if (err) {
console.log(err);
}
})
}
});
ffmpeg.ffprobe(path, function (err, metadata) {
if (err) {
console.log(err);
}
Setting.find()
.exec(function (err, setting) {
var wmimage = setting[0].wmpath;
var hd = setting[0].hd * 1;
var wd = 0;
var markdir = "./public/mark/mark.png";
var videometa = metadata.format;
var videostreams = metadata.streams;
var bitrate = Math.floor(videometa.bit_rate / 1000);
var size = "";
var bv = 500;
var bufsize = 1000;
var maxrate = 500;
var id = movie._id;
var outpath = './public/videos/';
var des = outpath + id;
var videoarr = path.split(".");
videoarr.pop();
var srtpath = videoarr.join(".")+".srt";
fs.exists(des, function(exists){
if(!exists){
fs.mkdir(des,function(err) {
if(err) {
console.log(err);
}
})
}
});
ffmpeg.ffprobe(path,function(err,metadata){
if(err) {
console.log(err);
}
console.log(metadata);
Setting.find()
.exec(function(err, setting) {
var wmimage = setting[0].wmpath;
var hd = setting[0].hd*1;
var videometa = metadata.streams[0];
var size = "";
var bv = "500k";
var bufsize = "1000k";
var maxrate = "500k";
var vf = 'movie=' + wmimage + ' [watermark]; [in][watermark] overlay=main_w-overlay_w [out]';
if (hd==480) {
size = "720x480";
app.post("/metadata", function(req, res) {
var file = req.body.file;
console.log("Metadata of", file, "requested");
var filetype = getFileType(file);
if ( filetype == "video"){
ffmpeg.ffprobe(file, function(err, metadata) {
metadata.path = file;
metadata.filetype = filetype;
res.render("metadata", {
path: file,
filetype: filetype,
video: get_stream(metadata, 'video') || {
width: -1,
height: -1,
duration: -1,
bit_rate: -1,
codec_long_name: 'N/A'
},
audio: get_stream(metadata, 'audio') || {
bit_rate: -1,
codec_long_name: 'N/A'
}
return new Promise((resolve, reject) => {
const channel = this;
const itemId = item.id;
const itemPath = itemId.split($path.sep).map(encodeURIComponent).join("/");
ff.ffprobe(this.getFile(item.id), (err, metadata) => {
if (err) {
reject(err);
} else {
let duration = parseFloat(metadata.format.duration) * 1000;
const baseUrl = `${channel.pith.rootUrl}stream/${encodeURIComponent(options && options.fingerprint) || '0'}/${itemPath}`;
const desc = {
url: baseUrl,
mimetype: item.mimetype || 'application/octet-stream',
seekable: true,
format: {
container: metadata.format.tags ? metadata.format.tags.major_brand : 'unknown',
streams: metadata.streams.map(stream => ({
index: stream.index,
codec: stream.codec_name,
exec: function playfile (data) {
if (this.io.input) return false;
ffmpeg.ffprobe(data.filename, (error, meta) => {
if (error) {
this.emit('error', error);
if (data.done) data.done(error, true);
return;
}
if (!this.io.input) {
const conf = this.config.extensions.audio;
const stream = meta.streams[0];
const samples = 48000;
this.space.set('audio.streaming', true);
this.io.establish({
input: true,
inputOptions: {
duration(filePath, callback) {
Ffmpeg.ffprobe(filePath, (err, metadata) => {
if (err) return callback(0);
if (metadata && metadata.format) {
var duration = parseFloat(metadata.format.duration);
duration = (isNaN(duration)) ? 0 : duration;
}
callback(duration);
});
}
function extractMetadata(song, path, metadata) {
metadata = metadata || {};
var deferred = Q.defer();
ffmpeg.ffprobe(path, function(err, data) {
if (!err && !data.format.duration) {
err = new Error('No duration found.');
}
if (err) {
deferred.reject(err);
return;
}
var tags = data.format.tags || {};
if (metadata.title) song.title = metadata.title;
else if (tags.title) song.title = tags.title;
if (metadata.album) song.album = metadata.album;
else if (tags.album) song.album = tags.album;