Created
April 15, 2022 16:01
-
-
Save tayiorbeii/da5e8ea742490e55d35f1b7342fae366 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import "@johnlindquist/kit" | |
const replaceAll = await npm('just-replace-all') | |
// Name: cut video clips | |
let cutsToMake = [ | |
{ | |
from: '00:10:40', | |
to: '00:13:22', | |
desc: '04 - 11 client side routing thoughts' | |
}, | |
{ | |
from: '00:13:21', | |
to: '00:15:29', | |
desc: '04 - 12 approaching client side routing test' | |
}, | |
{ | |
from: '00:15:28', | |
to: '00:18:04', | |
desc: '04 - 13 reach router thoughts' | |
}, | |
{ | |
from: '00:18:03', | |
to: '00:22:15', | |
desc: '04 - 14 start page change test' | |
}, | |
{ | |
from: '00:22:48', | |
to: '00:26:17', | |
desc: '04 - 15 h1 issues pt1' | |
}, | |
{ | |
from: '00:26:31', | |
to: '00:29:25', | |
desc: '04 - 16 h1 issues pt2' | |
}, | |
{ | |
from: '00:30:10', | |
to: '00:33:37', | |
desc: '05 - 01 puppeteer intro' | |
}, | |
{ | |
from: '00:33:36', | |
to: '00:35:54', | |
desc: '05 - 02 a11y tree intro' | |
}, | |
{ | |
from: '00:35:53', | |
to: '00:38:24', | |
desc: '05 - 03 a11y tree part 2' | |
}, | |
{ | |
from: '00:38:42', | |
to: '00:42:07', | |
desc: '05 - 04 a11y tree resources' | |
}, | |
{ | |
from: '00:43:05', | |
to: '00:45:20', | |
desc: '06 - 01 puppeteer test intro' | |
}, | |
{ | |
from: '00:45:19', | |
to: '00:48:13', | |
desc: '06 - 02 puppeteer test setup pt1' | |
}, | |
{ | |
from: '00:48:52', | |
to: '00:49:31', | |
desc: '06 - 03 test is running after rename' | |
}, | |
{ | |
from: '00:49:29', | |
to: '00:52:03', | |
desc: '06 - 04 writing tree snapshot test' | |
}, | |
{ | |
from: '00:52:03', | |
to: '00:53:45', | |
desc: '06 - 05 running tree snapshot test' | |
}, | |
{ | |
from: '00:53:56', | |
to: '00:56:29', | |
desc: '06 - 06 intersting only mode' | |
}, | |
{ | |
from: '00:56:27', | |
to: '00:57:22', | |
desc: '06 - 07 landmark exploration' | |
}, | |
{ | |
from: '00:57:23', | |
to: '01:02:16', | |
desc: '06 - 08 start meganav assertion' | |
}, | |
{ | |
from: '01:02:17', | |
to: '01:04:52', | |
desc: '06 - 09 end meganav assertion' | |
}, | |
{ | |
from: '01:06:05', | |
to: '01:10:46', | |
desc: '06 - 10 new snapshot test' | |
}, | |
{ | |
from: '01:11:56', | |
to: '01:13:47', | |
desc: '06 - 11 snapshot experiment' | |
}, | |
{ | |
from: '01:14:20', | |
to: '01:15:44', | |
desc: '07 - 01 CI intro' | |
}, | |
{ | |
from: '01:15:43', | |
to: '01:16:35', | |
desc: '07 - 02 start adding a workflow' | |
}, | |
{ | |
from: '01:16:34', | |
to: '01:18:37', | |
desc: '07 - 03 add cct' | |
}, | |
{ | |
from: '01:18:43', | |
to: '01:20:28', | |
desc: '07 - 04 check github actions' | |
}, | |
{ | |
from: '01:23:47', | |
to: '01:25:10', | |
desc: '07 - 05 fix cct command' | |
}, | |
{ | |
from: '01:25:13', | |
to: '01:26:16', | |
desc: '07 - 06 push updated command' | |
}, | |
{ | |
from: '01:26:58', | |
to: '01:27:42', | |
desc: '07 - 07 watch cypress work' | |
}, | |
{ | |
from: '01:28:20', | |
to: '01:30:07', | |
desc: 'q about wordpress' | |
}, | |
{ | |
from: '01:30:13', | |
to: '01:36:24', | |
desc: 'q about lighthouse' | |
}, | |
{ | |
from: '01:36:28', | |
to: '01:38:35', | |
desc: 'q about helmet' | |
}, | |
{ | |
from: '01:38:43', | |
to: '01:41:39', | |
desc: 'q about prioritization' | |
}, | |
] | |
// 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 | |
let editedVideo = await exec(`ffmpeg -i "${clipFileName}" -codec:v libx264 -crf 18 -filter_complex "[0:v]fade=type=in:duration=${fadeLength},fade=type=out:duration=${fadeLength}:start_time='${offset}'[v];[0:a]afade=type=in:duration=${fadeLength},afade=type=out:duration=${fadeLength}:start_time='${offset}'[a]" -map "[v]" -map "[a]" "${clipFileName}_fade.mp4"`) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment