fix gifv to have a failover and to use videoExtensions to compare
This commit is contained in:
parent
06efb67198
commit
e8c05667d0
1 changed files with 43 additions and 26 deletions
|
@ -121,11 +121,9 @@ router.get(
|
||||||
|
|
||||||
const [filename, fileExtension] = extension(`uploads/${req.params.file}`);
|
const [filename, fileExtension] = extension(`uploads/${req.params.file}`);
|
||||||
if (
|
if (
|
||||||
fileExtension == ".mp4" ||
|
videoExtensions.includes(fileExtension)
|
||||||
fileExtension == ".mov" ||
|
|
||||||
fileExtension == ".webm" ||
|
|
||||||
fileExtension == ".gif"
|
|
||||||
) {
|
) {
|
||||||
|
try {
|
||||||
const imageData = ffProbe(
|
const imageData = ffProbe(
|
||||||
`uploads/${req.params.file}`,
|
`uploads/${req.params.file}`,
|
||||||
filename,
|
filename,
|
||||||
|
@ -141,7 +139,17 @@ router.get(
|
||||||
width: width,
|
width: width,
|
||||||
height: height,
|
height: height,
|
||||||
});
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error processing video:", error);
|
||||||
|
return res.render("gifv", {
|
||||||
|
url: url,
|
||||||
|
host: `${req.protocol}://${req.get("host")}`,
|
||||||
|
width: 800,
|
||||||
|
height: 600,
|
||||||
|
});
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
try {
|
||||||
const imageData = await imageProbe(
|
const imageData = await imageProbe(
|
||||||
fs.createReadStream(`uploads/${req.params.file}`)
|
fs.createReadStream(`uploads/${req.params.file}`)
|
||||||
);
|
);
|
||||||
|
@ -151,6 +159,15 @@ router.get(
|
||||||
width: imageData.width,
|
width: imageData.width,
|
||||||
height: imageData.height,
|
height: imageData.height,
|
||||||
});
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error processing image:", error);
|
||||||
|
return res.render("gifv", {
|
||||||
|
url: url,
|
||||||
|
host: `${req.protocol}://${req.get("host")}`,
|
||||||
|
width: 800,
|
||||||
|
height: 600,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue