All pastes #269246 Raw Edit

Anonymous

public shellscript v1 · immutable
·published 2006-12-06 12:27 UTC
rendered paste body
#!/bin/bash[ "$#" -lt 1 ] && exec echo -e "usage: $0 <filmname.mp4> [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/sr0TITILE=1CHAPTER=1[ -z "$DEBUG" ] && MSG='-msglevel all=0:avsync=5'[ "$#" -ge 2 ] && DEV="$2"[ "$#" -ge 3 ] && TITLE="$3"[ "$#" -ge 4 ] && CHAPTER="$4"trap clean_tmp SIGINTtrap clean_tmp SIGQUITtrap clean_tmp SIGKILLecho -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_tmpecho -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_tmprm /tmp/dvd.$$.aviecho -e "\e[32mNormalizing Audio...\e[39;49m"normalize-audio --peak /tmp/audio.$$.wav || clean_tmpmplayer /tmp/audio.$$.wav -ao pcm:fast:file=/tmp/audio2.$$.wav || clean_tmpmv /tmp/audio2.$$.wav /tmp/audio.$$.wavecho -e "\e[32mEncoding Audio...\e[39;49m"neroaacenc -lc -q 0.15 -if /tmp/audio.$$.wav -of /tmp/audio.$$.mp4 || clean_tmprm /tmp/audio.$$.wavMP4Box -raw 1 /tmp/audio.$$.mp4mv /tmp/audio.$$_track1.aac /tmp/audio.$$.aacecho -e "\e[32mPutting all together\e[39;49m"MP4Box -new -add /tmp/video.$$.264 -add /tmp/audio.$$.aac "$1" || clean_tmpclean_tmp