Get video codec

This commit is contained in:
Supositware 2023-03-20 03:55:53 +01:00
parent c66f3e8403
commit 0b63dd3a60

View file

@ -8,6 +8,7 @@ export default {
ffmpeg,
stringIsAValidurl,
compressVideo,
getVideoCodec,
};
async function downloadVideo(urlArg, output, format = 'bestvideo*+bestaudio/best') {
await new Promise((resolve, reject) => {
@ -77,3 +78,16 @@ async function compressVideo(input, output, preset) {
});
});
}
async function getVideoCodec(input) {
return await new Promise((resolve, reject) => {
exec(`ffprobe -v error -select_streams v:0 -show_entries stream=codec_name -of default=noprint_wrappers=1:nokey=1 ${input}`, (err, stdout, stderr) => {
if (err) {
reject(stderr);
}
if (stderr) {
console.error(stderr);
}
resolve(stdout.trim());
});
});
}