#!/bin/bash # Version 0.3 # Package video-converter # Author Nikolay Nikolov # Copyright root.bg All rights reserved. # License GNU/GPL license: http://www.gnu.org/copyleft/gpl.html ############################# HELPER FUCTIONS [start] ############################# function install_deps { echo "" echo "Installing ffmpeg and its deps" echo "for ubuntu 14.04 users, use : sudo apt-add-repository ppa:samrog131/ppa, and then install ffmpeg-real and link ffmpeg to /usr/bin/ : sudo ln -sf /opt/ffmpeg/bin/ffmpeg /usr/bin/ffmpeg" sudo apt-get update sudo apt-get install libx264-dev libx264-142 libogg-dev libvorbis-dev libfaac-dev libtheora-dev libtheora0 faac ffmpeg -y mkdir $PWD/videoz } function convert_videos { echo "" echo "=== Starting ffmpeg to convert $1 to mp4,ogv and webm formats. ===" ffmpeg -i $1 -c:v libx264 -preset ultrafast videoz/$1.mp4 ffmpeg -i $1 -acodec libvorbis -ac 2 -ab 96k -ar 44100 videoz/$1.ogv ffmpeg -i $1 -acodec libvorbis -ac 2 -ab 96k -ar 44100 videoz/$1.webm echo "" echo "=== Now will create screenshot from the movie and will save it in videoz directory" ffmpeg -ss 00:00:15 -i videoz/$1.mp4 -vf scale=800:-1 -vframes 1 videoz/$1.jpg } ############################# HELPER FUCTIONS [end] ############################# ### Define actions ### case $1 in install) echo "" echo " ****************************************************" echo " * Installing required software *" echo " ****************************************************" install_deps echo " ****************************************************" echo " * Installing Complete *" echo " ****************************************************" echo "" ;; convert) echo "" echo " ****************************************************" echo " * Converting $2 *" echo " ****************************************************" convert_videos $2 echo " ****************************************************" echo " * Installation Complete *" echo " ****************************************************" echo "" ;; *) echo "" echo -e "\033[35;1m Please define an action: install | convert \033[0m" echo -e "\033[35;1m For example: ./video-converter.sh install \033[0m" echo "" ;; esac