Created
January 13, 2022 20:04
-
-
Save tayiorbeii/fa819ecebd26f2fa9f177af4c4fba329 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
// 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