Site hosted by Angelfire.com: Build your free website today!

Tiny scripts for MPlayer users


If you are a user of the feature rich Linux/Unix movie player mplayer and its encoder mate, mencoder, you may find these scripts useful.
(Btw., to download and further info, click here !)

Scripts

These bash scripts are written for Linux. Feel free to modify them to your needs :) Find the comments about usage in the script files.

bppcalc

Bit-per-pixel (bpp) calculator for movie files. As you can see in the mplayer documentation about encoding tips, the bpp value should be in the range 0.2-0.3. Using this utility, you can check if the bpp value is too high in which case the movie may be worth transcoding to a lower bpp value, see the next utility, mencode2pass.
The bpp is defined as follows:
                 bitrate [bit/s]
bpp = -------------------- [bit/pixel]
height * width * fps
where fps is the frames/s value, and the height and width are the image dimensions in pixel. bppcalc's output helps to determine these:

ID_FILENAME=telefon.mpg
ID_VIDEO_FORMAT=0x10000001
ID_VIDEO_BITRATE=500000
ID_VIDEO_WIDTH=320
ID_VIDEO_WIDTH=320
ID_VIDEO_HEIGHT=240
ID_VIDEO_FPS=29.970
ID_VIDEO_ASPECT=1.3333
ID_AUDIO_CODEC=mp3
ID_AUDIO_FORMAT=80
ID_AUDIO_BITRATE=96000
ID_AUDIO_RATE=44100
ID_AUDIO_NCH=2
ID_LENGTH=50
bpp = 0.217231

As you can see, bppcalc is actually useful for giving ID info about the file.
Note: some movie files don't have the above parameters encoded in their header. In that case, mplayer cannot determine the parameters in advance and you will see 0 values in some (or all) ID rows.

mencode2pass

2 pass DivX transcoder script. Can be used to a produce DivX encoded .avi file from a movie file. You can specify the bitrate of the output file (in kbit/s), wanted width for X scaling, and optional rotation with +/- 90 degrees.
When to use mencode2pass ? Well, in these cases:
  1. If you have a movie file in another format (e.g. .mpg) and you prefer DivX format;
  2. If your movie file (of any format) has too high bpp value. In that case you can calculate the new bitrate so that the bpp value will change linearly with the new bitrate value, see the bpp formula above.
  3. If you want to save space by scaling down your movie file, maintaining its original bpp value and aspect ratio. In that case the new bitrate for the same bpp value will decrease with the square of the scaling factor, so scaling to half width + height results in a bpp decrease by a factor of four.
When encoding from DVD, you can select some chapters via grouping the DVD track number and the chapter range into the 1st argument of the script using quotation marks:

mencode2pass "dvd://1 -chapter 1-20" 1800 outputfile.avi

mp3audio

This script replaces the audio track of a movie file with an mp3 encoded one. The output filename is "mp3-" prepended to the input filename.
In the script I used the Blade encoder (bladeenc) to do the wav --> mp3 conversion; modify to use your own favorit tool.

About...

If you have any comment, issue, another handy mplayer script, please drop a mail to