import "@johnlindquist/kit"
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"`)