#!/bin/bash # # mplayer encoding script # # Eric Thern # January 21, 2003 # # # mencoder script to encode a two part VCD/SVCD style movie into # a single divx file, with mp3 audio & in fullscreen mode # # Prerequisites: # # all movies should be named like this: # 'somemovie-part1.mpg' and 'somemovie-part2.mpg' # this two part naming scheme gets piped into mencoder, # and it will automatically create a single .avi file from it. # cropdetect runs and takes out the blackspace on top and bottom, # which allows you to have, in the end, a full-screen movie # which (IMHO) is the best way to watch movies on a computer screen. # # You need to have mplayer/mencoder installed, and libmp3lame # you could use ogg/vorbis instead of mp3lame, in fact that would be neat. do it. # # # Example: # here is what your directory looks like (names selected randomly): # #-rw-rw-r-- 1 mplayer mplayer 833277172 Dec 25 22:22 some.lame.movie-part1.mpg #-rw-rw-r-- 1 mplayer mplayer 833307384 Dec 25 22:22 some.lame.movie-part2.mpg #-rw-rw-r-- 1 mplayer mplayer 833260904 Dec 25 22:22 another.lame.movie-part1.mpg #-rw-rw-r-- 1 mplayer mplayer 833325976 Dec 25 22:22 another.lame.movie-part2.mpg #-rw-rw-r-- 1 mplayer mplayer 825826428 Dec 25 22:22 another.lame.movie-part3.mpg # # You run this script: # $./mencoder-script # # it runs, and you end up with all of the above, plus the following: # #-rw-rw-r-- 1 mplayer mplayer 700200100 Dec 26 01:01 some.lame.movie.avi #-rw-rw-r-- 1 mplayer mplayer 700200100 Dec 26 02:02 another.lame.movie.avi # # (or something similar) # for i in `ls -1 | grep mpg | awk -F"-part" '{print $1}' | uniq `; do rm -f frameno.avi rm -f cropdetect mplayer -ao null -vo null -vop cropdetect -ss 100 $i-part1.mpg > cropdetect & sleep 5 killall -9 mplayer sleep 5 CROP=`tail -2 cropdetect | head -1 | awk -F"(" '{print $2}' | awk -F")" '{print $1}'` #cat $i* | mencoder -o "$i".avi -ovc lavc -lavcopts vcodec=mpeg4:vhq:vbitrate=1800 $CROP -oac mp3lame -lameopts vbr=3 - nice -n 19 cat $i* | mencoder -ovc frameno -o frameno.avi $CROP -oac mp3lame -lameopts vbr=3 - nice -n 19 cat $i* | mencoder -ovc lavc -lavcopts vcodec=mpeg4:vpass=1 $CROP -oac copy -o /dev/null - nice -n 19 cat $i* | mencoder -ovc lavc -lavcopts vcodec=mpeg4:vpass=2 $CROP -oac copy -o "$i".avi - rm -f cropdetect done