Convert your avi files (if any) into the free matroska format


This post is a follow up on:
Conversions.

I am bit of on a deadline now! So come back later for a more detailed explanation.

#!/bin/bash
# Modified: Today by E.l.f
#
## This program is free software; you can redistribute it and/or modify it under
## the terms of the GNU General Public License as published by the Free Software
## Foundation; either version 2 of the License, or (at your option) any later
## version.
#
## This program is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
## FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
## details.
#
## You should have received a copy of the GNU General Public License along with
## this program; if not, write to the Free Software Foundation, Inc., 51
## Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
## http://www.gnu.org/copyleft/gpl.html
#
## Script-name - avi2mkv.sh
#
## Source (inspired on): http://ffmpeg.org/ffmpeg-doc.html
## And: http://ubuntuforums.org/showthread.php?t=1037517
## If colors are not defined in .bashrc, then uncomment the next three lines.
#YELLOW="33[1;33m"
#RED="33[0;31m"
#ENDCOLOR="33[0m"
## Root check / Sanity check.  You decide.  >-)
## Just in case someone calls this script with sudo -s,
## or has cd'ed into his/her path.
if [ $USER = root ]; then
  echo -e $RED"Are you Insane!"
  echo -e $RED"Error: In order to use this script, one must NOT be $USER"
  echo -e $YELLOW"Exiting..."$ENDCOLOR
  exit 0
else
  echo ""
  echo "$USER may proceed."  
  echo "May peace be with you."  
fi
ls *.avi
echo -n "Enter filename: "
read INPUT
INPUT=$INPUT
if [ ! -f $INPUT ]; then
  echo ""
  echo -e $RED"Error: File doesn't exist!"
  echo -e $YELLOW"Exiting..."$ENDCOLOR
  echo ""
  exit 0
fi
OUTPUT=${INPUT%.*i}
TITLE=${INPUT%.*i}
OUTPUT+=".mkv"
# These were the options I saw mkvmerge pass on multiple occasions when I was looking at its cli output.
OPTIONS=$(echo "--forced-track 0:no --forced-track 1:no -a 1 -d 0 -S -T --no-global-tags --no-chapters --track-order 0:0,0:1")
mkvmerge -o $OUTPUT $OPTIONS $INPUT
exit 0
# find -iname '*.ext' -exec someScript "{}" \;
# Depends on sudo apt-get install libdvdcss2 k9copy ffmpeg2theora mkvtoolnix-gui avidemux mencoder ffmpeg

PS: These new posts of mine will be in line with the notes I post on facebook.com. 😉 Though the formatting won’t be garbled this time. *Say demoronize* >-)

One thought on “Convert your avi files (if any) into the free matroska format

  1. Pingback: Batch processing by means of using any script of your choosing. « Bohemian Wildebeest's Blog

Comments are closed.