Skip to content

Instantly share code, notes, and snippets.

@tayiorbeii
Created September 21, 2022 20:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tayiorbeii/67c37e4feacf8eda409b1abf5d88b6cc to your computer and use it in GitHub Desktop.
Save tayiorbeii/67c37e4feacf8eda409b1abf5d88b6cc to your computer and use it in GitHub Desktop.
import "@johnlindquist/kit"
const replaceAll = await npm('just-replace-all')
// Name:
let cutsToMake = [
{
from: '00:18:38',
to: '00:33:51',
desc: 'part01'
},
{
from: '00:41:39',
to: '00:45:03',
desc: 'part02'
},
{
from: '00:55:15',
to: '01:06:12',
desc: 'part03'
},
{
from: '01:33:14',
to: '01:46:28',
desc: 'part04'
},
{
from: '01:54:40',
to: '02:07:17',
desc: 'part05'
},
{
from: '02:30:52',
to: '02:40:16',
desc: 'part06'
},
{
from: '03:05:15',
to: '03:18:40',
desc: 'part07'
},
{
from: '03:48:15',
to: '03:52:01',
desc: 'part08'
},
{
from: '04:22:48',
to: '04:45:37',
desc: 'part09'
},
{
from: '05:06:39',
to: '05:18:00',
desc: 'part10'
},
]
// 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} -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