Add a fade in and fade out transitions to video file

Select a video file in Finder, hit the shortcut, and this script will create a copy of the file with fade in and fade out transitions.

Requires ffmpeg to be installed locally. Set fadeLength to a time in seconds of your choice.

Open fade-video-clip in Script Kit

// 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"`)