diff --git a/src/video/videoManager.js b/src/video/videoManager.js index e4b1d3b..e1f128e 100644 --- a/src/video/videoManager.js +++ b/src/video/videoManager.js @@ -64,14 +64,19 @@ async function createVideoWithList(projectId, pathList, duration, videoId) { // Commande ffmpeg pour créer la vidéo const ffmpegCommand = `ffmpeg -r ${frameRate} -f concat -safe 0 -i ${tempFile} -vsync vfr -pix_fmt yuv420p ${outputVideo}`; console.log('Running ffmpeg command:', ffmpegCommand); - execSync(ffmpegCommand); - console.log('Video created successfully:', outputVideo); + execSync(ffmpegCommand).then(() => { + console.log('Video created successfully:', outputVideo); - // Mettre à jour le statut de la vidéo à "completed" - const updateStatusQuery = 'UPDATE public.videos SET status = $2 WHERE id = $1 RETURNING *'; - const updateStatusValues = [videoId, 1]; // 1 pour le statut "completed" - const updateStatusRes = await db.query(updateStatusQuery, updateStatusValues); - console.log('Video status updated to completed:', updateStatusRes.rows[0]); + // Mettre à jour le statut de la vidéo à "completed" + const updateStatusQuery = 'UPDATE public.videos SET status = $2 WHERE id = $1 RETURNING *'; + const updateStatusValues = [videoId, 1]; // 1 pour le statut "completed" + const updateStatusRes = db.query(updateStatusQuery, updateStatusValues); + console.log('Video status updated to completed:', updateStatusRes.rows[0]); + } + ).catch((error) => { + console.error('Error creating video:', error); + serverError.sendError('Error creating video', err=error); + }); return outputVideo; } catch (error) {