User:Jedidiah

From MythTV Official Wiki
Revision as of 03:06, 6 February 2009 by Jedidiah (talk | contribs)

Jump to: navigation, search

MythTV user since September 2006.

Linux user since 1996.

Distros Used:

    Slackware
    Redhat
    Mandrake
    Debian
    Ubuntu

Unix user since 1989.

My frontends include two old laptops that function more as control consoles than anything else.

My backend is an Athlon X2 3800+ with a PVR150 and 750G recording space. It runs Ubuntu 6.10 and is called lars.

My frontend is a Mac Mini. It runs Ubuntu 7.10 and is called frankie.


My DVD ripping script:

#!/bin/bash

#### Start of User modifiable script variables

INPUT="/dev/scd0"
INPUT="/dev/dvd"
RIPS=/home/media/DVD-RIP

#### End of User modifiable script variables

###############################################################
###############################################################
RIP_TYPE=$1
DNAME=$2


function _usage {
    echo " " 
    echo "Usage: $0 <rip_type> [disk_name]"
    echo "<rip_type> -> sitcom action film extras-only all"
    echo "sitcom        ->  30 minutes per title"
    echo "action        ->  60 minutes per title"
    echo "film          -> 120 minutes per title"
    echo "extras-only   ->   3 minutes per title"
    echo " " 
    echo "all -> Anything between 3 and 200 minutes"
    echo " " 
}
if [ "$RIP_TYPE" = "" ]; then
    _usage
    exit
fi

if [ -d $RIPS ]; then
    cd $RIPS
else
    echo " " 
    echo "RIPS directory [$RIPS] does not EXIST!"
    echo "Please reset RIPS variable in script."
    echo " " 
    exit
fi
###############################################################
###############################################################

###TYPE= sitcom,action,film,extras

###--- Control ripping based on expected size of shows ---###

case $RIP_TYPE in 
    "sitcom")
	EXPECTED_SIZE=30
	MIN=$(expr $EXPECTED_SIZE '/' 2 ) 
	MAX=$(expr $EXPECTED_SIZE '*' 2 )
	;;
    "action") 
	EXPECTED_SIZE=60
	MIN=$(expr $EXPECTED_SIZE '/' 2 ) 
	MAX=$(expr $EXPECTED_SIZE '*' 2 )
	;;
    "film") 
	EXPECTED_SIZE=120
	MIN=$(expr $EXPECTED_SIZE '/' 2 ) 
	MAX=$(expr $EXPECTED_SIZE '*' 2 )
	;;
    "all")
	MIN=3
	MAX=200
	;;
    "extras-only")
	MIN=3
	MAX=30
	;;
    *)
	_usage
	exit
	;;
esac
###--- Control ripping based on expected size of shows ---###

###########################################################

###------------- make sure there is a DVD in the drive ---###
flag=$( lsdvd 2>&1 | grep "Can't open disc" | wc -l )

if [ $flag -eq 1 ]; then
    eject
    echo "Disc Not Found!"
    echo "Please insert a DVD. And hit enter to continue."
    read button
fi

echo "Continuing..."

flag=$( lsdvd 2>&1 | grep "Can't open disc" | wc -l )

if [ $flag -eq 1 ]; then
    eject
    echo "Disc Not Found! Exiting"
    exit
fi
###------------- make sure there is a DVD in the drive ---###

echo "Getting DVD Title information..."
###------------------- Get the Title Details -------------###
NAME=$(lsdvd $INPUT | grep "Disc Title" | sed 's/.*: //g')
if [ "$DNAME" != "" ]; then
    NAME=$DNAME
fi
###------------------- Get the Title Details -------------###

echo "Disc Title is $NAME..."
###########################################################

###------------ Get title data --------------------------###
TITLES=$(lsdvd $INPUT 2> /dev/null \
    grep ':' | sed 's/Title: //g' | sed 's/, Length: /~/g' \
    | sed 's/.*Longest.*//g' \
    | sed 's/[.].*//g' | grep ':' \
    | sed 's/:[^:]*$//g')
###------------ Get title data --------------------------###



###--- Find Titles that meet our rip criteria -----------###
RIPME=""

for title in $TITLES; do
    
    time=$(echo $title | sed 's/.*~//g' )
    title=$(echo $title | sed 's/~.*//g' | sed 's/^0*//g' )

    hour=$(echo $time | sed 's/:.*//g' )
    minute=$(echo $time | sed 's/.*://g' )
    minutes=$( echo " $hour * 60 + $minute " | bc )
    

    if [ $minutes -ge $MIN ]; then
	if [ $minutes -le $MAX ]; then
	    echo "Title $title should be ripped!"
	    RIPME="$RIPME $title"
	else
	    echo "Title $title is too big!"
	fi
    else
	echo "Title $title is too small!"
    fi
done
###--- Find Titles that meet our rip criteria -----------###



###------------------ Rip the matching Titles -----------###
echo $RIPME
for title in $RIPME; do    
    echo "mplayer -dumpstream dvd://$title -dumpfile $NAME.$title-1.vob" 
    nice mplayer -dumpstream dvd://$title -dumpfile $NAME.$title-1.vob
    
