From 9e850f00903724de0beef48a9c92cbb3fbda2c5c Mon Sep 17 00:00:00 2001 From: dakerboul Date: Mon, 10 Mar 2025 17:08:11 +0100 Subject: [PATCH] =?UTF-8?q?Modifier=20la=20fonction=20createVideoWithList?= =?UTF-8?q?=20pour=20accepter=20la=20dur=C3=A9e=20et=20ajuster=20le=20fram?= =?UTF-8?q?e=20rate=20en=20cons=C3=A9quence?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routes/videoRoutes.js | 4 +++- src/video/videoManager.js | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/routes/videoRoutes.js b/routes/videoRoutes.js index bfd2096..28fe3c5 100644 --- a/routes/videoRoutes.js +++ b/routes/videoRoutes.js @@ -342,7 +342,9 @@ router.post('/videos/render/:video_id', async (req, res) => { console.log('Path list:', pathList); res.json({ message: 'Render process started' }); - const videoFile = await videoManager.createVideoWithList(project_id, pathList); + duration = results.rows[0].duration; + + const videoFile = await videoManager.createVideoWithList(project_id, pathList, duration); console.log('Video file:', videoFile); await videoManager.updateVideoFile(videoId, videoFile); diff --git a/src/video/videoManager.js b/src/video/videoManager.js index 1aed47c..3e06eff 100644 --- a/src/video/videoManager.js +++ b/src/video/videoManager.js @@ -27,7 +27,7 @@ async function deleteVideoProject(videoId) { return res.rows[0]; } -async function createVideoWithList(projectId, pathList) { +async function createVideoWithList(projectId, pathList, duration) { //pathList étant la liste des chemins déjà triés const tempFile = path.join('temp.txt'); try { @@ -55,7 +55,7 @@ async function createVideoWithList(projectId, pathList) { // Créer un fichier temporaire pour la liste des images fs.writeFileSync(tempFile, sortedImages.map(image => `file '${image}'`).join('\n')); - const frameRate = 10; + const frameRate = Math.ceil(sortedImages.length / duration); // le fichier final prend cette forme : {projectId}_{firstImageId}_{lastImageId}-{timestamp}.mp4 const timestamp = new Date().getTime();