Raspberry Pi, Time-Lapse & Nikon D90 – Part II

With the Raspberry Pi now on WLAN and the first impressions of the Nikon D90 as time-lapse device, here is my first improvement.

The camera is back out on the balcony, I have started the Raspberry Pi connected to it and I terminated my autorun script from last night. Last night, I took pictured and stored them on the Nikon’s SDCard (because I did not have any connection to my Raspberry). Now, I would like to change that because I would like to be able to download photos from the Raspberry Pi while the camera is still connected and in operation!

Let’s see where the D90 is currently storing images when triggered by gPhoto2:

gphoto2 --get-config capturetarget

The current storage location is the camera’s internal memory…

Image 01 - Current Image StorageNow, that is not what we want… but funny enough, the switch we are looking for (to store the captured image into a local file) is elsewhere:

gphoto2 –capture-image-and-download

This will take a while – it takes the image, then downloads it to the Raspberry Pi.

Image 02 - Image CapturedBy default, the image is stored in my current directory – which accidentally also is my home directory. Using tools such as WinSCP, I can now copy the file to my local computer… not really speedy via WLAN but it works.

Image 03 - Copying the File

Now, there are a couple of other things to explore than just taking images. Let’s first find out what my Nikon D90 supports (via gPhoto2):

gphoto2 --abilities

So this is what gPhoto2 supports me and my Nikon D90 with:

Image 04 - Camera AbilitiesNext thing I am interested in is what settings I can control remotely – so far, I have only manipulated the image storage location on the camera – but there should be more:

gphoto2 --list-config

This gives a long, long list of configuration values to deal with:

Image 05 - Configuration ValuesNow, I might be interested in the details of a special value – say, I want to know the current status of the Battery (Property: Batterylevel)

gphoto2 --get-config Batterylevel

It always takes a moment to respond – but here is the current battery level information:

Image 06 - Battery LevelHow about information about the current ISO Setting (Property: iso)?

gphoto2 --get-config iso

And the result is:

Image 07 - ISO LevelSo not only tells the camera it’s current setting – it also tells me what choices I got when I want to set the ISO Value via the command line… pretty cool!

It even is possible to ask the camera for the available focal length (property: focallength), shutter speed (property: shutterspeed in seconds, shutterspeed2 in fractions of a second) and many many other settings.

So there you go – enough settings to spark ideas, a “life” connection to the images taken… what you make from it, is up to you.

To get back to my time-lapse project:

gphoto2 --interval 30 --frames 200 --capture-image-and-download --filename "%Y%m%d%H%M%S.jpg"

is creating the next time-lapse, this time with the images stored on the Raspberry Pi. Next improvement: copy them to my NAS once they are taken… or to a large USB Stick, that also goes onto the Raspberry Pi (but I’d need a current model with four USB Slots or an USB Hub…)

Now, I have taken a series of 200 Images with the aforementioned command – here is the result.

https://youtu.be/ifLlxph3jJc

For another set of night photos, one thing to consider is the fact that I want my stars to be “points” rather than “lines”, which is caused by the rotation of the earth. Obviously, the longer you open the shutter, the more Earth rotates and that creates these lines…

tmax = 500 / (Focal Length * Crop Factor)

is the formula that gives you the maximum exposure time if you want to keep the stars as points. For my Nikon with its 35mm Lens, that is

tmax = 500 / (35 * 1.5) = 9,52 s

Which means, I am going to work with a 10 second exposure time, 1.600 ISO and an aperture of f/3.5. Last night, my photos were taken with an interval of 60 seconds, I think, i am going to cut this down to 20 seconds. So that is 3 images per minute, 180 images per hour. At least, that is the plan… and here is the script to do it:

Image 08 - Script starfieldAnd it worked – OK, the light from the streets did not help to get the excellent view but it is good enough to proof the setup.

http://youtu.be/BMJs-HCAzuE

 

Posted in Raspberry Pi | Leave a comment

Raspberry Pi & WLAN

When working with the Nikon D90 last night, and using my Raspberry Pi as the time-lapse controller, one thing I was dearly missing was SSH Access to the Raspberry Pi on my balcony… but the WLAN Stick that I had at hand would not work with the box… so I ordered a new one quickly: en EDIMAX nano USB Adapter (which is supposed to work right with the Raspbian installation without any need for additional drivers or firmware). Plugged it in, started the box, and logged in (via regular LAN).

Once connected, you can check if the stick has been recognized – the command is

dmesg

And here is the result:

Image 01 - USB Stick recognized

So that worked… next, we need to check the network devices:

ifconfig

And yes, the Raspberry shows the new network device, wlan0:

Image 02 - ifconfig with new wlan0

As you can see, the wlan0 interface does not have an IP Address (yet) – in order for that to work, we need to tell the system to which WLAN to connect – as superuser, edit /etc/network/interfaces.

