#!/bin/bash
#Author: Surendra Anne(surendra@linuxnix.com)
#Purpose: To convert any video file into a GIF image file. The script will take one video file from command line arguments and do the conversion using mplayer and convert. So please install these two software’s before running this script.
#Licence: GPL v.3
[[ “$#” -ne 1 ]] && { echo -e “Script should be run as belown bash $0 video-filen Exiting the script..!”;exit 1; }
mkdir /tmp/images/
mplayer -ao null $1 -vo jpeg:outdir=/tmp/images/
convert /tmp/images/* /tmp/abc.gif
convert /tmp/abc.gif -fuzz 10% -layers Optimize /home/surendra/Desktop/opt-gif.gif
rm -rf /tmp/{abc.gif images/}
First line in the script will check if a file is passed to script or not, if not it will through some meaningful error message to user.
mplayer command will convert video file into jpeg images and the first convert command will club these image files to single animated gif file. The second convert command will compress the gif file considerably to 10% of actual size. And the file will be stored on desktop. You may have to change the locations to suite your requirements.
Latest posts by Surendra Anne (see all)
- Docker: How to copy files to/from docker container - June 30, 2020
- Anisble: ERROR! unexpected parameter type in action:
Fix - June 29, 2020 - FREE: JOIN OUR DEVOPS TELEGRAM GROUPS - August 2, 2019
- Review: Whizlabs Practice Tests for AWS Certified Solutions Architect Professional (CSAP) - August 27, 2018
- How to use ohai/chef-shell to get node attributes - July 19, 2018