forked from Supositware/Haha-Yes
Get video codec
This commit is contained in:
parent
c66f3e8403
commit
0b63dd3a60
1 changed files with 14 additions and 0 deletions
|
@ -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) => {
|
||||||
|
@ -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());
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
Loading…
Reference in a new issue