1
0
mirror of https://github.com/bpatrik/pigallery2.git synced 2024-12-25 02:04:15 +02:00

fixing video thumbnail error

This commit is contained in:
Patrik J. Braun 2018-11-23 22:03:21 +01:00
parent ddd1c97bf8
commit 2427e6f054
2 changed files with 11 additions and 4 deletions

View File

@ -52,6 +52,7 @@ export interface RendererInput {
export class VideoRendererFactory {
public static build(): (input: RendererInput) => Promise<void> {
const ffmpeg = FFmpegFactory.get();
const path = require('path');
return (input: RendererInput): Promise<void> => {
return new Promise((resolve, reject) => {
@ -63,24 +64,30 @@ export class VideoRendererFactory {
}
const ratio = data.streams[0].height / data.streams[0].width;
const command: FfmpegCommand = ffmpeg(input.mediaPath);
const fileName = path.basename(input.thPath);
const folder = path.dirname(input.thPath);
let executedCmd = '';
command
.on('start', (cmd) => {
executedCmd = cmd;
})
.on('end', () => {
resolve();
})
.on('error', (e) => {
reject(e.toString());
reject(e.toString() + ' executed: ' + executedCmd);
})
.outputOptions(['-qscale:v 4']);
if (input.makeSquare === false) {
const newWidth = Math.round(Math.sqrt((input.size * input.size) / ratio));
command.takeScreenshots({
timemarks: ['10%'], size: newWidth + 'x?', filename: input.thPath
timemarks: ['10%'], size: newWidth + 'x?', filename: fileName, folder: folder
});
} else {
command.takeScreenshots({
timemarks: ['10%'], size: input.size + 'x' + input.size, filename: input.thPath
timemarks: ['10%'], size: input.size + 'x' + input.size, filename: fileName, folder: folder
});
}
});

View File

@ -1,6 +1,6 @@
{
"name": "pigallery2",
"version": "1.2.2",
"version": "1.2.9",
"description": "This is a photo gallery optimised for running low resource servers (especially on raspberry pi)",
"author": "Patrik J. Braun",
"homepage": "https://github.com/bpatrik/PiGallery2",