Bash Scripts with Arguments

Make your Mac great again. With full example code!

Photo by Stanislav Kondratiev on Unsplash

Prerequisites:

Terminology

Justification

A little help…

Prework: Installing ffmpeg

Implementing your bash script

Creating the bash script

Add the shebang line

#!/usr/bin/env bash

Add the script

INPUT=${1?Error: no input filename given}
OUTPUT=${2?Error: no output.gif filename given}
FRAMESIZE=${3:-1200x720}

ffmpeg -i $INPUT -s $FRAMESIZE -pix_fmt rgb24 -r 10 -f gif - | gifsicle --optimize=3 --delay=10 > $OUTPUT
echo "FFMPEG script has been run"

Update the script to have a help function (optional)

Syntax: ffmpegscript input.mov output.gif FrameSizeWxH

Save the script

Make the script executable

Run the script

Make the script Globally available

:wq

Making further edits

The full script:

Conclusion:

The Twitter contact:

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store