Skip to content

Instantly share code, notes, and snippets.

@victoriagrace
victoriagrace / crossfadevideo.sh
Last active December 21, 2020 21:53 — forked from coderofsalvation/crossfadevideo.sh
ffmpeg commandline crossfade-looped video
#!/bin/bash
[[ ! -n $3 ]] && { echo "Usage: crossfadevideo <input.mp4> <fade in seconds> <output.mp4>"; exit; }
input="$1"
fade="$2"
duration="$(ffprobe -v error -select_streams v:0 -show_entries stream=duration -of default=noprint_wrappers=1:nokey=1 $1 )"
duration="$(echo "$duration-($fade)" | bc)"
[[ ${duration:0:1} == "." ]] && duration="0$duration"
output="$3"
set -x
ffmpeg -i "$input" -filter_complex '