Friday, March 26, 2010

Headless dvd ripping for xbmc.

As always use at your own risk. This blog assumes you are not afraid of the shell.

I will describe how I am able to Rip my DVDs from my HTPC running XBMC-Live. I like to use DVDFab HD Decrypter because they do a fine job of keeping up with all the stupid shit the movie people do to keep you from making easy legal backups. This should work on Blu ray but I don't own any Blu ray movies/Drives nor will I until the make a real Blu ray player for linux.

Must install required software
ssh to your XBMC-Live box(ex. ssh user@xbmc-live -X)
the -X will send any X information to your display

if your running windows you will need something like:
http://www.straightrunning.com/XmingNotes/
or a keyboard and mouse and be in front of your TV.

cd ~
sudo apt-get install wine wget xvfb
wget http://www.kegel.com/wine/winetricks
sh winetricks corefonts vcrun6sp6


goto http://www.dvdfab.com/free.htm
and grab the latest DVDFab HD Decrypter
I just right click the link or button and select "copy link location" then in the console type wget and then paste the link. Sometimes you need to surround the link with single quotes to preserve the URL.
it would look like this:

wget 'http://www.dvdfab.com/mlink/download.php?g=DVDFAB6'
wine DVDFab____.exe


use tab to auto-complete..
if you get some errors like:
"Application tried to create a window, but no driver could be loaded.
Make sure that your X server is running and that $DISPLAY is set correctly."
go back to the top and read this again.
wine will be pretty verbose with "fixme:" stuff but you can ignore all that.

Install the program and uncheck every option it gives you.

when its done you can run it by doing the following..

wine ~/.wine/drive_c/Program\ Files/DVDFab\ 7/DVDFab.exe


For anything that pops up select the "don't bother me next time" check box.

Click the green checkmark button on the right side of the title bar.

this seemed a little broken to me the only way to navigate the is to click in the menu box and hit the down key.
In here we want to turn off sounds (general ->sound)
and under DVD to DVD I changed default output size to "DVD9" (shouldn't be necessary) I do this becasue I transcode them to H.264 video and pass thru the audio using handbrake. If you plan to just burn them to a standard 4.3 GB DVD-R/+R/RW then you would want to keep that at DVD5

My XBMC-Live install in sitting on a 8GB esata stick.. I don't have much in the way of space so I make up for that by having Gigabit lan to a sever with a large amount of space.

I already have a directory that I can write to mounted but wine will only see the free space of the current drive unless I add a new drive as a network share.

winecfg


A window will pop up click the "Drives tab" add a dive letter select your folder on the server you have write access to and click "show advanced" then choose type of "network share.
we are done in there so hit "ok."

I created the file .wine/drive_c/Program\ Files/DVDFab\ 7/dvdfab.bat with this in it:


c:\Program Files\DVDFab 7\DVDFab.exe /MODE "FULLDISC" /SRC "D:\" /DEST "E:\" /OUTDISC DVD9 /CLOSE


choose your own options from
http://www.dvdfab.com/docs/index.php/Main/RunningProgramCommandLine
pop in a DVD and run:

wineconsole C:\\Program\ Files\\DVDFab\ 7\\dvdfab.bat


If everything goes will it should rip your movie and close it self.

to put it in a script you just

/usr/bin/xvfb-run /usr/bin/wineconsole C:\\Program\ Files\\DVDFab\ 7\\dvdfab.bat


I'm using "launcher" program addon for XBMC, for some reason I had to launch it twice for it to rip.. I wrote a bash script for a work-around, it will stop you from ripping the same disc twice or overwriting a ripped dvd because of unimaginative DVD volume names. This script goes on the XBMC box. It doesn't copy well here is the link. I usually save them to /usr/local/bin/ and don't for get to enable execution "chmod +x"


It would go something like this for each script:
download the file, move it to /usr/local/bin/
sudo mv DVDFab /usr/local/bin/
make it executable and readable for all and writable for the owner
sudo chmod 755 /usr/local/bin/DVDFab
change the owner and group to root(so you don't accidentally delete it or change it. 
sudo chown root:root  /usr/local/bin/DVDFab


DVDFab:

#!/bin/bash
#kill wine and xvfb if they are already running. Die Mofo!
killall -I wineconsole.exe
killall -I xvfb
#must be mounted first.
mount /dev/cdrom
#get the name of the DVD
VOLNAME=`volname`
DVDLOCATION="/media/gigantor/downloads/ARCHIVE/FullDisc/$VOLNAME"
#1st attempt to backup the DVD
#if the folder allready exsists display warning and exit.
if [ -d $DVDLOCATION ]; then
        wget 'http://xbmc:8080/xbmcCmds/xbmcHttp?command=ExecBuiltIn(Notification("DVD folder already exists. Go fix it.","",11000,"/home/xbmc/.xbmc/Green-Help.png"))' -o /dev/null -q -O /dev/null
        exit
else
        /usr/bin/xvfb-run /usr/bin/wineconsole C:\\Program\ Files\\DVDFab\ 7\\dvdfab.bat
fi

#If the folder exists
if [ -d $DVDLOCATION ]; then
        #send popup to xbmc and stop here if the folder exists
        wget 'http://xbmc:8080/xbmcCmds/xbmcHttp?command=ExecBuiltIn(Notification("DVD Rip complete","",11000,"/home/xbmc/.xbmc/Green-Help.png"))' -o /dev/null -q -O /dev/null
        umount /dev/cdrom
        exit
else
        #if at first you don't succeed...
        /usr/bin/xvfb-run /usr/bin/wineconsole C:\\Program\ Files\\DVDFab\ 7\\dvdfab.bat
        if [ -d $DVDLOCATION ]; then
                wget 'http://xbmc:8080/xbmcCmds/xbmcHttp?command=ExecBuiltIn(Notification("DVD Rip complete","",11000,"/home/xbmc/.xbmc/Green-Help.png"))' -o /dev/null -q -O /dev/null
        fi
fi

umount /dev/cdrom


You know it is successful when the tray pops out.

I would like to turn this into a XBMC plugin and automate the transcoding. I wrote a simple bash script to use HandbrakeCLI
here is a link to the script.


hb:

#!/bin/bash

if [ "$1" = "--help" ] || [ "$1" = "" ] || [ "$2" = "" ] || [ "$3" = "" ]; then
  echo "for to make MKV h.246 video with passthrough AC3 audio from Movie DVD and subtitle"
  echo "HighQ movie :Usage $0 movie input output"
  echo "LowQ movie  :Usage $0 moviel input output"
  echo "HighQ TV    :Usage $0 tv input Name.of.Show Season starting.episode.number number.of.shows.on.disc"
  echo "LowQ TV     :Usage $0 tvl input Name.of.Show Season starting.episode.number number.of.shows.on.disc"

  exit 0
fi
saveto=/bfhdd/downloads/ARCHIVE/
saveuser=james
savegroup=media
savemod=775
let epend=$5+$6-1
i=0

case $1 in
        movie)
        /usr/bin/HandBrakeCLI -i "$2" -o "$3" -L -e x264 -q 20.0 -a 1,1 -E ac3 -B 160,160 -6 dpl2,auto -R 48,Auto -D 0.0,0.0 -f mkv --detelecine --decomb --loose-anamorphic -m -N eng --subtitle 1 -v 9 -x b-adapt=2:rc-lookahead=40
        ;;
        moviel)
        /usr/bin/HandBrakeCLI -i "$2" -o "$3" -L -e x264 -q 20.0 -a 1 -E lame -B 160 -6 auto -R 48 -D 0.0,0.0 -f mkv --detelecine --decomb --loose-anamorphic -m -N eng --subtitle 1 -x b-adapt=2:rc-lookahead=40
        ;;
        tv)
          for ep in $(seq $5 1 $epend)
                do
                  let i=i+1;
                  epno=$(printf %02d $ep)
                  seno=$(printf %02d $4)
                  file_name="$saveto$3 - S${seno}E${epno}.mkv"
                  if [ !-f file_name ]; then
                    /usr/bin/HandBrakeCLI -i "$2" -o "$file_name" -t $i -e x264 -q 20.0 -a 1,1 -E ac3 -B 160,160 -6 dpl2,auto -R 48,Auto -D 0.0,0.0 -f mkv -$
                    chown $saveuser:$savegroup "$file_name"
                    chmod $savemod "$file_name"
                  fi
          done
        ;;
        tvl)
          for ep in $(seq $4 1 $epend)
                do
                  let i=i+1;
                  epno=$(printf %02d $ep)
                  seno=$(printf %02d $4)
                  file_name="$saveto$3 - S${seno}E${epno}.mkv"
                  /usr/bin/HandBrakeCLI -i "$2" -o "$file_name" -t $i -e x264 -q 20.0 -a 1 -E lame -B 160 -6 dpl2 -R 48 -D 0.0 -f mkv --strict-anamorphic -m -N eng --subtitle 1 --subtitle-default -v 9 -x ref=2:bframes=2:subme=6:mixed-refs=0:weightb=0:8x8dct=0:trellis=0
                  chown $saveuser:$savegroup "$file_name"
                  chmod $savemod "$file_name"
                done
        ;;
esac
#end of hb


This script is for future use as a cron job. It searches for .info files in the directory of the rips, then trans-codes using handbrake.


Link


#!/bin/bash
backupdir="/where/you/have/DVDfab/ripping/to/FullDisc/"
moviedir="/where/you/have/your/movies/"
tvdir="/where/you/have/your/TV Shows/"
for file in $backupdir* ; do
        if [ -f "$file/.info" ]; then
                . $file/.info
                echo $type
                echo $title
                case $type in
                movie)
                if [ $movieyear ]; then
                  moviename="$moviedir$title ($movieyear).mkv"
                else
                  moviename="$moviedir$title.mkv"
                fi
                  /usr/bin/HandBrakeCLI -i "$file" -o "$moviename" -L -e x264 -q 20.0 -a 1,1 -E ac3 -B 160,160 -6 dpl2,auto -R 48,Auto -D 0.0,0.0 -f mkv --d$
                  rm $file/.info
                ;;
                tv)
                if [[ ( $season ) && ( $title ) && ( $startep ) && ( $numberep) ]]; then
                  tvsavedir="$tvdir$title/Season $season"
                  if [ ! -d "$tvdir$title" ]; then
                       /bin/mkdir "$tvdir$title" 
                  fi  
                  if [ ! -d "$tvsavedir" ]; then
                       /bin/mkdir "$tvsavedir" 
                  fi  
                  for ep in $(seq $startep 1 $epend)
                        do
                          let i=i+1;
                          epno=$(printf %02d $ep)
                          seno=$(printf %02d $season)
                          file_name="$tvsavedir/$title - S${seno}E${epno}.mkv"
                          /usr/bin/HandBrakeCLI -i "$2" -o "$file_name" -t $i -e x264 -q 20.0 -a 1,1 -E ac3 -B 160,160 -6 dpl2,auto -R 48,Auto -D 0.0,0.0 -f$
                          chown root:media "$file_name"
                          chmod 555 "$file_name"
                  done   

                fi
                ;;
                esac
        fi     
        type=""
        title=""
        season=""
        startep=""
        numberep=""
done   



Some scripts where only tested on opensolaris but they should work on any *nix.(if you run as super user) some have not been tested yet.

I plan on keeping this up-to-date when as I change things so comment or email me if got something wrong of if it isn't working for you.

Tuesday, July 21, 2009

Free phone*

This is my first attempt at a how to so please leave me comments and questions.

How to make calls for free* or cheap
(*free as in no added cost you already pay for Internet and have a PC, etc)

Use this how to at your own risk, don't blame me if your head explodes or your dog catches fire because you read or try this at home..

1A
Find free sip provider and sign-up for an account.
Callcentric
sip2sip
sipgate (free number, this is the simplist method)
voipuser
ekiga
or a really big list at voip-info.org look under peer2peer make sure it says 'Free' and 'Sip' in the description.

I've had good luck with Callcentric and sip2sip . Callcentric has lots of nice features. I've have no luck with ekiga. I'm messing with sipgate atm so far so good.

If you are using a sip provider that gave you a number you can skip this step

Free Washington State phone number from IPKall so people can call you from a PTSN(Public Telephone Switched Network)

or there might be a local sip broker # you/your people can call.

so that sets up the call in from a land line part at this point you cannot call out to a PTSN but people can call in. Now if you get/have google voice you could get a local number and add your Washington State number from IPKall (or from sipgate, etc) to your account. You must have a phone number (of some sort) to sign up for google voice. To make free calls from google voice just login and click the call button put in the number you want to reach, first it will ring your what ever number you used and then call that number.


1B
For unlimited incoming calls from the PTSN use callcentric Cheap DID and pay $4.50/month for a local Number plus per min rates. For the US to US calls you would have to use 782 min to spend $20(including the $4.50). That $4.50 is after 911 fee and taxes. This is great for people like me, for you people like my mother who can spend 3 hours a day on the phone you might want to get the Unlimited plan or check out some reviews on other VOIP companies in you hood. I'd stay away from 8x8 aka Packet8 and Vonage. I would also cross reference the company with this page to see if they play nice with sipbroker. This means anyone with access to a sip account(lots o free ones, see above) can call you directly from a soft phone or call via local sipbroker #.

