Skip to content

Instantly share code, notes, and snippets.

@tayiorbeii
Created October 17, 2022 19:29
Show Gist options
  • Select an option

  • Save tayiorbeii/d359ea0b922ac613eb98b370fe9587af to your computer and use it in GitHub Desktop.

Select an option

Save tayiorbeii/d359ea0b922ac613eb98b370fe9587af to your computer and use it in GitHub Desktop.
import "@johnlindquist/kit"
const replaceAll = await npm('just-replace-all')
// Name:
let cutsToMake = [
{
"from": "00:00:46",
"to": "00:58:47",
"desc": "2022-09-15 edited"
},
]
// from to desc
/*
* Highlight the long video we are taking clips out of in Finder
*/
let longVideoFile = await getSelectedFile()
/**
* Tell kit we want to be working in the same directory as the source file
*/
cd(path.dirname(longVideoFile))
for (let cut of cutsToMake) {
let fadeLength = 1
let clipFileName = `${replaceAll(cut.desc, ' ', '_')}.mp4`
await exec(`ffmpeg -i "${longVideoFile}" -c copy -ss ${cut.from} ${cut.to ? `-to ${cut.to}`: ''} ${clipFileName}`)
let { stdout } = await exec(`ffprobe -loglevel error -show_entries format=duration -of default=nk=1:nw=1 "${clipFileName}"`)
let totalDuration = stdout
let offset = totalDuration - fadeLength
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment