Sunday 8 March 2009

Convert iso to vob script

Since i own a PS3 i like to stream all my movies to it. Sadly the video support in it as of date is pretty poor, but it can play .vob. Sadly most movies "borrowed" from the internet is encapsulated into a .iso or .img files, that is iso9660 for us mortals... ;)

Anyway, upon mounting an iso you will find, if it's a dvd rip of course, two folders VIDEO_TS and AUDIO_TS. The VIDEO_TS contains the whole movie segemented into a s*itload of .vob files.
Each of these files contains x-minutes of the movie. So what you can do if you don't like changing movie file every other second. Merge the files together as one large vob. This can easily be done with a cat *.vob new_file.vob command.

But as i'm lazy by nature i wrote a script doing all this for me. I found a nifty cat progress bar implementation called Bar to see the merge status as cat has no progress report of it's own.
So here goes, my extract-vob script. Ps. Sorry about the indentation, i blame the blogs wysiwyg.


#!/bin/bash
NO_ARGS=""

#path and name of file
SRC_NAME="$1"

#DEST path
DEST="$2"

#Name of file with extension
FILE_NAME="${SRC_NAME##*/}"

#Base name of file without extension
BASE_NAME="${FILE_NAME%%.*}"

#EXTENSION of file
EXT="${FILE_NAME#*.}"

#Temporary mount to /mnt
TMP_DIR="/mnt"

#####################################
#To utilize the mount command user #
#must be/have root-previlegies #

#####################################
function check_if_root()
{
ROOT_UID=0 # Only users with $UID 0 have root privileges.
E_NOTROOT=67 # Non-root exit error.

if [ "$UID" -ne "$ROOT_UID" ];then
echo "Must be root to run this script."
exit $E_NOTROOT
fi
}

#########################
#Check for common errors#
#########################
function errors ()
{
if [[ "$SRC_NAME" == "$NO_ARGS" || "$DEST" == "$NO_ARGS" ]];then
echo "Too few arguments"
exit 0
elif [[ ! -e $SRC_NAME || -d $SRC_NAME ]];then
echo "Source does not exist"
echo "Source can not be a directory"
exit 0
elif [[ ! -d $DEST || ! -e $DEST ]];then
echo "DEST is not a directory"
echo "DEST does not exist"
exit 0
fi
}

##########################################
#Check for simple errors and correct them#
##########################################
function dest ()
{
if [[ $DEST == "." ]];then
DEST="$PWD"
elif [[ $DEST == "./" ]];then
DEST="$PWD"
elif [[ $DEST == "/" ]];then
DEST="$PWD"
fi

if [[ ! "$DEST" =~ /$ ]];then
DEST=$DEST"/"
fi
}

################
#Main function #
################
function main()
{
echo "Source : $SRC_NAME"
echo "DEST : $DEST$BASE_NAME.vob"

echo "Mount file in tmp dir"
mount -o loop -t iso9660 $SRC_NAME $TMP_DIR

echo "Extracting file to $DEST$BASE_NAME.vob"
bar -o "$DEST/$BASE_NAME.vob" -c cat $TMP_DIR/video_ts/vts_*.vob
chmod 777 "$DEST/$BASE_NAME.vob"

echo "Umount $TMP_DIR"
umount $TMP_DIR

echo "Remove $TMP_DIR"
rmdir $TMP_DIR

echo "Done! You can find extracted file at:"
echo "$DEST$BASE_NAME.vob"
}

#########################
# Function Calls #
#########################

check_if_root
errors $#
dest $DEST
main $#


Friday 20 February 2009

CDWOW ... delays yet again!

WOW my CD is delayed again... Never order from CDWow.. Would not recomed this site to anyone.

"Hi.

First of all, i placed this order in the end of january and only one of the three items I ordered has arrived(took 11-workingdays, 3 weeks as it was sent on a wednesday).
The second one was set to "sent status" earlier this week(So i guess it will arrive in the start of March!).
But this third item, Valkyrie Chronicles,has now for the second time been delayed. So i feel the urge to really complain about this to you as i see it as unacceptable
to first give the impression of having it in stock. Then after i order it say that it's not by sending a Order Delayed message telling me nothing about when it will be back in stock!
I have now waited 20+ days and yet again a Order Delayed message arrives telling me nothing!! Now i have to wait another x-amount of days before you send me the item( or another Order Delay)
plus the additional 11 days for the delivery to arrive.

With this said, can you please tell me when the game will be back in stock so i can decide between canceling this order and get my game today by buying it
locally or if i should give you a second chance and maybe die of old age before the game arrives.

// Henrik."