jschan - Anonymous imageboard software. Classic look, modern features and feel. Works without JavaScript and supports Tor, I2P, Lokinet, etc.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

38 lines
1.2 KiB

const ffmpeg = require('fluent-ffmpeg')
, config = require(__dirname+'/../../config.js')
, uploadDirectory = require(__dirname+'/uploadDirectory.js');
module.exports = (file, geometry, timestamp) => {
const { thumbSize } = config.get;
return new Promise((resolve, reject) => {
const command = ffmpeg(`${uploadDirectory}/file/${file.filename}`)
.on('end', () => {
return resolve();
})
.on('error', function(err, stdout, stderr) {
return reject(err);
})
if (timestamp === 0) {
//bypass issue with some dumb files like audio album art covert not working with .screenshots
command.inputOptions([
'-t',
0
])
.outputOptions([
`-vf scale=${geometry.width > geometry.height ? thumbSize + ':-2' : '-2:' + thumbSize}`,
'-frames:v 1'
])
.output(`${uploadDirectory}/file/thumb/${file.hash}${file.thumbextension}`)
.run();
} else {
command.screenshots({
timestamps: [timestamp],
count: 1,
filename: `${file.hash}${file.thumbextension}`,
folder: `${uploadDirectory}/file/thumb/`,
size: geometry.width > geometry.height ? `${thumbSize}x?` : `?x${thumbSize}`
//keep aspect ratio, but also making sure taller/wider thumbs dont exceed thumbSize in either dimension
});
}
});
};