User:Jedidiah

From MythTV Official Wiki
Jump to: navigation, search

MythTV user since September 2006.

Linux user since 1996.

Distros Used:

    Slackware
    Redhat
    Mandrake
    Debian
    Ubuntu

Unix user since 1989.

I have 3 backends and 3 frontends:

Frontends:

  nv9400 Mac Mini attached to an HDTV (columbia).
  i945 Mac Mini attached to an HDTV (riffraff)
  AppleTV attached to an HDTV (magenta)
Backends:

  Home Built Phenom X4 with and 1.5TB of disk (lars II) + HD-Homerun.
  i945 Mac Mini (frankie) + HD-PVR
  nv9400 Mac Mini (columbia] + HD-PVR.
  Home Built Quad Core with 6TB of disk (nomad).
Notes:

  My main desktop also serves as a frontend and fileserver for MythVideo (6TB). 

  Currently, none of my recording devices is located in the same room as the storage.
The HD HomeRun is located upstairs in order to optimize OTA antenna reception. The 
HD-PVRs and their associated STBs were centrally located in the home office but I
found the associated cable mess unmanageable. HD-PVRs and STBs now each sit underneath
a TV. The STBs are "wired in" to the TVs so that the STB can be reconfigured easily.

  Recording storage is not co-located in the same room as any of the recorders. 
 
  I have one SD unit and one HD unit. The SD unit uses and IR Blaster and the HD unit uses USB-serial control.

All machines run a recent version of trunk (for HD-PVR support).
Most of the machines run x86 Ubuntu 8.04 (qt4.4 support for trunk).
The master backend runs AMD64 Ubuntu 8.04
The box-full-of-disk desktop machine runs Ubuntu 9.04
The nv9400 mini runs Ubuntu 9.04


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