sudo nano /etc/network/interfaces

There, you can enter (the quick & dirty way!) your SSID and Password (but be careful, it is clear-text and can be read by anyone gaining access to the Raspberry Pi!)

Image 03 - Configure WLAN

Last but not least, we would like to disable the power-savings of the WLAN Adapter – otherwise, it would be a bit hard to get a connection once it has gone to sleep…

sudo nano /etc/modprobe.d/8192cu.conf

There, you can specify the adapter options:

Image 04 - Adapter Configuration FilePlease keep in mind that the described approach is “quick & dirty” and that there are better ways of working with an encrypted pass phrase for the WLAN… but for now, this works and allows me wireless access to the device.

One final comment: when starting the Raspberry Pi now, it can take a little while till the WLAN connection is established – just allow it some time (about a minute) before thinking that something went wrong!

Posted in Raspberry Pi | Leave a comment

Raspberry Pi Time-Lapse with Nikon D90

I have already shown you how to turn a Raspberry Pi with an attached Camera Module into a time-lapse camera. While that was easy and worked well, there is one thing that it cannot overcome: the limitations of the camera itself. How much cooler would it be to replace the tiny Rapsberry Pi Camera with one of my Nikon Cameras? Say with my D90? I could take advantage of all the different lenses and filters I already got anyway and at the same time have the Raspberry taking control over the photos… and here is how that works!

Of course, the first step – again – is the installation of a current Raspbian Image into a new SDCard (so i am not going to mess with any of my existing systems). Once that is done, the new Raspberry Pi installation can be started and I am using PuTTY to login. Of course, the first commands are apt-get update and apt-get upgrade… at the same time, I also changed the Raspberry Pi’s hostname to nikonctrl.

What’s needed?

Well, here is the idea: the only thing I (currently) want – or maybe rather: want to start with – is making the Nikon take photos when the Raspberry Pi triggers it. That way, I should be able to write me a little script around that trigger that creates the photos for a time-lapse. The library used to control the camera is called gPhoto2.

The command

apt-get install gphoto2

installs die package.

Image 01 - Installing gPhoto2

As you can see, installing gPhoto2 also installs the required library, libcdk5. With that done, I think it is time to hook up the Nikon D90 to the Raspberry Pi. Next, I would like to find out if the Raspberry Pi is now able to detect my Nikon camera – the command is

gphoto2 --auto-detect

And yes, gPhoto2 tells me that it can in fact recognize the camera… first step done!

Image 02 - Nikon D90 detected

Now, things can either get very, very simple – or very, very complex. So let’s try the quick & dirty approach first (keeping in mind what I wanted to do): we need to tell the camera to

  • take a photo,
  • do that every 1 minute,
  • take 600 photos (that fits on the built-in SDCard), and
  • store them on the Nikon D90

which would give me an equivalent set of images as my previous post about the Raspberry Pi time-lapse camera. But before we actually kick off taking photos, one important thing remains to be done: since we want to store the images on the camera, we need to tell gPhoto2 where to store them – which is on the SDCard!

gphoto2 --set-config capturetarget=1

If you don’t do that, the images will be taken but they are stored in the camera’s internal memory and eventually get deleted when you shut down the cam! Now, with that taken care of, here is the command to take the actual photos:

gphoto2 --interval 60 --frames 600 --capture-image

As I said: that would do the job – a quick & dirty solution but that’s all that I have asked for.

Getting a first series of Images

Now, I have a little problem at the moment: my Raspberry Pi does not (yet) have a WLAN adapter and I wanted to take some photos of the nightly sky from my balcony. But in order for that to work, I need the Raspberry to automatically start, configure the camera and then take the photos.

Solution: I am writing a little Shell Script that combines what I need and put it into the cron, auto-starting it at reboot.

Image 03 - Simple Autostart ScriptProbably not brilliant but it does the job… and here is the result of the nightly sky above me:

Starfield_TimeLapse

Posted in Raspberry Pi | Leave a comment

Adding Custom .NFO Files to Kodi Media Center

In a previous post, I have written about my problems with my Kodi installation, how to get Kodi installed on Ubuntu and how to identify issues with the environment. One of the outcomes was that I should consider creating custom .NFO files to better control or at least assist Kodi’s Scraper algorithm to identify and index my TV Shows properly. This also lead to a reorganization of my TV Shows on my QNAP NAS – one outcome was a File Share dedicated to TV Shows for Kids. Anyone of the shows mentions have been recorded on TV and archived over the years, later digitized. The shows are

  • Daktari: a CBS TV Series first aired in 1966. (TheTVDB)
  • Frei geboren: a NBC TV Series first aired in 1974. (TheTVDB)
  • Fünf Freunde: an ITV1 TV Series first aired in 1978. (TheTVDB)
  • Jack Holborn: one of the German TV’s Christmas Shows, first aired in 1982 (TheTVDB)
  • Mandara: a German TV Series (ZDF), first aired in 1983. (TheTVDB)
  • Patrick Pacard: a German TV Series (ZDF), first aired in 1984 (TheTVDB)

Mandara – An easy one

Let’s look at the easier shows first – Mandara was a single-season (dummy-season) show, aired in 12 episodes. My NAS reflects exactly this setup so there should be no issue identifying and scraping the information.

Image 01 - Mandara

All I need to do is to create a file named tvshow.nfo and place it in the show’s root directory on my NAS. The content: the URL of TheTVDB excluding the lid (“Language ID”): http://thetvdb.com/?tab=series&id=83453

Patrick Pacard – Easy but no Episode Names

For Patrick Pacard, the situation is similar: the show was aired in six episodes and I got it down in six episodes.

Image 02 - Patrick Pacard

Jack Holborn – Working with custom Episode NFO Files

Next up is Jack Holborn – it has been aired in 12 episodes in a single season but looking at the information in TheTVDB.com, only the first six of them have titles.

Image 03 - Jack HolbornWhat we got ourselves here is an error in TheTVDB: the series is available in six episodes or twelve episodes – but if spread across twelve episodes, the episode titles are valid for blocks of two (Part 1, Part 2). We now got two choices: we can correct TheTVDB.com or we can create a custom .NFO File with the full information. I opt for the latter one – building my own custom .NFO Files.

Image 04 - Jack Holborn Sample

The above image shows Kodi’s interpretation of my files with a single .NFO File created for Episode 1. The remaining files receive their information from TheTVDB as you can guess. This is what the .NFO File looks like:

Image 05 - Custom NFO File

Repeating the exercise for the remaining episodes sorts out this TV Show…

Image 06 - Jack Holborn completeFamous Five – Restructuring my NAS & Show NFO File

Next up is Fünf Freunde – Enid Blyton’s Famous Five. First of all, there are two shows by that name – the original TV Series from 1978 and a newer one from 1996 (I got copies of the 1978 series).

That one is available on TheTVDB.com and it correctly splits the episode into two parts (although some of them only took one part to cover the story). All I need to do is to create the matching Seasons on my QNAP (I got 26 flat files) and rename them accordingly. But that is done quickly and easily…

Image 07 - Famous FiveDaktari – Restructuring the NAS & gaps in the Episodes

First of all, Daktari has to be restructured into four seasons – which means I need to create the four directories on my NAS.

Image 08 - DaktariNext, I need to put the episode files into the Season directories and rename them appropriately. The easiest way of doing that is taking a look into each one of them, hoping for it to display the title of the episode and then match it up with the information in TheTVDB.com.

Image 09 - DaktariAnd so on… as you can see: adding correct .NFO Files to the movies and allowing the Scraper to better identify them is no rocket science – once you figured out how to do it, it almost becomes an obvious thing to do…

Posted in Raspberry Pi, Ubuntu | Tagged | Leave a comment

Raspberry Pi, Kodi Media Center & Ubuntu

One of the jobs I am using my Raspberry Pi for (or rather: one of my Raspberry Pi’s) is running a Media Center for my TV.

Installing Kodi on a Raspberry Pi

The installation of Kodi (formerly: XBMC) on the Raspberry Pi is simple – the easiest way is to download one of the SDCard Images that already contains a complete system (such as OpenELEC). This will get you started immediately and the casual user does not have to worry about the installation… until things stop to work! Which has happened to me…

Installing Kodi on Ubuntu

Twice now, my Kodi Installation has ceased to work (or work the way I wanted it to work). Unfortunately, finding the problem on the Raspberry Pi is a bit…tedious. Also, trying out things is (although theoretically you only need to make a backup image of the SDCard to roll back to a previous state). So I decided to get me a Kodi Installation on Ubuntu to try things out before rolling them out to the Raspberry Pi – and of course, the Ubuntu Machine is hosted as a Virtual Machine so I can take snapshots, roll back, take screenshots, etc.

My Virtual Machine has got 1 Processor with 4 Cores, 1024 MB RAM, and a 32 GB Disk (reflecting a larger SD Card for the Raspberry Pi). For Ubuntu, I have chosen the ubuntu-14.10-desktop-amd64.iso installation image. Next step was to perform a straight-forward standard installation of the operating system. Of course, once the OS was installed, I powered down the Virtual Machine and set a snapshot.

Before installing Kodi itself, I am patching the OS Installation to the latest releases of the packages – apt-get update and apt-get upgrade are my first steps. The next step is an addition of some standard packages to support maintenance of the Package Manager, apt-get. These are needed to install the actual Kodi Package which is not part of the default distribution. The following packages are installed

  • python-software-properties
  • pkg-config
  • software-properties-common

This can be done in a single command (assuming you have switched to superuser rights by now – sudo su)

apt-get install python-software-properties pkg-config software-properties-common

Image 01 - Package Manager Installation

As mentioned before, Kodi is not available from the default Package Archives – but the Kodi team offers its own Private Package Archive (or PPA). But we need to tell our Ubuntu Installation about it (again, under superuser privileges!)

add-apt-repository ppa:team-xbmc/ppa

Image 02 - Adding the PPA

With the new Package Archive added, the internal Package Database must be updated:

apt-get update

Now, we are ready to install Kodi – the following packages are needed:

  • kodi
  • kodi-audioencoder-*
  • kodi-pvr-*

Again, this can be done in a single command:

apt-get install kodi kodi-audioencoder-* kodi-pvr-*

These will install the core package, all audio-encoder packages and a set of add-on’s to Kodi. The next screenshot will show you in detail to what the package manager resolves the asterisks:

Image 03 - Adding Kodi and related Packages

After the installation, I am restarting the entire virtual machine – a) to be sure that the installation has cleanly initialized and b) to take a new snapshot before starting Kodi for the first time.

Configuring Kodi for the first time

Once the system has restarted, I can start Kodi from the Dash or via a Command Line.

Image 04 - Kodi in the Dash

Now, with Kodi started, I am where my Raspberry Pi takes me to automatically… time to play!

Image 05 - Kodi Main Menu

One of the first things to do when configuring a new instance of Kodi is to point it to the media files. A typical setup could either be a directly connected USB Drive (connected to the Raspberry Pi, that is) or the hosting of the media files on some accessible network share.

In my environment, I have implemented the second option – my media files are residing on a QNAP NAS with a share that allows read-only access to a user I am going to connect with from the Kodi Installation(s).

Image 06 - Setting up Media Files

Via Add Videos… you can now specify a Video Source – in my case, for a Windows Network/Samba Share. You need to specify the Server (I am using the NAS’s IP Address), the name of the Share (in my case “TV-Shows”), the Username (I am using “xmbc” which has read-only access to this folder) and the Password.

Image 07 - Media Source Configuration

Adding the Network Location now allows you to use it with the Video Source configuration dialog.

Image 07 - The Media Source

If everything is all right, you should then be presented with the content of your Video Source and a dialog for further configuration. Which is the next dialog, where you can specify the type of content in that Video Source and how you want it handled.

Your media files are just files to you – but Kodi can identify the files if you tip it off in the right direction. My Video Source contains TV Shows and I want to use a Scraper to index them. The Scraper for TV Shows is TheTVDB – a good description of the Scraper and the settings can be found here. With the right setting chosen, you can then “add” the Video Source and Kodi will automatically apply the Scraper Settings (which can take a while).

Addressing Problems

Foe one reason or another, my Content Scraper does not pick up all episodes of the TV Shows I am hosting in my Video Source. It used to work in the past – but now something is odd (which also happens on my Raspberry Pi and is the reason why I am going through this whole exercise here…)

First, I need to enable Kodi Debugging – that is done via the System Menu -> Settings -> System -> Debugging -> Enable debug logging.

Image 08 - Kodi Debugging

Kodi will immediately start to display overlay information about the system itself and shows the location of the Log File. I can now repeat the operation that cause trouble, i.e. re-scan my Video Source – which I do (to be on the safe side) by removing it, then re-adding it (which triggers a new configuration and a full new scan of the library).

Done with this, I leave Kodi via the Main menu – button in the lower left, then Exit. And open the File Manager in Ubuntu.

The File Manager, by default, does not show the hidden files we need now – as ./kodi is a hidden directory. Ctrl+H will – in the File Manager – quickly enable the display of those hidden items:

Image 09 - File Manager with Hidden Files

Go to ./kodi/temp and open the kodi.log file. Which in my case turns out an interesting information: for some reason, the Scraper plugin identifies the TV Show by it’s title but retrieves the information about a different show (with the same name) and then fails to find the episode matches.

Adding custom Info Files to assist the Scraper

Not sure why this is happening now but it is – and it also shows me what I should be doing: helping the Scraper to identify the TV Show properly. Information about the .nfo files can be found here.

There are multiple flavors for the .nfo files for TV Shows – I am trying the easiest: on the NAS (where the episode files are), I am creating a file called tvshow.nfo. Instead of specifying the exact information, I am just helping the scrapper by pointing it to the right URL in the TheTVDB.com database: go to thetvdb.com, search for your TV Show causing trouble) (e.g. “Miami Vice”) and then copy the show’s page URL (in this case http://thetvdb.com/?tab=series&id=77098) into the .nfo file.

You may have to remove the TV Show from the Database, then re-scan the Video Source but the Scraper will pick up the .nfo file and use this as the baseline for the episode identification.

Posted in Raspberry Pi, Ubuntu | Tagged | Leave a comment