Modifier la fonction createVideoWithList pour inclure l'ID de la vidéo et mettre à jour le statut de la vidéo après le rendu

This commit is contained in:
2025-03-10 17:36:39 +01:00
parent 7baac5dcb7
commit 55697fc032
2 changed files with 11 additions and 11 deletions

View File

@@ -347,21 +347,12 @@ 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);
const videoFile = await videoManager.createVideoWithList(project_id, pathList, duration, videoId);
console.log('Video file:', videoFile);
await videoManager.updateVideoFile(videoId, videoFile);
console.log('Video rendering complete');
//changer status de la vidéo à 1
const query = 'UPDATE public.videos SET status = 1 WHERE id = $1';
db.query(query, [videoId], (err, results) => {
if (err) {
return serverError.sendError('Error updating video status:', res, err);
}
console.log('Video status updated:', results.rows[0]);
});
} catch (err) {
console.error('Error during video rendering:', err);
res.status(500).json({ error: 'Error during video rendering' });

View File

@@ -27,7 +27,7 @@ async function deleteVideoProject(videoId) {
return res.rows[0];
}
async function createVideoWithList(projectId, pathList, duration) {
async function createVideoWithList(projectId, pathList, duration, videoId) {
const tempFile = path.join('temp.txt');
try {
const workdir = path.join(PROJECTS_DIR, 'storage', `${projectId}`);
@@ -89,6 +89,15 @@ async function createVideoWithList(projectId, pathList, duration) {
fs.unlinkSync(tempFile);
console.log('Temporary file deleted:', tempFile);
}
//changer status de la vidéo à 1
const query = 'UPDATE public.videos SET status = 1 WHERE id = $1';
db.query(query, [videoId], (err, results) => {
if (err) {
return serverError.sendError('Error updating video status:', res, err);
}
console.log('Video status updated:', results.rows[0]);
});
}
}