17 lines
439 B
JavaScript
17 lines
439 B
JavaScript
const { exec } = require('child_process');
|
|
|
|
function probeVideo(videoPath) {
|
|
return new Promise((resolve) => {
|
|
const cmd = `ffprobe -v quiet -print_format json -show_format -show_streams "${videoPath}"`;
|
|
exec(cmd, (err, stdout) => {
|
|
if (err) return resolve({});
|
|
try {
|
|
resolve(JSON.parse(stdout));
|
|
} catch {
|
|
resolve({});
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
module.exports = { probeVideo };
|