MLUG Bash Scripting Workshop 25/04/08
Prev Index Next

My final contovob script

If I am writing a new script, I usually put in lots of comments so I can understand what I'm doing as I go along. I am often pushing my boundaries and comments help me to remember but once I understand I take out most of the comments unless they will be of benifit to someone else who might use the script.

I have put my working copy of contovob below for you to have a look at. You can also find it here. I believe that anyone who has stuck with this from the beginning will understand this script by reading it.

Well you might not understand the mencoder command but neither do I. That's why I wrote this script in the first place.

Next I'm going to show you a script I use to autmatically shutdown a server.


#!/bin/bash
############################################################
# /usr/local/contovob (convert to vob) rm20060611
#
# I use this file to prepare mpeg-ps files for burning to a
# video dvd that can be played on any old set top dvd player.
# Th resulting video will be mpeg-ps and audio wil be ac3 
# a.k.a a52.
#
# I am normally converting mpeg-ps files that have been edited
# in Gopdit and saved with the following postprocessing command:
#
#   mencoder -of mpeg -mpegopts format=dvd:vbitrate=9000 \
#   -o "%s" -oac copy -ovc copy - &> /dev/null
#
# Working with videos saved with my DVB-T cards that have
# been edited and post processed via gopdit, this script
# script will improve video quality, convert the mp3 audio 
# to ac3 (mp3's won't work on most set top dvd players and  
# quite possibly reduce the size of the resulting file.
#
# I've also found that while I may have trouble with audio/video
# sync after resizing my video file using tcextract and replex,
# I usually don't experience that problem working with a file 
# that has first been processed with this script.
#
# You will have to have mplayer installed to have mencoder
# available. There may be other libraries and programs required
# by mencoder to do this job. You will have to watch standard out
# for dependency errors. I don't know what you have installed on
# your box but I know this works on mine.
#
############################################################

INPUT_FILE=$1
OUTPUT_FILE=$2

test -n "$INPUT_FILE"
  if [ $? -eq 1 ]; then
    echo -e "\nUsage: contovob [input file] [output file]\n"
    exit
  fi

test -n "$OUTPUT_FILE"
  if [ $? -eq 1 ]; then
  echo -e "\nUsage: contovob [input file] [output file]\n"
  exit
  fi


mencoder -oac lavc -ovc lavc -of mpeg -mpegopts format=dvd \
-vf scale=720:576,harddup -srate 48000 -lavcopts \
vcodec=mpeg2video:vrc_buf_size=1835:vrc_maxrate=9800:vbitrate=5000:keyint=15:acodec=ac3:abitrate=192:aspect=16/9 \
-ofps 25 $INPUT_FILE -o $OUTPUT_FILE

#end of script


Top