done
###------------------ Rip the matching Titles -----------###

eject

eject


My bulk/batch transcoding script for compressing DVDs:

Just execute this and all of the VOB files in your current working directory will be converted to h264 AVI files with the original english audio track from the VOB.

#!/bin/bash


if [ "$1" != "" ]; then
    FROM="$1"
else
    FROM=$( ls *vob )
fi

CROP_ME="TRUE"
CROP_ME="FALSE"

cp /dev/null convert.log

#####################################################################
###---------------------------------------------------------------###


###--- xvid defaults

OPTIONS="-xvidencopts bitrate=800"
MAIN_OPTS="-ovc xvid -oac mp3lame -alang en -slang en"


###--- h.264 high quality


BITRATE=800
BITRATE=1200
BITRATE=1500

### subq=6:partitions=all:8x8dct:me=umh:frameref=5:bframes=3:b_pyramid:weight_b
### subq=5:8x8dct:frameref=2:bframes=3:b_pyramid:weight_b
### subq=4:bframes=2:b_pyramid:weight_b

###OPTIONS="-x264encopts subq=6:4x4mv:8x8dct:me=3:frameref=5:bframes=3:b_pyramid:weight_b:bitrate=$BITRATE "


### h264 High Quality options, 2 pass
### This is the default setting
X264_PASS1="-ovc x264 -x264encopts subq=4:bframes=4:b_pyramid:weight_b:pass=1:psnr:bitrate=$BITRATE:turbo=1"
X264_PASS2="-ovc x264 -x264encopts subq=5:partitions=4x4:8x8dct:frameref=3:me=hex:bframes=4:b_pyramid:pass=2:psnr:bitrate=$BITRATE" 

### h264 basic options, 1 pass
### This is for problem content like Forever Knight
#X264_PASS1=""
#X264_PASS2="-ovc x264 -x264encopts bitrate=$BITRATE" 
##X264_PASS2="-ovc x264 " 


CROP_OPTS=" -vf crop=720:360 -lavcopts aspect=16/9"

LANG="-alang en -slang en -aid 128"

MP3_AMP=":vol=8"
MP3_AMP=":vol=6"
MP3_AMP=""

MP3_OPTS="-oac mp3lame -lameopts br=128${MP3_AMP}"
MP3_OPTS="-oac copy"


OPTIONS=""

###---------------------------------------------------------------###
#####################################################################



for from in $FROM; do
    echo "Converting $from..."

    flag=$(file $from | sed 's/.*: //g' | grep ^MPEG | wc -l)
    if [ $flag -eq 1 ]; then

	####---- Create the destination filename ----####
	to=$( echo $from | sed 's/[.]vob$/.avi/g' )


	#########################################################
        ###---------------------------------------------------###
	flag=$(echo "$EXCLUDE" | tr ' ' '\n' | grep $from | wc -l  )
	exclude=0
        ###---------------------------------------------------###
	if [ $flag -gt 0 ]; then
	    echo "$to"
	    echo "Source File on Exclusion List! Skipping..."
	    exclude=1
	fi
        ###---------------------------------------------------###
	if [ -f $to ]; then
	    echo "$to"
	    echo "Destination file already exists! Skipping..."
	    exclude=1
	fi
	if [ -f x264/$to ]; then
	    echo "x264/$to"
	    echo "Destination file already exists! Skipping..."
	    exclude=1
	fi
        ###---------------------------------------------------###
	#########################################################


     
	######################################################################
	###--- Determine if this is a letterboxed video by the filename ---###
	flag=$(echo "$from" | grep 'LB.vob' | wc -l )
	echo "<crop_flag> $flag"
	if [ $flag -eq 1 ]; then
	    CROP=" -vf crop=720:360 -lavcopts aspect=16/9"
	    OPTIONS="$CROP"
	else
	    OPTIONS=""
	    CROP=""
	fi
	###--- Determine if this is a letterboxed video by the filename ---###
	######################################################################



	#####################################################################
        ###------------- Make sure we haven't converted it already -------###
	if [ $exclude -eq 0 ]; then
	    echo "Converting $to..."

	    basename=$(echo $from | sed 's/[.].*$//g' )

	    if [ "$X264_PASS1" != "" ]; then
       	        ###--- Pass #1 
		nice -20 mencoder -v $from $X264_PASS1 $OPTIONS \
		    -oac copy $LANG \
		    -o /dev/null
		    ## -vobsubout $basename -vobsuboutindex 0 \
	     fi

	     ###--- Pass #2
             nice -20 mencoder -v $from $LANG \
		$MP3_OPTS $X264_PASS2 $OPTIONS \
		-o $to

	fi

     else
         echo "$from is NOT an MPEG file! Skipping..." | tee -a convert.log
     fi

done

exit


	 nice -20 mencoder $from -o $to -oac mp3lame -ovc lavc \
	     -lavcopts vcodec=xvid:vpass=1:vbitrate=${BITRATE} $CROP
	 nice -20 mencoder $from -o $to -oac mp3lame -ovc lavc \
	     -lavcopts vcodec=xvid:vpass=2:vbitrate=${BITRATE} $CROP