Archive for the ‘Uncategorized’ Category

About: beaks.live – the software

Monday, April 17th, 2023

This is the bird box that is shown at beaks.live. It is on the side of a house in Cambourne, about 8 miles west of Cambridge, in the UK.

Right from the start, the plan was to get it working roughly and quickly and then improve it until it was the best I could do with the crap hardware – this being a £11 webcam connected via USB to a Raspberry Pi 4, which also drives transistors to work the cheapest infra-red LEDs I could find.

Having messed around with RTMP (no one uses it any more) and HLS (I’ll be fucked if I can get it to work) for streaming, I eventually ended up with this system:

The Raspberry Pi takes care of the camera and lighting, uploading the video to the server (a VDS hosted with Mythic Beasts), which does all the heavy lifting of looking for motion and streaming live footage to the many dozens of viewers who are eager to catch a glimpse of beak.

Did I mention the camera is crap? The automatic exposure sets itself to some random level and occasionally flashes up and down twice a second, apparently to relieve the boredom. So the R-Pi has to sort out the exposure, and luckily, you can set most of the camera settings manually via USB. Every 10 minutes the Pi records 5 seconds of video, takes 5 frames and averages the light level on each of them. It then sets the exposure, gamma, and LED levels* depending on whether it needs to be lighter or darker. Or it just leaves things as they are if it’s all hunky dory.

* the LEDs are so dim I just leave them all on all the time now.

It records 5 minutes of video at a time, using FFmpeg (with some video tweaking and normalisation to make the crap camera’s video a bit nicer), which is then uploaded to the server. Funny story – I originally set up the Pi’s exposure setting software so it calculated the camera’s exposure settings from this video – this video which has been normalised. So whatever is coming out of the camera, FFmpeg “fixes” it, and then exposure setting software thinks everything is hunky dory, despite the exposure being so wrong the video is just noise. This is why it records 5 seconds of unfixed video separately to check the exposure. A couple of months later I had forgotten this, and had the brilliant idea of using samples from the 5 minute feed rather than doing a separate 5 second one. I thought the camera had died, until I remembered the normalisation and why I didn’t do it like that originally. I look forward to doing the same thing again in July, September, November, etc.

Incidentally, all this software is written in a mixture of Python and Bash scripting because I am a masochistic lunatic. I love Bash – it’s just mad, with random shit like functions looking like “function my_function () { …” where the ()’s do nothing because you can’t put anything inside them – they are purely decorative.

But I digress. The server has the latest video uploaded to it. It keeps the last 4 uploads so there is 20 minutes of buffer. It deletes the oldest one once it has been processed for motion detection. There is a watchdog timer on the server and the Pi will only upload a video if it’s been updated recently enough. This is to stop the server being filled up with files if it reboots and the processing stops or something. Each 5 minutes is about 100MB.

The motion detection is done with DVR-Scan and hits are processed to generate thumbnails and a static web page. Anything less than 30 seconds long is discarded to get rid of most of the dross. Videos older than 25 hours are deleted so there’s a rolling list of videos.

The live page is also static and uses video.js for the player. The current 5 minute chunk location is obtained using an XMLHttpRequest, then the video loaded with JS. When it gets to the end, the JS gets the next section and plays it with a minor blip for the viewer.

The “live” video is actually always 10-15 minutes in the past because it takes 5 minutes to record a chunk before it’s uploaded and then the server tells the player to play the previously uploaded one so you don’t start watching one that’s still uploading.

It’s a bit like the HLS streaming system, except there’s hideous latency and mine works. If you want to mess it up, right click and choose “show all controls” and then slide the slider to the end. I’ve no idea why I’ve told you that.

About: beaks.live – the hardware

Thursday, April 13th, 2023

This is the bird box that is shown at beaks.live. It is on the side of a house in Cambourne, about 8 miles west of Cambridge, in the UK.

When I put a camera in this bird box last year, I was not optimistic. Expecting to capture nothing more than the inside of an empty box, there didn’t seem much point in spending any significant sum of money on a camera. I decided to see how well I could get it working for how little money.

Two cameras for £21.66 doesn’t scream quality, but they are able to manually focus down to a few cm. Being cheap and nasty also means they won’t have an infra-red filter on the lens, which means I can illuminate the box at night with a light the beaks can’t see.

I picked one and sawed off the mounting at the bottom, knocked up a 3d printed housing to fit it in the apex of the bird box roof, and fitted some cheap Ebay IR LEDs.

A mess of wires being put into the 3d printed camera mount.
Cheap and nasty does it every time

This is the camera and LED housing mounted in the bird box:

Looking up into the box with the mounting fitted.
Looking upwards into the roof of the box

On the outside is the 3d printed box which holds the interface to the cable that goes into the house and the drivers for the LEDs. I actually had a proper PCB made with a D/A for the microphone but I never wired it up because I’m lazy. That’s why there is no sound. Sorry.

The interface box with unused D/A.

The LED controls and USB for the camera share a length of CAT-5 cable into the house, where they plug into the Raspberry Pi, which has an ethernet connection to the router.

And that’s the hardware. Total cost probably around £75, including custom made PCBs, which were ridiculously cheap. I mean like stupidly cheap – around £5 for 5 PCBs, including delivery from China. Anything clever is done in software, including stuff to improve the performance of the (frankly substandard) parts I used. Next year I’ll replace it with decent kit, including a camera that isn’t shit.

Coming up next… The software

Everybody needs good neighbours

Thursday, September 26th, 2013

Following a repossession and a long vacancy, the house next door has a new owner, who is doing it up. We share a drive and I bumped into him as he was unloading decorating stuff from his car. I’m not good at chit chat. “Hello” I said. “Hello” he said. “You own the house now?” I said. “Yes” he said. That was the point I realised I had completely run out of conversation. He stared with increasing panic at me while I frowned furiously, trying to think of something else to say. This continued for a while. My brain had seized up completely, locked at 100% CPU, trying to think of anything to say that wasn’t just fucking insane. Meanwhile, my facial muscles stayed the same in the absence of any further direction from further up the head. In the end he dived inside the house to escape the steady but vicious frowning that was being pointed in his direction.

The next day I was brewing up some beer in the garage with the door open. I was at the stage where you boil it with the hops, and I had a nice rolling boil going in my large stainless boiling pot. My boiler has various wires coming out for heaters, thermometers and the like, along with taps and attachments for chilling the liquid once the boil is done. I had my head immersed in the aromatic steam when I spied my neighbour walking from his house to his car. He spotted me and looked puzzled, so I thought I’d try to be friendly again. I was trying out a large friendly grin when it occurred to me that it might look a little odd that I was grinning at him with my head immersed in steam coming from some weird contraption with wires and pipes coming out of it. I couldn’t help it when my grin turned into a bit of a giggle, which must have added to whatever effect my steamy grinning was having on him because his quizzical expression turned to one of alarm and he almost ran to his car.

The day after that wasn’t any better for neighbourly relations. I was leaving for work in the car, just as his car appeared at the end of the drive, turning in from the main road. I stopped and started waving my arms about a bit, mouthing words to convey the message that it was perfectly OK for him to continue down the drive and I would reverse back into my parking space so he could get off the main road safely because I’m nice like that and not a dangerous maniac. I’m guessing that from his point of view, the dangerous maniac with the weird laboratory in his garage was annoyed that he was coming down the drive, getting shouty and angry. He reversed back on to the road at high speed in what was, quite frankly, a shockingly dangerous manoeuvre. I tried to catch his eye as we passed but he seemed to be hiding behind the steering wheel.

I haven’t seen him since and I’m not quite sure how to convince him that I am almost normal and really not that dangerous.

I’m so popular!

Thursday, March 22nd, 2012

"We must invite Naich. He's so fucking sophisiticated."

Gosh, where do I start.  There are so many people want me to join their exclusive circles.  I had a letter from the Vice Chancellor of Cambridge University (or “Vicey”, as I call him), asking me – actually more like begging me to join him for a swanky reception with canapes and vino.  He used the excuse that it was for my 25 years service working at the uni, but come off it – who wouldn’t want the company of a badly dressed, slightly brain damaged electronics technician, staggering around guzzling wine and belching pastry fumes?

But even more exciting was my email invitation to join the Freemason Illuminati.  I didn’t even realise there was one until I got their mail!  They obviously like the cut of my gib and I was just thinking it was about time I heard from the shadowy evil secret rulers of the world.  If anyone would like any favours once I’ve joined the select elite, let me know.  This is what they sent.  It all seems totally legit.

Date: Sat, 17 Mar 2012 09:30:03 +1200
From: freemason illuminati <noreply@freemason.org>
Reply-To: order@illuminati.umail.net
To: yourorder@fi.org
Subject: we call

You are receiving this mail in regards of the freemason confraternity  of the
whole wide world (FCWWW).

You are moving well in what you are doing but in order to make it easier for
you, we have concluded for you to be a part of us as a member to sign your
life to us and have any thing you need.

Be it any thing in the whole wide world.

You can’t refuse us now for it’s too late.

Get back to us now for your Illuminati membership Order and also for you to
know more about the ancient ILLUMINATI FORUM and also the Orientation and
goals that we pursue.

Get back to acquire your goal now.

I can’t wait to set up some sort of super-villain style base on a Caribbean island.  I’ll need some sidekicks if anyone is interested.  You’ll have to improvise with the sinister weapons until I get set up properly.  I’ll see if I can get some sort of poisoned dart cigarette holder made up, or maybe a miniature gun in a mobile phone, but in the meantime you could use a brick in a sock to bludgeon people to death.

Cat 0 : Linux 1

Monday, March 12th, 2012

I went to do some stuff on my PC the other day to find that the cat had been sleeping with her paw on the “Print Screen” button. This button starts up a program that takes a screenshot and brings up a window asking where you want to save it.

Holding down a key keeps repeating the keypress, so as long as the key is held down it’ll keep starting up new copies of the program, again and again and again, as fast as it can.   It is the PC equivalent of sitting stationary in your car with your foot firmly pressed down on the accelerator. The cat had been sitting like that for quite a long time.  Everything had ground to a halt and the status bar was just 1 pixel wide grey stripes. There was a black box on the screen where the last “take a screenshot” window had popped up but the poor PC didn’t have enough CPU left to actually fill it with anything.

The mouse was barely moving so there was no hope of actually using it to close the windows. It was time to use Geek powers and drop to the command line. I hit CTRL-ALT-F2 and waited for a while. Several seconds later the terminal came up and although it took a few seconds for each keypress to register, after a couple of minutes I was actually able to log in. An incantation of “ps -ef |wc -l” showed there were 3,600 processes running. Each screenshot capture takes 3 processes, so there were 1,200 screenshot programs running simultaneously. I gave it some Linux magic – “killall gnome-screenshot” and everything instantly sped up. I did some more killing and everything went back to normal – in fact there were no ill effects whatsoever and the computer worked fine for the rest of the day, with no need for a reboot or anything.

Jimbo once started up 140 text editors which barely slowed the PC down and Luna couldn’t kill it with 1,200 screenshot programs. Linux – impervious to cats and kids.

Update: It’s been pointed out that I should have used “pkill” rather than “killall”.  Killalling, while relatively harmless on a Linux box – a bit like trimming a dog’s claws, is the Unix equivalent of taking it out back and shooting it in the head with a rocket propelled grenade.

In 20 years…

Wednesday, June 2nd, 2010

Jimbo will have turned into some sort of terrifying super villain:

Yay!  Go Jimbo!

What now?

Monday, May 17th, 2010

I feel I should write something but I lack inspiration. The first person to reply with a suggestion gets a blog entry written about it.

Paypal are a bunch of useless twats

Thursday, October 9th, 2008

A word of advice if you selling something on Ebay to an international buyer using Paypal – don’t. Well, at least read this first before you do and don’t come running to me when Paypal decide that your money is safer with them and they’ll just hang on to it, thank you so very much, you horrible potential thief.

so, as you’ve probably guessed by now, this post isn’t even going to have any attempted humour in it, other than some bitter sarcasm, maybe.

When I sold a certain item on Ebay, it was to a Canadian gentleman. As the item was quite heavy and large I didn’t bother setting things up for an international sale, but this guy was very keen and gave me a good price. So I looked up the carriage on it. It was £71. Holy fuck. Still, he’s paying for it; and he did pay for it, nice and quickly with Paypal. So I packaged it up and decide to transfer the money over to my bank before sending it. I’m not quite destitute yet but a £71 sized hole in my budget isn’t something I’d want for very long.

Paypal says “no, you can’t have your money”. I might be a crook for all they know, so they’ll just look after it for a while. It’s being “Temporarily held” to “help ensure that the transactions go smoothly.” It is released, apparently, “after 21 days without a buyer dispute, claim, chargeback or other action. The hold may be released earlier if buyer leaves positive feedback.” Which isn’t much use to me as it’ll take up to 30 days to get there. So that’s 3 weeks I’ll be out of pocket by £71, which will be lounging around in Paypal’s account, gathering interest for them. That’s a tiny part of Ebay’s $280m profit or, to put it another way, the value of a week’s worth of groceries that I’m lending them for free.

By the way, isn’t it handy that this particular service to the public – helping innocent Ebayans have smooth transactions with potential villains, also lets them earn interest on all the money they are looking after on behalf of their grateful customers? I bet they didn’t even think of this when they set it up – they just have their customer’s interests at heart, after all.

Anyway, I explained the situation to my Canadian buyer and suggested that I refund him the money, as I cannot afford to send it while Paypal are hanging on to the carriage money. Instead he gave me positive feedback to release the funds.

Yes, that’s right. Paypal’s buyer protection policy, designed to squeeze a few more pennies out of it’s customers…, er I mean save innocent buyers from unscrupulous bastards such as me, put him in a position where he had to give positive feedback for an item which hadn’t even been posted to him yet. Nice one Paypal. Good job I’m honest, isn’ t it?

But it gets better. This all happened 5 days ago, so the money was released 5 days ago, right? Nah, Paypal decided that it liked his money so much, it wouldn’t pass it on to me after all. I’ve sent emails to Paypal, the first of which was answered by “Miles” who blamed the computer and said he would get it taken off hold. It wasn’t, so I emailed them again and asked my buyer to email them too, which he did. They sent him a similar message as the one sent to me the first time (except that it contained factually incorrect information about their holding policies, namely that if I marked it as sent it would be taken it off hold) and ignored the email I sent.

So I’ve just given up and refunded him. There was no sign that the money was ever going to be taken off hold.

Based on my experiences, what would my advice be? Well, for one thing, don’t treat Paypal as a bank and don’t keep any money in your account. They are not a bank, are not bound by the rules that govern banks, and can choose to keep your money at any time without warning and there’s nothing you can do about it. Also, if there is any danger that your money will be put on hold, avoid using them for international transactions. This site has plenty more Paypal horror stories.

And finally, as they might still say on the News at Ten (I can’t watch it these days – it’s just too awful), they asked me to complete a questionnaire to see if I was satisfied with their customer service. I decided to be honest.