Ajouter la prise en charge de la résolution personnalisée lors de la création de vidéos
This commit is contained in:
@@ -57,9 +57,15 @@ router.post('/videos', async (req, res) => {
|
||||
|
||||
const { duration: videoDuration, measurement_ids: videoMeasurementIds, project_id: videoProjectId } = result.rows[0];
|
||||
const pathList = await measureManager.getPathList(videoMeasurementIds, videoProjectId);
|
||||
|
||||
// parser la résolution (ex: 1920x1080)
|
||||
const [res_width, res_height] = resolution.split('x').map(Number);
|
||||
if (isNaN(res_width) || isNaN(res_height)) {
|
||||
return res.status(400).json({ error: 'Invalid resolution format. Use WIDTHxHEIGHT (e.g., 1920x1080)' });
|
||||
}
|
||||
|
||||
// Start background processing
|
||||
videoManager.createVideoWithList(videoProjectId, pathList, videoDuration, videoId)
|
||||
videoManager.createVideoWithList(videoProjectId, pathList, videoDuration, videoId, res_width, res_height)
|
||||
.then(videoFile => {
|
||||
console.log('Rendu vidéo terminé:', videoFile);
|
||||
return videoManager.updateVideoFile(videoId, videoFile);
|
||||
|
||||
@@ -32,7 +32,7 @@ async function deleteVideoProject(videoId) {
|
||||
return res.rows[0];
|
||||
}
|
||||
|
||||
async function createVideoWithList(projectId, pathList, duration, videoId) {
|
||||
async function createVideoWithList(projectId, pathList, duration, videoId, res_width, res_height) {
|
||||
const tempFile = path.join('temp.txt');
|
||||
let ffmpegProcess;
|
||||
let cleanupDone = false;
|
||||
@@ -76,6 +76,7 @@ async function createVideoWithList(projectId, pathList, duration, videoId) {
|
||||
eta = NULL
|
||||
WHERE id = $1
|
||||
`, [videoId]);
|
||||
const scale = res_width && res_height ? `scale=${res_width}:${res_height}` : 'scale=854:480'; // Redimensionne la vidéo en 480p par défaut
|
||||
|
||||
// Configuration de FFmpeg
|
||||
const ffmpegArgs = [
|
||||
@@ -86,7 +87,7 @@ async function createVideoWithList(projectId, pathList, duration, videoId) {
|
||||
'-i', tempFile,
|
||||
'-vsync', 'vfr',
|
||||
'-pix_fmt', 'yuv420p',
|
||||
'-vf', 'scale=854:480', // Redimensionne la vidéo en 480p
|
||||
'-vf', scale,
|
||||
'-b:v', '1500k', // Force un bitrate vidéo de 1500 kbps (ajuste si nécessaire)
|
||||
outputVideo
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user