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, ffmpeg,
stringIsAValidurl, stringIsAValidurl,
compressVideo, compressVideo,
getVideoCodec,
}; };
async function downloadVideo(urlArg, output, format = 'bestvideo*+bestaudio/best') { async function downloadVideo(urlArg, output, format = 'bestvideo*+bestaudio/best') {
await new Promise((resolve, reject) => { await new Promise((resolve, reject) => {
@ -76,4 +77,17 @@ async function compressVideo(input, output, preset) {
resolve(); resolve();
}); });
}); });
}
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());
});
});
} }