Created
January 15, 2024 19:14
-
-
Save nithinbekal/b58260c342b92d9b62615a2ccb1e926b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#! /usr/bin/bash | |
frame_rate=2 | |
# Process command line options | |
while getopts "r:" opt; do | |
case $opt in | |
r) frame_rate=$OPTARG ;; | |
\?) echo "Usage: $0 [-r frame_rate] input_file output_file"; exit 1 ;; | |
esac | |
done | |
# Remove processed options from arguments | |
shift "$((OPTIND-1))" | |
if [ "$#" -lt 1 ]; then | |
echo "Usage: $0 [-r frame_rate] input_file output_file" | |
exit 1 | |
fi | |
input_file="$1" | |
if [ "$#" -eq 2 ]; then | |
output_file="$2" | |
else | |
output_file="final.jpg" | |
fi | |
mkdir -p frames | |
mkdir -p aligned | |
rm frames/* | |
rm aligned/* | |
ffmpeg -i "$input_file" -r "$frame_rate" frames/%04d.png | |
/Applications/Hugin/tools_mac/align_image_stack frames/*.png -a aligned/a -v | |
convert aligned/*.tif -average "$output_file" | |
open "$output_file" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment