Little surprises in electronics.

October 4, 2014

On a cheap Yuan Hung Lo MR16 LED lamp, it was a pleasant surprise to find silkscreen print on the tiny PCB showing the orientation of the surface mount rectifier diodes.

SMT diode replacement on a MR16 LED lamp.

SMT diode replacement on a MR16 LED lamp.

I had taken a photo of the board before starting work, and I will be cleaning off the flux before putting the lamp back in to service. At this stage I had only replaced two of the four diodes.

Creating multi-page PDFs with free software.

September 27, 2014

This is another of those posts which are mostly for my reference, but I’m happy to share also.

The task was to scan a multi-page letter, and email it to someone. As I’m not keen on spending money, I look to free software to get the job done.

Requirements: Linux and ImageMagick.

As the letter was a simple monochrome document, I will convert all the scanned images to the Grey colour space first, and then compile them in to a multi-page PDF. The file names are of the format “page01.jpg” “page02.jpg” “page03.jpg” etc and the input format is not important.

mogrify *.jpg -colorspace Gray -compress JPEG

convert *.jpg Filename.pdf

That is it. Really. It’s that simple.

I have not tested it, but if you have colour input images then you ought to omit the mogrify command.

Royal Mail, Barrow-in-Furness sorting office.

August 19, 2014

It seems to be impossible to find the opening hours for my local Royal Mail sorting office (142 Abbey Road).
I’m putting them here for my reference. I hope others find this useful.

Monday: 10:00 – 17:30
Tuesday: 08:30 – 17:30
Wednesday: 08:30 – 20:00
Thursday: 08:30 – 17:30
Friday: 08:30 – 17:30
Saturday: 09:15 – 14:00

Their phone number is 01229 841737, but bear in mind they are unable to answer if they are busy.


July 11, 2014

I don’t seem to receive much spam email, and that’s good. On the other hand I notice that there seems to be a lot of spam coming from , and it has been going on for some weeks now. I keep flagging the messages as spam but talktalk don’t seem to be doing a lot about it.

“Money Made Simple” nuisance calls.

June 17, 2014

A few minutes ago my mobile phone rang. The callers number was displayed as “01274663293”.
Me: “Hello?”
Caller: “Can I speak to Mr. Smith please?”
Me: “That’s me. Good morning.”
Caller: “Hello, this is S… from Money Made Simple. I understand you’ve paid in to a private or frozen pension. Are you aware of the recent changes in government legislation regarding pensions?”
(I didn’t catch the name of the caller, but it does not matter)
Me: “I don’t discuss my private financial arrangements with companies who telephone me without invitation.”
Caller: “Oh, ok” <click!>
The caller terminated the call.

This is the thin end of a type of scam, where the company provides a service to cash in your pension early. They don’t warn you that the “administration fees” are significantly expensive, and they don’t warn you that you will be liable for a large tax on your income from this transaction. Avoid.

“Proper” maps in Strava!

June 1, 2014

(While I’m on the theme of acknowledging and celebrating other people’s good work)

This page has some useful bookmarklets:

They allow you to substitute more useful maps within Strava, more useful if you are a mountain biker anyway.

Converting fonts to paths in Ghostscript

June 1, 2014

This entry is mostly for my convenience, to make it easier to find in the future.


If you just want a one-off conversion at the command line:

gs -sDEVICE=pswrite -dNOCACHE -sOutputFile=”” -q -dbatch -dNOPAUSE -dQUIET “” -c quit

A sorry little tale of how it took two months to get a warranty replacement.

May 2, 2014

In the middle of June 2013 I ordered and received a Kingston brand 32Gb USB drive. It arrived a few days later, after verifying it was legitimate and fully-functional I used it in the usual way. It arrived formatted to NTFS, and I seem to remember re-formatting it to FAT32 for compatibility reasons.

5/2/2014: Part-way through saving a TV show on to the drive, the drive just stopped responding. I tried using the drive on several computers and operating systems. Not recognised. Under linux, the lsusb command did not list the drive. I contacted the seller and was told to send the drive back and a replacement would be dispatched.

17/2/2014: I enquired about when to expect the replacement drive. The following day I received a reply confirming a replacement drive had been shipped.

5/3/2014: I enquired again, as I have not received the drive. The following day I received an apologetic reply, confirming a second replacement drive would be dispatched.

17/3/2014: I reported that the second replacement drive has not arrived. The following day I received an apologetic reply, and the seller asked me to give the Royal Mail a few more days

28/3/2014: I reminded the seller that the second drive has still not arrived. This is a Friday, so I did not receive a reply until Monday. The seller apologised again and confirmed that a third replacement drive would be dispatched.

1/4/2014: Drive arrives by Registered Post. Perhaps they ought to have used Registered Post the first time?

I don’t know what has happened here. Does my post man have light fingers, or can two parcels disappear in two months? I did take the precaution of reporting the missing mail to the Royal Mail. There might be a problem. Even if there isn’t a problem, it protects me where some legal documents are considered “served” if posted correctly without requiring a signature upon receipt.

Obviously I’m not expecting to receive anything like that, but I still think that ten minutes on the telephone to the Royal Mail’s investigation team was time well spent.

I am not going to name the seller. They may have:
(a) Lost two drives to the Royal Mail.
(b) A poor organisation that none of the drives were ever dispatched until 31/3/2014.
(c) Decided to take the chance that I would not pursue the missing drive, and not dispatch it. If this is the case, they decided to send the drive on 31/3/2014 because I had complained about it so many times.
One of these possibilities is beyond the control of the company, another is a deliberate connivance to defraud.

Unpacking D-Cinema content.

April 4, 2014

This entry is intended to be read after my earlier entry on a similar subject:


Having provided a (relatively) simple system for putting your content in to DCP format, I now present a simple system for recovering it. When considering publishing this information I have tried to anticipate some of the outcomes. I have discussed it with people whose judgement I trust. I use no exploit, or “hack” or “bypass” here. I trust that you will only use this information to process content you have the rights to, or only with the full authority of the copyright holder.
The DCI specification provides a means to protect content against unauthorised access, and against tampering. The cinema industry uses it every day. There is no excuse not to use content protection in the cinema industry, particularly when key management is now so streamlined and automated.


If you did not install the digital_cinema_tools package:

then do it now because you will need it for the asdcp-test command

Other requirements are:
(1) OpenShot
(2) ImageMagick
(3) mencoder
(4) A working knowledge of how a DCI package is organised
(5) Lots of disk space
(6) A supply of tea, or your preferred beverage(s)

You might want to turn off image thumbnail creation, as this can easily generate in excess of 6000 files in your working folder. At various points in this tutorial you will find yourself looking for various bits of information about the content such as frame rate, aspect ratio e.t.c. Most of this is held in the Control Play List (CPL) file. The ASSETMAP will define which file is the CPL. The contents are held in XML, so open the ASSETMAP, CPL etc in a web browser.

As the DCI Specification is tightly defined, this procedure ought to work on any JPEG-2000 encoded Digital Cinema Package (DCP) with these conditions:
(a) Not encrypted (no KDM required)
(b) Not stereo (2D content)
(c) Consists of only one reel – most shorts, trailers, adverts, public service announcements etc.

Extracting the picture stream, and conversion from CIE 1931.

First, read the ASSETMAP file. This is found within the folder which holds all the files which (together) comprise the DCP. The ASSETMAP file should tell you where to find the PacKing List (PKL). Search for “<PackingList>” and look a few lines down for the name of the actual PKL file.
Open the PKL file, and look for “asdcpKind=Picture”. That will give you the name of the MXF file which holds the picture information. Also there should be a pointer to the MXF file for the sound, make a note of that for later.

For the purposes of this procedure, I will assume you have determined that the picture file is called “MXF-video.mxf”. Open a command window, cd to the correct folder and issue this command (changing the name of the MXF file to suit):

asdcp-test -x frame MXF-video.mxf

What will happen is asdcp-test will create files of the names frame000000.j2k, frame000001.j2k, frame000002.j2k e.t.c. One file per frame of the DCP. These will be in JPEG-2000 format.

You may be able to import these files directly in to your video editing software. I will provide means to convert them in to other formats, which are more readily understood.

What you should consider at this point is that you may lose some colour information. DCI content uses the CIE 1931 colour space model, and gives a maximum of 12 bits per colour component, therefore 36 bits per pixel. In theory you could convert these JPEG-2000 images to TIFF format, and preserve all that colour resolution, but not all applications understand 48 bits per pixel TIFF files.

To be fair, I’m not sure how much it matters as my display device is 10 bits per channel at best. If you’re using a notebook, you may well only have 6 bits per channel.

To convert to PNG files use this (with a tiny loss of colour accuracy):

mogrify -format png -alpha Off -resize 999x540 -gamma 0.384615 -set colorspace XYZ -colorspace sRGB -depth 8 *.j2c

(a) The output images are resized, feel free to adjust the target size to suit your requirements. I’ve simply divided by 4 to get these figures.
(b) Notice the use of the unusual gamma, because in D-Cinema gamma is 2.6 at projection.
(c) Use “-depth 16″ and “format tiff” if you want to preserve all colour resolution. Worth doing for selected stills, not worth it for transcoding to video.
(d) This will take a long time, go and make a cup of tea. Other beverages may be available.

At this point you can pick out your favourite still frame.

If you intend to proceed all the way to producing a consumer-friendly video of the content, then read on.

Sorting out the sound.

The sound is not so hard to deal with, as the DCI Specification requires uncompressed sound. Common media player applications such as VLC can play audio held in the MXF container format without any sort of conversion. For simplicity’s sake, and because this post is mainly about the picture, I suggest converting the sound to a 2 channel WAV file like this:

mplayer MXF-audio.mxf -ao pcm:file=audio.wav,fast -channels 6 -af pan=2:0.4:0:0:0.4:0.2:0:0:0.2:0.3:0.3:0.1:0.1

This command mixes the six channel sound down to two channels in a standard RIFF format WAV file. The pan option tells mplayer how to mix each input channel to make two output channels. (Source thank you, it sounds slightly better than the example in the manual)

Encoding the video and sound.

You can use some magic command line incantations for this, but it is easier to import the image sequence in to OpenShot along with the 2 channel sound file.

Within OpenShot, create a profile which matches your chosen picture resolution and frame rate. Refer back to the mogrify command you used earlier.

(1) Frame rate is likely to be 24fps, as not all DCinema kit fully supports all valid frame rates. You will find it in the CPL file.
(2) The aspect ratio is likely to be 1.85, but look in the CPL file to confirm. Openshot will accept aspect ratios as a fraction, so you can use 185/100 or the simplest version as 37/20.
(3) The pixel aspect is “1/1″.

There is something which might trip you up. Check the CPL for the “<ReelList>” section. For the picture and sound there might be non-zero “<EntryPoint>” values. These values describe an offset within the video and audio, to show where playback should commence. Using the frame rate and offset (number of frames), calculate the offset between picture and sound. If both of these are zero, then it’s easier later on in OpenShot.

I did not set out to write an OpenShot tutorial, but there is a feature of OpenShot which is not well known. If you drag a file named similar to “image000000.png” to the Project File panel, OpenShot will recognise it as the first frame of a set of sequentially numbered frames. See this tutorial for the details. Add the sound file to the project in the same way.

Put the video on track 2 (upper), and sound on track 1 (lower).

If you have non-zero <EntryPoint> values: With reference to the offset you calculated earlier, move the video or sound left or right as required. If the picture needs to be ahead of sound, you can right-click and enter the offset with reference to the project time line.

Play it through to confirm correct synchronisation.

Use the Razor tool to remove the excess picture/sound from the beginning and end of the project as required. If you’re left with a blank space at the zero line of the project, move both tracks so they commence at zero on the timeline.

Export the project as (rendered) Video, check the profile in use is correct (matches resolution and frame rate) and choose sensible values for container format, video codec, audio codec and frame rate. Some versions of OpenShot (currently) seem to have a problem in saving the finished file to any other folder than /home, so don’t panic if the file is not where you expected it to be.

Tidying up.

(Use these commands with care)

rm *.j2c
rm *.png
rm *.tiff
rm audio.wav

Final words and bits that don’t fit anywhere else.

There was a discussion about adding support for converting XYZ colours to RGB to ffmpeg. I’m no stranger to compiling code from source, but I’ve not tried this method.
As with my previous post on this subject, I extend my thanks to the same four people – for the same reasons.
Actually you can use this with 3D material, start with asdcptest -3 -x frame … and it will output all left eye and right eye frames. I’ll leave it as an exercise for the reader about further processing of the data.

Printing an image larger than the paper size.

February 6, 2014

This another of those “for personal reference posts”, although it might be useful for others. Like many of my posts on computing, this is relevant to Debian-derived Linux i.e. Ubuntu.

If you want to print a banner, or poster, and only have a printer which can print on (say) A4 paper then there is a simple solution. Save the image at the correct size in EPS format. I used Inkscape for this, and I had the paper size set to 1100mm by 550mm.

Check that poster is installed (if not, it is available in the standard repositories).

The command to print my design at 1:1 scale, using A4 size pages:

poster -v -mA4 -s1 InputFile.eps >

The switches specify verbose output (-v), use A4 size paper (-mA4) and that the scaling factor is 1:1 (-s1).

The output file can be printed from Evince, or your favourite Postcript-aware application. It is worth reading the manual for poster too.


Get every new post delivered to your Inbox.