#!/bin/bash [ "$#" -lt 1 ] && exec echo -e "usage: $0 [input device|input iso|input dir] [title] [chapter]\n\texample: $0 myfilm.mp4 /dev/hdc 2 3" clean_tmp(){ [ -z "$KEEPTEMP" ] && rm -f /tmp/*$$* exit 0 } X264='partitions=all:frameref=3:me=umh:qcomp=1:subq=6:me_range=32:mixed_refs:trellis=2:level_idc=13:crf=24' DEV=/dev/sr0 TITILE=1 CHAPTER=1 [ -z "$DEBUG" ] && MSG='-msglevel all=0:avsync=5' [ "$#" -ge 2 ] && DEV="$2" [ "$#" -ge 3 ] && TITLE="$3" [ "$#" -ge 4 ] && CHAPTER="$4" trap clean_tmp SIGINT trap clean_tmp SIGQUIT trap clean_tmp SIGKILL echo -e "\e[32mDetecting crop area...\e[39;49m" CROP=$(mplayer -dvd-device "$DEV" -alang it dvd://$TITLE -chapter "$CHAPTER" -vo null -ac null -vf cropdetect -frames 1000 -fps 500 2>/dev/null |grep '[CROP]' |tail -n 1 |cut -d '(' -f 2 | cut -d ')' -f 1) echo -e "\e[32mRipping and encoding...\e[39;49m" mencoder -dvd-device "$DEV" -alang it -cache 16384 "dvd://$TITLE" -chapter "$CHAPTER" $CROP,scale=368:-10,harddup -ovc x264 -x264encopts $X264 -oac copy -o /tmp/dvd.$$.avi $MSG || clean_tmp [ -b "$DEV" ] && eject "$DEV" echo -e "\e[32mExtracting encoded video...\e[39;49m" mencoder /tmp/dvd.$$.avi -o /tmp/video.$$.264 -nosound -ovc copy -of rawvideo $MSG || clean_tmp echo -e "\e[32mExtracting Audio...\e[39;49m" mplayer /tmp/dvd.$$.avi -vc null -vo null -ao pcm:fast:file=/tmp/audio.$$.wav -af lavcresample=44100 $MSG || clean_tmp rm /tmp/dvd.$$.avi echo -e "\e[32mNormalizing Audio...\e[39;49m" normalize-audio --peak /tmp/audio.$$.wav || clean_tmp mplayer /tmp/audio.$$.wav -ao pcm:fast:file=/tmp/audio2.$$.wav || clean_tmp mv /tmp/audio2.$$.wav /tmp/audio.$$.wav echo -e "\e[32mEncoding Audio...\e[39;49m" neroaacenc -lc -q 0.15 -if /tmp/audio.$$.wav -of /tmp/audio.$$.mp4 || clean_tmp rm /tmp/audio.$$.wav MP4Box -raw 1 /tmp/audio.$$.mp4 mv /tmp/audio.$$_track1.aac /tmp/audio.$$.aac echo -e "\e[32mPutting all together\e[39;49m" MP4Box -new -add /tmp/video.$$.264 -add /tmp/audio.$$.aac "$1" || clean_tmp clean_tmp