commit
This commit is contained in:
parent
7a86ad95b4
commit
afb3a2d0fd
3 changed files with 20 additions and 5 deletions
|
@ -157,6 +157,7 @@ export const ffmpegConvert = (path: string, filename: string, extension: string)
|
||||||
reject(`Submitted file is neither a video nor a gif: ${path}`);
|
reject(`Submitted file is neither a video nor a gif: ${path}`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
<<<<<<< HEAD
|
||||||
|
|
||||||
return new Promise<void>((resolve, reject) => {
|
return new Promise<void>((resolve, reject) => {
|
||||||
ffmpeg()
|
ffmpeg()
|
||||||
|
@ -183,3 +184,6 @@ export const ffProbe = (path: string, filename: string, extension: string) => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
=======
|
||||||
|
};**/
|
||||||
|
>>>>>>> f730b3d (commit)
|
||||||
|
|
|
@ -4,7 +4,7 @@ import fs from "fs";
|
||||||
import process from "process";
|
import process from "process";
|
||||||
|
|
||||||
import {extension, videoExtensions, imageExtensions} from "./lib";
|
import {extension, videoExtensions, imageExtensions} from "./lib";
|
||||||
import {db, MediaParams, insertToDB} from "./db";
|
import {insertToDB} from "./db";
|
||||||
import {ffmpegDownscale} from "./ffmpeg";
|
import {ffmpegDownscale} from "./ffmpeg";
|
||||||
|
|
||||||
export const checkAuth: Middleware = (req, res, next) => {
|
export const checkAuth: Middleware = (req, res, next) => {
|
||||||
|
|
|
@ -36,17 +36,20 @@ export const generateTestVideo = async (encodingType: EncodingType): Promise<voi
|
||||||
console.log(`Generating test video using ${encodingType}...`);
|
console.log(`Generating test video using ${encodingType}...`);
|
||||||
|
|
||||||
const startTime = Date.now();
|
const startTime = Date.now();
|
||||||
|
let totalFrames = 0;
|
||||||
|
|
||||||
const outputOptions = [
|
const outputOptions = [
|
||||||
'-vf', 'scale=-2:720',
|
'-vf', 'scale=-2:720',
|
||||||
'-c:v', encodingType,
|
'-vcodec', encodingType,
|
||||||
'-c:a', 'copy',
|
'-c:a', 'copy',
|
||||||
|
'-b:v', '5000k',
|
||||||
|
'-pix_fmt', 'yuv420p',
|
||||||
];
|
];
|
||||||
|
|
||||||
// Adjust output options based on encoder for maximum quality
|
// Adjust output options based on encoder for maximum quality
|
||||||
switch(encodingType) {
|
switch(encodingType) {
|
||||||
case EncodingType.CPU:
|
case EncodingType.CPU:
|
||||||
outputOptions.push('-crf', '0');
|
//outputOptions.push('-crf', '0');
|
||||||
break;
|
break;
|
||||||
case EncodingType.NVIDIA:
|
case EncodingType.NVIDIA:
|
||||||
outputOptions.push('-rc', 'cqp', '-qp', '0');
|
outputOptions.push('-rc', 'cqp', '-qp', '0');
|
||||||
|
@ -64,12 +67,20 @@ export const generateTestVideo = async (encodingType: EncodingType): Promise<voi
|
||||||
|
|
||||||
return new Promise<void>((resolve, reject) => {
|
return new Promise<void>((resolve, reject) => {
|
||||||
ffmpeg()
|
ffmpeg()
|
||||||
.input('test.mp4')
|
.input('unknown_replay_2023.10.29-22.57-00.00.38.103-00.01.00.016.mp4')
|
||||||
.inputFormat('mp4')
|
.inputFormat('mp4')
|
||||||
.outputOptions(outputOptions)
|
.outputOptions(outputOptions)
|
||||||
.output(`720p-test-${encodingType}.mp4`)
|
.output(`720p-test-${encodingType}.mp4`)
|
||||||
|
.on('progress', (progress) => {
|
||||||
|
totalFrames = progress.frames;
|
||||||
|
})
|
||||||
.on('end', () => {
|
.on('end', () => {
|
||||||
|
const elapsedTime = (Date.now() - startTime) / 1000; // Convert to seconds
|
||||||
|
const avgFps = totalFrames / elapsedTime;
|
||||||
|
|
||||||
console.log(`720p copy complete using ${encodingType}, took ${Date.now() - startTime}ms to complete`);
|
console.log(`720p copy complete using ${encodingType}, took ${Date.now() - startTime}ms to complete`);
|
||||||
|
console.log(`Average FPS for the entire process: ${avgFps.toFixed(2)}`);
|
||||||
|
|
||||||
resolve();
|
resolve();
|
||||||
})
|
})
|
||||||
.on('error', (e) => reject(new Error(e)))
|
.on('error', (e) => reject(new Error(e)))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue