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();