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,36 +121,53 @@ router.get(
|
|||
|
||||
const [filename, fileExtension] = extension(`uploads/${req.params.file}`);
|
||||
if (
|
||||
fileExtension == ".mp4" ||
|
||||
fileExtension == ".mov" ||
|
||||
fileExtension == ".webm" ||
|
||||
fileExtension == ".gif"
|
||||
videoExtensions.includes(fileExtension)
|
||||
) {
|
||||
const imageData = ffProbe(
|
||||
`uploads/${req.params.file}`,
|
||||
filename,
|
||||
fileExtension
|
||||
);
|
||||
try {
|
||||
const imageData = ffProbe(
|
||||
`uploads/${req.params.file}`,
|
||||
filename,
|
||||
fileExtension
|
||||
);
|
||||
|
||||
width = (await imageData).streams[0].width;
|
||||
height = (await imageData).streams[0].height;
|
||||
width = (await imageData).streams[0].width;
|
||||
height = (await imageData).streams[0].height;
|
||||
|
||||
return res.render("gifv", {
|
||||
url: url,
|
||||
host: `${req.protocol}://${req.get("host")}`,
|
||||
width: width,
|
||||
height: height,
|
||||
});
|
||||
return res.render("gifv", {
|
||||
url: url,
|
||||
host: `${req.protocol}://${req.get("host")}`,
|
||||
width: width,
|
||||
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 {
|
||||
const imageData = await imageProbe(
|
||||
fs.createReadStream(`uploads/${req.params.file}`)
|
||||
);
|
||||
return res.render("gifv", {
|
||||
url: url,
|
||||
host: `${req.protocol}://${req.get("host")}`,
|
||||
width: imageData.width,
|
||||
height: imageData.height,
|
||||
});
|
||||
try {
|
||||
const imageData = await imageProbe(
|
||||
fs.createReadStream(`uploads/${req.params.file}`)
|
||||
);
|
||||
return res.render("gifv", {
|
||||
url: url,
|
||||
host: `${req.protocol}://${req.get("host")}`,
|
||||
width: imageData.width,
|
||||
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