To create a context menu action in the Mac Finder to convert a .mov video using ffmpeg via the command line, you can use the Automator app. Here are the steps: You need to install ffmpeg and gifsicle
brew install ffmpeg
brew install gifsicle
- In the mac spotlight open Automator.app and create a new "Quick Action"
- In the search bar, look for "Run Shell Script" and drag it to the right pane.
- In the "Service receives selected" dropdown, select "files or folders"
- In the "Pass input" dropdown, select "as arguments"
- Copy paste this script in the script section
- Save the service with a desired name
original_file_path="$1"
original_file_directory=$(dirname "$original_file_path")
/usr/local/bin/ffmpeg -y -i "$original_file_path" -pix_fmt rgb8 -r 5 "$original_file_directory/$(basename "$original_file_path" .mov).gif"
if /usr/local/bin/gifsicle -O3 "$original_file_directory/$(basename "$original_file_path" .mov).gif" -o "$original_file_directory/$(basename "$original_file_path" .mov).gif"; then osascript -e 'display notification "File: '"$(basename "$output_file")"' has been converted optimized" with title "Conversion"'
else
if /usr/local/bin/gifsicle --unoptimize "$original_file_directory/$(basename "$original_file_path" .mov).gif" -o "$original_file_directory/$(basename "$original_file_path" .mov).gif"; then osascript -e 'display notification "File: '"$(basename "$output_file")"' has been converted unoptimized" with title "Conversion"'
else
osascript -e 'display notification "File: '"$(basename "$output_file")"' convertion ERROR retry later" with title "Conversion"'
fi
fi
- Right click on a .mov file in Finder, you should see the new service in the context menu.