[MPlayer-dev-eng] [script] dvd_extract
A Mennucc1
debdev at Tonelli.sns.it
Mon Mar 31 15:21:15 CEST 2003
hi everybody
I have written a short shell script that implements the tips
in http://mplayerhq.hu/DOCS/encoding.html
you may wish to add it in the TOOLS in the distribution
(it can be useful to newbies)
a.
ps:
my previous e-mail was messy, sorry.
I will post a correct e-mail for the -vm bug
On Tue, Mar 25, 2003 at 09:09:54PM +0100, Arpi wrote:
> Hi,
>
> > I see two bugs in the -vm implementatio
>
> > 1)
> > I have ripped the DVD of Lord Of the rings
> > (that I own :-) )
>
> 1)
> this is not mplayer-users list
> do not send (incomplete, useless) bugreports here
>
> > 2) sometimes mplayer crashes after it changes videomode
>
> 2)
> RTFM docs/bugreports.html
>
> 3)
> Since developers don't have that dvd, either send it to us, or
> upload sample file, the script using to rip it is not enough...
>
> 4)
> never cut mplayer log
>
>
> A'rpi / Astral & ESP-team
>
--
Andrea Mennucc
"E' un mondo difficile. Che vita intensa!" (Tonino Carotone)
-------------- next part --------------
#!/bin/bash -e
## dvd_extract : a front end for mencoder to rip DVDs at best
## based on http://mplayerhq.hu/DOCS/encoding.html
# Copyright A. Mennucc1 Mar 2003
# Licenxe: GPL
#Usage: edit these variables at taste but do not put spaces
# call as dvd_extract movie_name
VOP=''
## if the video is interlaced, uncomment
#VOP='pp=lb'
LANG=en
DVD='-dvd 1 -alang '$LANG' -dvd-device /dev/cdrom -cache 8192'
A='-oac mp3lame -lameopts preset=128'
LAVC='vhq:vqmin=2:vlelim=-4:vcelim=9:lumi_mask=0.05:dark_mask=0.01'
V='-ovc lavc -lavcopts vcodec=mpeg4'
SUB=''
##uncomment for subtitles
#SUB=" -slang $LANG -vobsubout $B -vobsuboutindex 0"
#this is the fallback if not autodetected
# it is also a max to the autodetected one
BITRATE=1100
#megabytes of the CD: must be on ofe 650 700 or 800
MB=700
#percent used in the CD: to allow some space for subtitles
CDPC=97
#autodetect CROP
CROP=''
#CROP="crop=w:h:x:y"
#autodetect aspect
ASPECT=''
#ASPECT='2.418'
#########################
[ "$B" ] || { echo provide file name, without .avi extension ; exit ; }
[ "$TIMING_DVD_EXTRACT" ] || { [ -x /usr/bin/time ] && \
{ TIMING_DVD_EXTRACT=yes /usr/bin/time $0 "$@" ; exit ; } ; }
B="$1"
shift
mkdir ${B}_tmp || { echo -e \\a ============ REUSING DIR ; sleep 3 ; }
cd ${B}_tmp
if [ "$CROP" == "" -o "$ASPECT" = "" ] && [ ! -r cropping.log ] ; then
echo ============= CHECKIN CROPPING AND/OR ASPECT
mplayer -quiet -ss 800 -frames 800 -vo null -ao null \
-vop cropdetect $DVD > cropping.log
fi
if [ "$CROP" == "" ] ; then
CROP=$( sed 's/.*-vop //;s/).*//' cropping.log | grep crop | tail -1 )
echo ============= CROPPING to $CROP
fi
if [ "$ASPECT" = "" ] ; then
ASPECT=$(grep 'Movie-Aspect is ' cropping.log | \
sed 's/Movie-Aspect is //;s/:.*//' )
echo ============ ASPECT $ASPECT
fi
if [ "$ASPECT" -a "$CROP" ] ; then
ASPECT=$( echo $CROP | cut -d= -f2 |\
awk 'BEGIN{FS=":"};{print $1 / 720 / ( $2 / 576 ) * '"$ASPECT"'}' )
echo ============ ASPECT $ASPECT after crop
fi
M="mencoder $DVD $@"
if [ -r frameno.avi ] ; then
echo -e \\a ============= REUSING frameno ; sleep 3
else
echo ==================== AUDIO PASS
trap 'rm frameno.avi' 0
$M $SUB -ovc frameno $A -o frameno.avi | tee audioenc.log || rm frameno.avi
trap '' 0
fi
b=$( grep 'Recommended video bitrate for '"$MB"'MB CD:' audioenc.log | cut -d: -f2 )
if [ "$b" ] ; then
b=$( expr $b \* $CDPC / 100 )
if [ $b -gt $BITRATE ] ; then
echo ==============BITRATE FORCED FROM $b to $BITRATE
b=$BITRATE
else
echo ==============BITRATE $b
fi
else
b=$BITRATE
[ "$b" ] || echo -n 'BITRATE ? ' ; read b
fi
ASP=''
[ "$ASPECT" ] && ASP='aspect='$ASPECT
if [ -r divx2pass.log ] ; then
echo =============== REUSING divx2pass.log
else
echo ==================== VIDEO PASS 1
trap 'rm divx2pass.log' 0
$M ${V}:$LAVC:$ASP:vpass=1:vbitrate=$b -vop $CROP:$VOP \
-oac copy -o $B.avi | tee videoenc1.log || rm divx2pass.log
fi
echo ==================== VIDEO PASS 2
trap '' 0
$M ${V}:$LAVC:$ASP:vpass=2:vbitrate=$b -vop $CROP:$VOP \
-oac copy -o $B.avi | tee videoenc2.log
mv -v --backup=numbered $B* ..
exit
#echo -n 'which bitrate? ' ; read b
########################
#rm frameno.avi subtitles.idx subtitles.sub divx2pass.log test.avi || true
# -vop cropdetect
#[ -r frameno.avi ] || \
# $M -ovc frameno -oac mp3lame -lameopts vbr=3 -o frameno.avi
#$M -oac copy -ovc divx4 -divx4opts pass=1
#$M -oac copy -ovc divx4 -divx4opts pass=2 -vobsubout subtitles -vobsuboutindex 1 -sid 5
#-vobsubout subtitles -vobsuboutindex 0 -sid 2 -o frameno.avi -ovc frameno -oac mp3lame -lameopts vbr=3 -ovc lavc -lavcopts vcodec=mpeg4:aspect=16.0/9.0
More information about the MPlayer-dev-eng
mailing list