Modifier la fonction createVideoWithList pour accepter la durée et ajuster le frame rate en conséquence
This commit is contained in:
@@ -342,7 +342,9 @@ 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 = results.rows[0].duration;
|
||||||
|
|
||||||
|
const videoFile = await videoManager.createVideoWithList(project_id, pathList, duration);
|
||||||
console.log('Video file:', videoFile);
|
console.log('Video file:', videoFile);
|
||||||
|
|
||||||
await videoManager.updateVideoFile(videoId, videoFile);
|
await videoManager.updateVideoFile(videoId, videoFile);
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ async function deleteVideoProject(videoId) {
|
|||||||
return res.rows[0];
|
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
|
//pathList étant la liste des chemins déjà triés
|
||||||
const tempFile = path.join('temp.txt');
|
const tempFile = path.join('temp.txt');
|
||||||
try {
|
try {
|
||||||
@@ -55,7 +55,7 @@ async function createVideoWithList(projectId, pathList) {
|
|||||||
// Créer un fichier temporaire pour la liste des images
|
// Créer un fichier temporaire pour la liste des images
|
||||||
fs.writeFileSync(tempFile, sortedImages.map(image => `file '${image}'`).join('\n'));
|
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
|
// le fichier final prend cette forme : {projectId}_{firstImageId}_{lastImageId}-{timestamp}.mp4
|
||||||
const timestamp = new Date().getTime();
|
const timestamp = new Date().getTime();
|
||||||
|
|||||||
Reference in New Issue
Block a user