I've got time codes using which I want to slice a short MP4 video (average length 5-7 minutes)
[ 0, 15, 35, 52, 142, 215, ...] // time codes in seconds
Usually there are 5-7 time codes meaning that I need to create 5-7 clips out of my initial video
The fist clip is from start to 15 sec, the second one is from 15 sec to 35 sec, 35-52, etc.
It's trivial operation in Bash but I'm using ffmpeg on NodeJS and I'd like to do it without iteration in one go
// Slicing a single clip
ffmpeg -i input.mp4 -ss 0 -to 15 -c copy clip-01.mp4
// Same command in NodeJS
ffmpeg(`/tmp/${id}/input.mp4`)
.renice(5)
.outputOptions([
'-ss 0',
'-to 15',
'-c copy'
])
.on('end', () => {})
.on('error', (e, stdout, stderr) => {})
.save(`/tmp/${id}/clip-01.mp4`);
No need for re-encoding, no need for precise timestamps (1 second out of sync is OK)
Any thoughts or ideas would be greatly appreciated!