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:
@@ -347,21 +347,12 @@ router.post('/videos/render/:video_id', async (req, res) => {
|
|||||||
console.log('Path list:', pathList);
|
console.log('Path list:', pathList);
|
||||||
res.json({ message: 'Render process started' });
|
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);
|
console.log('Video file:', videoFile);
|
||||||
|
|
||||||
await videoManager.updateVideoFile(videoId, videoFile);
|
await videoManager.updateVideoFile(videoId, videoFile);
|
||||||
|
|
||||||
console.log('Video rendering complete');
|
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) {
|
} catch (err) {
|
||||||
console.error('Error during video rendering:', err);
|
console.error('Error during video rendering:', err);
|
||||||
res.status(500).json({ error: 'Error during video rendering' });
|
res.status(500).json({ error: 'Error during video rendering' });
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ async function deleteVideoProject(videoId) {
|
|||||||
return res.rows[0];
|
return res.rows[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
async function createVideoWithList(projectId, pathList, duration) {
|
async function createVideoWithList(projectId, pathList, duration, videoId) {
|
||||||
const tempFile = path.join('temp.txt');
|
const tempFile = path.join('temp.txt');
|
||||||
try {
|
try {
|
||||||
const workdir = path.join(PROJECTS_DIR, 'storage', `${projectId}`);
|
const workdir = path.join(PROJECTS_DIR, 'storage', `${projectId}`);
|
||||||
@@ -89,6 +89,15 @@ async function createVideoWithList(projectId, pathList, duration) {
|
|||||||
fs.unlinkSync(tempFile);
|
fs.unlinkSync(tempFile);
|
||||||
console.log('Temporary file deleted:', 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]);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user