Skip to content

Instantly share code, notes, and snippets.

@jmarhee
Created March 26, 2021 07:52
Show Gist options
  • Save jmarhee/6e90d7ff4742a1acb17894ca43b2fd52 to your computer and use it in GitHub Desktop.
Save jmarhee/6e90d7ff4742a1acb17894ca43b2fd52 to your computer and use it in GitHub Desktop.
Overlays all videos in a directory on top of each other.
#!/bin/bash
i=0
while read line
do
array[ $i ]="$line"
(( i++ ))
done < <(ls)
# Creates the base overlay.mkv file
ffmpeg -i "${array[0]}" -i "${array[1]}" \
-filter_complex "[1:v]setpts=PTS-10/TB[a]; \
[0:v][a]overlay=enable=gte(t\,0):shortest=1[out]" \
-map [out] -map 0:a \
-c:v libx264 -crf 18 -pix_fmt yuv420p \
-c:a copy \
~/overlay.mkv
# Overlays the
for i in "${#array[@]}"; do \
ffmpeg -i "${i}" -i ~/overlay.mkv \
-filter_complex "[1:v]setpts=PTS-10/TB[a]; \
[0:v][a]overlay=enable=gte(t\,0):shortest=1[out]" \
-map [out] -map 0:a \
-c:v libx264 -crf 18 -pix_fmt yuv420p \
-c:a copy \
~/overlay.mkv
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment