const ffmpeg = require('fluent-ffmpeg');
const videoFile = './f1.mp4';
ffmpeg.ffprobe(videoFile, (err,metaData) => {
const {duration} = metaData.format;
const startingTime = parseInt(duration - 60);
const clipDuration = 20;
ffmpeg()
.input(videoFile)
.inputOptions([`-ss ${startingTime}`])
.outputOptions([`-t ${clipDuration}`])
.output('./result.mp4')
.on('end', ()=> console.log('Done!'))
.on('error',(err)=>console.error(err))
.run();
});
So this is my node js code where I am cutting a clip of the video my choice and giving me an output. I run it by node index. js ( code is in index.js file) I want to create a script that can run on the below command line
node index.js start_time end_time input/file/path.mp4 output/directory/
I mean it will be dynamic, as any input file from any directory and any output file from any directory like a function that will take user inputs and will accordingly. No manual set up. Is there a way to do that?? I have tried many but all are manually on the command line or a manual node setup. I am trying to create a dynamic js file that will run for any input