On Callcentric they have "call treatments" at the moment I have it setup to go directly to voice mail during the hours I should be asleep. Or if you have an ex that wont leave you alone you can have it based on caller id have "Error message: Number disconnected". If its someone you do want to talk to you can have it forward it to your cell or direct work number. They have excellent customer service and a nice trouble ticket system. I don't think they have a number to call but the response time is pretty good.

2A
find a soft phone and buy a headset.
I recommend USB (I blow up my mic port all the time.) Should work in WindowsXP/Linux/Mac with out the need to install drivers.
I'm using Twinkle sip phone and have a Logitec notebook headset
I've used SJ Labs soft phone on my old windows PDA before(is ok) and have tried Articulation on my treo 755p it sucks Articulation not the treo... if you have an ipod touch you could try this, requires a $60 bit of hardware :(

or

2B
Buy ATA(analog telephony adapter) and hook it to a real phone. I own a Linksys PAP2T it works well. I have a DECT 6.0 wireless phone that I can add up to 6 handsets. It uses 1.9 GHz so to not interfere with Wifi or bluetooth.
If you have money to burn you can get a cordless sip phone like this.
You just plug it into your router and plug in your phone.

Remember the quality can be affected by your bandwidth and latency. If you have any p2p software running be sure to limit the Up and Down speed as well as number of connections allowed. Bit torrent is great for downloading large files like Linux Disros, OpenOffice, etc.. but it can suck up all your bandwidth.. G.711 aka ulaw is probably the codec you will be using, it uses about 85 kbps or 0.085 Mbps. Stop all you downloads/steaming media and check your speed here. You may want to check at different times of the day. For instance if you have cable Internet you may notice a big slow down around the time the kids are getting home from school..

To check latency open a command prompt or xterm and ping the sip server by issuing the command 'ping sip_server' the less time the better. For example callcentic has a specific ping server the output will look like this:
$ ping ping.callcentric.com
PING ping.callcentric.com (204.11.192.10) 56(84) bytes of data.
64 bytes from www.callcentric.com (204.11.192.10): icmp_seq=1 ttl=245 time=100 ms
64 bytes from www.callcentric.com (204.11.192.10): icmp_seq=2 ttl=245 time=97.3 ms
64 bytes from www.callcentric.com (204.11.192.10): icmp_seq=3 ttl=245 time=98.8 ms
64 bytes from www.callcentric.com (204.11.192.10): icmp_seq=4 ttl=245 time=99.4 ms
64 bytes from www.callcentric.com (204.11.192.10): icmp_seq=5 ttl=245 time=98.2 ms
64 bytes from www.callcentric.com (204.11.192.10): icmp_seq=6 ttl=245 time=100 ms
64 bytes from www.callcentric.com (204.11.192.10): icmp_seq=7 ttl=245 time=99.8 ms
^C
--- ping.callcentric.com ping statistics ---
7 packets transmitted, 7 received, 0% packet loss, time 6008ms
rtt min/avg/max/mdev = 97.307/99.235/100.916/1.134 ms

fyi. with linux you have to hit ctrl-c to stop pining.

or there is a site that will test your broadband for jitter and packet loss. You will most likely have a little jitter but if you have alot of jitter or any packet loss there may be a real problem. If you have cable the can test the connection from the modem and tell you if its on their side or yours. I was suffering from some major packet loss and it ended up being a faulty splitter on the out side of the house. Who ever hooked up the cable the first time didn't know that a indoor splitter uncovered on the outside of the house was a bad idea.

http://myvoipspeed.visualware.com/


**Disclaimers: Unless your paying for it you will not have E911 support so dialing 911 will not help you. Most people have cell phones if you are on food stamps or what have you you probably qualify for Safe Link. Fucking poor people get all the breaks(kidding!). I'm not sure I agree with this program but thats a different blog.. Also any cell phone that operates on a band that is still active can dial 911 weather you paid the bill or not. This toddlers family knows all about it..

If your a true geek and want to go further down the rabbit hole check out these sites:
http://nerdvittles.com/
http://trixbox.org/
http://www.voip-info.org/