|
|
@ -146,28 +146,28 @@ async function autoCrop(input, output) {
|
|
|
|
|
|
|
|
|
|
|
|
execFile('ffprobe',
|
|
|
|
execFile('ffprobe',
|
|
|
|
['-f', 'lavfi', '-i', `movie=${ffprobeInput},cropdetect`, '-show_entries',
|
|
|
|
['-f', 'lavfi', '-i', `movie=${ffprobeInput},cropdetect`, '-show_entries',
|
|
|
|
'packet_tags=lavfi.cropdetect.w,lavfi.cropdetect.h,lavfi.cropdetect.x,lavfi.cropdetect.y',
|
|
|
|
'packet_tags=lavfi.cropdetect.w,lavfi.cropdetect.h,lavfi.cropdetect.x,lavfi.cropdetect.y',
|
|
|
|
'-read_intervals', '%+#10', '-hide_banner', '-print_format', 'json'], async (err, stdout, stderr) => {
|
|
|
|
'-read_intervals', '%+#10', '-hide_banner', '-print_format', 'json'], async (err, stdout, stderr) => {
|
|
|
|
if (err) {
|
|
|
|
if (err) {
|
|
|
|
reject(stderr);
|
|
|
|
reject(stderr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (stderr) {
|
|
|
|
if (stderr) {
|
|
|
|
console.error(stderr);
|
|
|
|
console.error(stderr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const packets = JSON.parse(stdout).packets;
|
|
|
|
const packets = JSON.parse(stdout).packets;
|
|
|
|
|
|
|
|
|
|
|
|
for (let i = 0; i < packets.length; i++) {
|
|
|
|
for (let i = 0; i < packets.length; i++) {
|
|
|
|
const element = packets[i];
|
|
|
|
const element = packets[i];
|
|
|
|
|
|
|
|
|
|
|
|
if (element.tags) {
|
|
|
|
if (element.tags) {
|
|
|
|
const cropdetect = element.tags;
|
|
|
|
const cropdetect = element.tags;
|
|
|
|
await ffmpeg(['-i', input, '-vf', `crop=${cropdetect['lavfi.cropdetect.w']}:${cropdetect['lavfi.cropdetect.h']}:${cropdetect['lavfi.cropdetect.x']}:${cropdetect['lavfi.cropdetect.y']}`, '-vcodec', 'libx264', '-acodec', 'aac', output])
|
|
|
|
await ffmpeg(['-i', input, '-vf', `crop=${cropdetect['lavfi.cropdetect.w']}:${cropdetect['lavfi.cropdetect.h']}:${cropdetect['lavfi.cropdetect.x']}:${cropdetect['lavfi.cropdetect.y']}`, '-vcodec', 'libx264', '-acodec', 'aac', output]);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
console.log(NODE_ENV === 'development' ? stdout : null);
|
|
|
|
console.log(NODE_ENV === 'development' ? stdout : null);
|
|
|
|
resolve();
|
|
|
|
resolve();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|