What A Crazy 48 Hours

11 11 2012

Well, that was fun. Interviewed by the BBC, got featured on BBC One (though crazy early at around 7am) and then on BBC News 24 twice. In-depth article on the BBC news website which makes the front of the Technology section (as a feature on the side) and then it makes the Home page as the most shared article and the second most read! Then get interviewed live on local radio and finally have a news agency come and take some photos and do another interview. Madness! All because of a blog post I wrote two years ago.

Many people have said I should try to cash in on this, but as others have pointed out, what I have done here isn’t rocket science, it isn’t complex, but I guess what is different is that I took the time to write about it and I plan to explain how to do it in non-techy speak. I also hope to write up a more detailed version, which will take time and I might charge a tiny amount for it, but that would simply be due to the time taken to write it up and because it would contains some code and scripts that I have created myself.

Kudos to WordPress for handling the server load. I use to host this site on my own sever at home, which would have melted by now!

I guess normality will resume tomorrow, but it was fun whilst it lasted. 





How to backup and sync your rooted Android phone automatically

1 03 2012

I have for a while now been working on a custom automatic sync solution for my HTC Hero running Froyo (Froydvillain ROM). As I am a Linux junkie and love scripts and hacks I wanted to do it all via cunning hacks and I’ve finally got it nailed.

This solution uses Scripting Layer 4 Android (SL4A) and Tasker alongside a custom ROM with rsync (any ROM should do so long as it has rsync). For those that don’t know, rsync is an awesome application that allows for remote backup and sync across machines. It turns out you don’t even need a ROM with rsync built in, as you can install an app that provides rsync, the app is called rsync backup for android and can be found here: https://market.android.com/details?id=eu.kowalczuk.rsync4android&hl=en

The only issue is you can’t call rsync from the command line using simply “rsync” since it isn’t in your systems path. However, if you use the following string instead,replacing calls to “rsync” with the following, the scripts still work: /data/data/eu.kowalczuk.rsync4android/files/rsync

SL4A is used to set out what to do via a script. You can write scripts in various languages in SL4A but I am using Bash as I am familiar with it. Rsync is used to actually handle the sync / backup and Tasker is used to launch the scripts when certain conditions are met.

I have created two scripts in SL4A, one backups my photos folder to my main photo folder on my server. The server runs the rsync daemon which rsync on the phone connects to. The other script does the reverse and copies a remote folder in my server that contains a bunch of music to my phone.

Tasker is set up with a profile that activates when my phone is plugged in and it’s between midnight and 7.00 am. This then connects to my WiFi network and then runs the two scripts via the SL4A plugin. Since I charge my phone each night this is effectively automatic.

The key here is getting permissions correct with rsync during the file transfer, as the memory card uses fat32 it hasn’t got any permissions. The rsync daemon doesn’t like this and errors out, hence the need for various settings. The second key here is exporting your password as an environmental variable. This is inherently insecure but since my server has multiple redundant backups and is only locally accessible I don’t care much. I could use trusted keys but I’m too lazy.

Here are the two scripts. First the music script that syncs from server to phone:

#rsync sync
export RSYNC_PASSWORD=password
DATE=$(date)
LOG=/mnt/sdcard/rsyncmusic.txt
echo rsync started $DATE > $LOG
TRY=1
rsync_com ()
{
DATE=$(date)
if [ $TRY = 15 ]; then
echo rsync failed, quitting on $DATE >> $LOG
exit
fi
sleep 10
echo rsync attempt $TRY started $DATE >> $LOG
rsync --progress -vHrltD --chmod=Du+rwx,go-rwx,Fu+rw,go-rw --no-perms --stats --password-file=/mnt/sdcard/scrt prupert@prupert::amusic /mnt/sdcard/amusic >> $LOG 2>&1
EXIT=$?
TRY=`expr $TRY + 1`
echo exit code is $EXIT >> $LOG
echo "********************" >> $LOG
}
rsync_com
while [ $EXIT != 0 ]; do
rsync_com
done
echo rsync finished $DATE >> $LOG
exit

The second script syncs the phones photos folder to my server:

#rsync sync photo
export RSYNC_PASSWORD=password
DATE=$(date)
LOG=/mnt/sdcard/rsyncphoto.txt
echo rsyncphoto started $DATE > $LOG
TRY=1
rsync_com ()
{
DATE=$(date)
if [ $TRY = 15 ]; then
echo rsync failed, quitting on $DATE >> $LOG
exit
fi
sleep 10
echo rsync attempt $TRY started $DATE >> $LOG
rsync -vHrltD --chmod=Du+rwx,go-rwx,Fu+rw,go-rw --no-perms --stats --password-file /mnt/sdcard/scrt /mnt/sdcard/DCIM prupert@prupert::apics >> $LOG 2>&1
EXIT=$?
TRY=`expr $TRY + 1`
echo exit code is $EXIT >> $LOG
echo "********************" >> $LOG
}
rsync_com
while [ $EXIT != 0 ]; do
rsync_com
done
echo rsync finished $DATE >> $LOG
exit

I have put some logging in to check progress and also some retry code that retries the sync if it timesout. It seems my HTC Hero’s WiFi connection claps out after a while so the script retries up to 15 times to run successfully based on the rsync exit code.





Not so long and thanks for all the clicks

4 02 2012

Edit, I’ve transferred over to wordpress.com, so the site stays, it’ll just stagnate for a while….

So, clearly, I have let this blog fall by the wayside. I haven’t written a new post since April 2011. Bad bad me.

As it’s time to renew my hosting, I have decided not to renew and to let this blog expire, rather than just let it attrite, as so many sites do. I use to have a lot more time, but now as I have a reasonably secure job (that I really enjoy), a wife, a lovely 2 year old and another on the way, I have no time to wax lyrical on tech any more.

You will be able to find me here:

http://www.rupert-plumridge.co.uk/

and my tech writings / scripts will move over to here: http://github.com/pruperting

So, it leaves to me say thanks to everyone who read and commented, it’s been fun.





A Better FFmpeg Progress Script

7 04 2011

So, a while ago I wrote an FFmpeg progress script. It worked, but it wasn’t brilliant and it fell apart on occassion.

After getting so annoyed by trying to get it work, I gave up. However, having a need to encode some stuff with FFmpeg again, I decided to return to the script. In the interveening period, my post on the Ubuntu forums, apart from getting one of the best response ever (see the matrix comment) had also encouraged others to give their solutions.

I thus used a combination of these ideas to create my updated version, which is below. It seems to be slightly more robust and still give the same useful info. I will be using this version for now, so I  hope it is of use for others ;)

Creative Commons License
YAFF by Rupert Plumridge is licensed under a Creative Commons Attribution-Non-Commercial-Share Alike 2.0 UK: England & Wales License





How To Make An Advanced Wireless Video Baby Monitor

27 04 2010

So, a while back, I wrote about making your own video baby monitor. This has worked very well, with one exception: at night. The webcam I used doesn’t cope very well at night, and since you are going to want to monitor your baby mostly at night, then I guess that is pretty fail. So, I got myself a new IP / Network webcam, this time a real cheapo Chinese joby from eBay.  One of these:

Now, this camera actually isn’t half bad. It’s got 10 IR LEDs for night vision, it claims to be 10MP, but I am not so sure about that, however the picture quality is fine. It also has audio in and out. Now, sadly, the audio in is pretty terrible, very smothered and fuzzy. I think that is partly down to the low bit rate it uses, but also because the microphone is blocked by the bodywork, which I’ll try and fix one day. The cool thing is that it has pan and tilt built in, so you can move it around to get something in picture, so you haven’t got to get up to move the camera if your baby has moved around somewhere.

The only issue I came across, was getting a video feed WITH audio out of this thin on Linux. It offers an ActiveX solution for IE, but only a video feed for FireFox, without audio (the fact it offers any FireFox compatibility at all is pretty cool). Now, the webcam doesn’t advertise what it is, since it turns out it is a rip off a webcam made by Fosscam. It is actually a Netwave IP camera. This was my major hurdle in working out how to use it. After literally hours and hours or googling and posting on metafi I finally found out how to get an video stream with audio out of it. It turns out the solution is quite simple, you just use this address in VLC’s streaming media source input:

http://IPADDRESS:PORT/videostream.asf?user=admin&resolution=32

Of course, if you changed the username, change it here and if you have a password, then add &pwd=PASSWORD or whatever it is. I found this address from an awesome PDF that lists all the Fosscam’s cgi commands and since the Netwave is a ripoff of the Fosscam, it uses the same commands.

You can find the PDF here: http://www.drivehq.com/file/df.aspx/publish/bubbah/PublicFolder/IPCAMCGISDKV1.7.pdf

There are loads of other options, you can basically configure the whole camera through cgi calls, though, beware, you can mess up and lock yourself out of the camera if you don’t know what you are doing. Here are a snippet of some of the commands:

Take a photo: /snapshot.cgi[?user=&pwd=&next_url=] Parameters user:username pwd:password next_url:the name of snapshot

Use server push mode to send videostream (no audio) /videostream.cgi[?user=&pwd=&resolution=] Parameters user:username pwd:password Resolution:8:320*240 32:640*480

Send videostream in asf format, only support vlc player and mplayer (with audio): /videostream.asf[?user=&pwd=&resolution=] Parameters user:username pwd:password Resolution: 8:320*240 32:640*480

Get device status info: /get_status.cgi Parameters now:The count of seconds form 1970-1-1 0:0:0 to now alarm_status: 0:no alarm  1:motion alarm 2:input alarm ddns_status:DDNS status upnp_status:UPNP status

Get camera params: /get_camera_params.cgi[?user=&pwd=] Parameters user:username pwd:password Resolution: 8: 320*240 32: 640*480 Brightness: 0-255 Contrast: 0-6 Mode: 0: 50hz 1: 60hz 2 outdoor format Flip: 0: initial 1: vertical rotate 2: horizontal rotate 3: vertical + horizontal rotate

Set misc parameters of camera:  /set_misc.cgi?[led_mode=&ptz_center_onstart=&ptz_auto_patrol_interval=&ptz_auto_patrol_type=&ptz_patrol_h_rounds=&ptz_patrol_v_rounds=&next_url=]
Parameters Led_mode: 0:mode1 1:model2 2:shut off the led Ptz_center_onstart: =1 Ptz_auto_patrol_interval, =0: no auto rotating Ptz_auto_patrol_type: 0:no rotate 1:horizontal 2: vertical 3: horizontal + vertical

I can also access the camera through it’s http interface or by using an Android app called IP Camera Lite, which allows me to pan and tilt the camera remotely.

Anyway, using this method, I now have a remote controllable camera that has really good night vision and with audio, all viewable via VLC. Sample nigh time pictures to follow ;)





A New Baby

18 03 2010

So, my regular readers might be wondering where all the usefull hacks, hints and tips are?

Well, I have an excuse, my lovely baby girl was born two weeks ago today and so my life has been rather preoccupied with nappies, vomit and bottles.

Never fear, new posts are coming, including hints and tips on using motion to take time lapse movies, a script to automatically update to the latest SVN versions of ffmpeg and x264 among others.

Till then, enjoy the peace and quiet.





Apple sues HTC over Android

2 03 2010





Backup Backup Backup – Updated

8 01 2010

So, my main storage drive failed yesterday. Admitedly I have been having problems with it over the past few months, with fsck throwing errors on reboot, but yesterday it totally died. One minute it was happily sharing my music out via samba, the next, everything had gone :( Luckily, I run a good backup solution, so all I had to do was get myself a new drive (upgrading to 1TB in the process) and copy over my backed up files.

Simple, but if I wasn’t running my backup solution, I would have been screwed – bye bye to my music, photos and work files.

Thank you rsback and rsync….

(Update)

What is even more awesome, is that since Linux regards everything as a file (so all drives are effectively referred to as files (via the UUID) in Linux (in my case Ubuntu)) swapping out a drive with a new one is very simple. I just updated /etc/fstab with the UUID of the new drive, and then copied over my backed up files to it.

As far as Ubuntu is now concerned, it is the same drive, now only bigger. So all my samba shares and rsync folders all work as before.

God I love Linux.





XBMC and 1080p

4 01 2010

I got myself a full HD TV over Xmas, a 32″ Full HD LCD TV from Panasonic (ok ok, the purests may say that you don’t need FullHD with a 32″ screen, but I say I dont need or want a TV half the size of my wall dominating my sitting room…). XBMC on it is just out of this world beautiful. Totally awesome. Anyone who is using XBMC on an old CRT needs to update NOW, it makes it SO much better.





Google Gives £12.4 Million To Charity For Christmas

24 12 2009

At least one company hasn’t forgotten the true meaning of Christmas. Google has announced that it will be giving £12.4 million to charity for Xmas. Good on you Google.

google








Follow

Get every new post delivered to your Inbox.