Skip to content

Instantly share code, notes, and snippets.

@tayiorbeii
Created January 13, 2022 20:04
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/4cfa685f68a306a3ea0c036a06999bff to your computer and use it in GitHub Desktop.
Save tayiorbeii/4cfa685f68a306a3ea0c036a06999bff to your computer and use it in GitHub Desktop.
// shortcut: opt+9
import "@johnlindquist/kit"
// Name: fade-video-clip
let fadeLength = 1.25
let videoFile = await getSelectedFile()
let basePath = await path.basename(videoFile)
let { stdout } = await exec(`ffprobe -loglevel error -show_entries format=duration -of default=nk=1:nw=1 "${videoFile}"`)
let totalDuration = stdout
let offset = totalDuration - fadeLength
let editedVideo = await exec(`ffmpeg -i "${videoFile}" -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]" "${videoFile}_fade.mp4"`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment