[MEncoder-users] my first bash encoding script

ronnie escobedo tenminuteslater at hotmail.com
Sun Dec 12 00:17:33 CET 2004


This is my first attempt at scripting in linux.

I am currently using a number naming convention for all my avi files, ex: 
1.avi, 2.avi ,3.avi and etc.
part 1
My script allows me to select all the chapters I would like to encode and 
then they are automatically named.

I am encoding several chapters from several dvds and storing them to one 
directory. My current problem is that everytime I pop in a new dvd to encode 
the current files are replaced by the new files I am encoding.

part 2
So I would also like to have the script scan the directory where all the avi 
files are stored and select the highest current file and assign the number 
value to x. x will then increase by 1 and assigned as the file name ready 
for encoding.

My skills are limitted. I have been working on part 2 without success. Is 
there someone that can offer some assistance/tips/resources. Thanks!





#!/bin/bash

#initialize x to 0
x=0;

# input chapters to encode examples below
# for encoding chapter 1 use 1-1
# for chapters 2 through 3 use 2-3
for chapter in 2-2 4-4; do

# increments the value of x by 1
x=$(expr $x + 1)

# mencoder commands and options
mencoder -dvd-device /dev/hda dvd://1 -oac pcm -ovc lavc -lavcopts 
vcodec=mpeg4:vqscale=2:vhq:v4mv:trell:autoaspect -ofps 29.97 -vf 
crop=692:464:14:8,pp=fd -noskip -chapter $chapter -o 
/mnt/xdrive/video/$x.avi

# end of loop
done

# line break
echo ""

echo "encoding complete"

# line break
echo ""





More information about the MEncoder-users mailing list