This is the code that runs https://bandolier.learnjsthehardway.com/ for you to review. It uses the https://git.learnjsthehardway.com/learn-javascript-the-hard-way/bandolier-template to create the documentation for the project.
https://bandolier.learnjsthehardway.com/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
969 B
39 lines
969 B
import ffmpeg from "fluent-ffmpeg";
|
|
import path from "path";
|
|
|
|
export const description = "Generates a thumbnail of a specific size from a video."
|
|
|
|
export const options = [
|
|
["--input <file>", "input file video"],
|
|
["--start <time>", "starting position", 600],
|
|
["--output <file>", "output filename, ext will determine type"],
|
|
["--debug <level>", "debug level for ffmpeg, 1=command, 2=all"]
|
|
];
|
|
|
|
export const main = (opts) => {
|
|
const { dir, name } = path.parse(opts.input);
|
|
|
|
const encode = ffmpeg(opts.input)
|
|
.inputOptions([
|
|
"-ss", opts.start
|
|
])
|
|
.outputOptions([
|
|
"-frames:v", 1,
|
|
"-vsync", "vfr"
|
|
])
|
|
.on("end", () => process.exit(0));
|
|
|
|
if(opts.output) {
|
|
encode.output(opts.output);
|
|
} else {
|
|
encode.output(`${dir}/${name}.jpg`);
|
|
}
|
|
|
|
if(opts.debug === 1) {
|
|
encode.on("start", line => console.log(line))
|
|
} else if(opts.debug === 2) {
|
|
encode.on("stderr", line => console.log(line))
|
|
}
|
|
|
|
encode.run();
|
|
}
|
|
|