Modifier la création de vidéos pour utiliser des promesses et gérer les erreurs lors de l'exécution de ffmpeg
This commit is contained in:
@@ -64,14 +64,19 @@ async function createVideoWithList(projectId, pathList, duration, videoId) {
|
|||||||
// Commande ffmpeg pour créer la vidéo
|
// 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}`;
|
const ffmpegCommand = `ffmpeg -r ${frameRate} -f concat -safe 0 -i ${tempFile} -vsync vfr -pix_fmt yuv420p ${outputVideo}`;
|
||||||
console.log('Running ffmpeg command:', ffmpegCommand);
|
console.log('Running ffmpeg command:', ffmpegCommand);
|
||||||
execSync(ffmpegCommand);
|
execSync(ffmpegCommand).then(() => {
|
||||||
console.log('Video created successfully:', outputVideo);
|
console.log('Video created successfully:', outputVideo);
|
||||||
|
|
||||||
// Mettre à jour le statut de la vidéo à "completed"
|
// Mettre à jour le statut de la vidéo à "completed"
|
||||||
const updateStatusQuery = 'UPDATE public.videos SET status = $2 WHERE id = $1 RETURNING *';
|
const updateStatusQuery = 'UPDATE public.videos SET status = $2 WHERE id = $1 RETURNING *';
|
||||||
const updateStatusValues = [videoId, 1]; // 1 pour le statut "completed"
|
const updateStatusValues = [videoId, 1]; // 1 pour le statut "completed"
|
||||||
const updateStatusRes = await db.query(updateStatusQuery, updateStatusValues);
|
const updateStatusRes = db.query(updateStatusQuery, updateStatusValues);
|
||||||
console.log('Video status updated to completed:', updateStatusRes.rows[0]);
|
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;
|
return outputVideo;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user