MLUG Bash Scripting Workshop 25/04/08 | ||
---|---|---|
Prev | Index | Next |
I have made up a very basic script using a shebang and the mencoder command. I could call it whatever I liked as long as the name is not the same as any executable in any of my paths.
I have named it contovob (convert to vob).
#!/bin/bash # /usr/local/contovob rm20080414 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.mpg] -o [output.mpg] #end of script
As you can see, the second line is a comment. You don't have to put in any comments. I do. This one provides the path and name I will use for this script. I could leave it in my home directory but I prefer to put my scripts in /usr/local/bin. I can give it any name I like but being that /usr/local/bin is in my $PATH I have to make sure that there are no other executables on this system with the name "contovob".
The command is a one liner but here it has been broken into four lines by using the backward slash " \ " after whitespace breaks in the command. The third line runs off the page because there's no white space for awile. I did not have to break the command down over four lines it just makes it easier for me to read the script
The comment "end of script" is not required. I usually put it in just for the sake of good order.
This script will fly as is but it could be improved. In the fourth line of the command there are two variables required by this script, [input.mpg] and [output.mpg]. Every time I want to encode a movie I would have to open this script up and manually edit in the name of the video file I am converting from and the name I want it to have once it is encoded.
If I could pass these two variables to contovob when I ran the command life would be much easier. What I want to do is run the command like this: "contovob [input.mpg] [output.mpg]".