Microscope Digital Video Using Only Free Software

Robert Pavlis, Girard, Kansas USA

The digital video cameras that are available today are much less expensive than the ones that were available in the past, and they generally have greater capabilities. They can be coupled with microscopes to provide excellent documentation of microscope observations. The resulting images can be transferred to computers and stored in one of several standard formats. Unfortunately there exist substantial variations in digital video cameras, and how they function. The discussion here will centre on use of cameras that utilise ieee 1394, often called "Firewire" data transfer from cameras to computers. Some modification of procedures discussed here may be necessary for other types of cameras.

There are several important advantages to using POSIX (Unix type) operating systems for digital editing such as Solaris, the three flavours of BSD, and the many flavours of Linux.

What makes POSIX, Xwindow based, systems especially useful for digital image manipulation is the fact that one has available both the power of mouse driven commands for processes that are most efficiently executed with "mouses", as well as the extreme power of POSIX shell commands when this mode of operation is better. It only takes a few minutes of working with digital video imaging to recognise that it is a serious hindrance not to have both of these modes of operation available!

Commercial software for handling digital images, both still and video, can be rather expensive. However, there are many free programs for doing this too. There are particularly large numbers of such programs for POSIX operating systems. Many of these are at least as good as their commercial analogues.

Modern digital video cameras are not the monsters that earlier ones were, in fact, many are less massive than many still digital cameras. Standard consumer digital video cameras have fixed zoom lenses that cannot be removed. This means that when they are attached to a microscope, the image must be obtained through a microscope ocular of some sort. The image to the right of this text shows a Leitz Orthoplan microscope with a digital video camera attached. This particular video camera is larger than average, and it is still dwarfed by the huge Orthoplan microscope!

In general the microscope ocular obtained for this purpose needs to have a large field lens and long eye relief. One can try several low power microscope oculars with a given digital cameras until an ocular is found that functions well. However, I used the Scopetronix Maxview Plus ocular, a special ocular that is designed to use with both standard telescope ocular sizes and and both standard microscope sizes. It also has threaded fittings on the other side for connecting to any camera that takes threaded lens accessories. This set is somewhat expensive, costing about $US300. There are other similar devices produced commercially; however it is not really too difficult to machine an adaptor to fit standard microscope oculars to a given camera. (Those familiar with machining will quickly note that the hardest thing involved in doing this is cutting the threads to attach to the camera lens.)

The best microscopes to use for this purpose are trinocular ones or at least ones with vertical ocular tubes. It is also best to use microscopes that focus by moving the stage rather than the optical assembly. Because modern digital video cameras are quite light, however, using microscopes that do not meet these conditions probably will not cause any problems.

Some trinocular microscopes may have unusual fittings for the "third eye". I machined a special holder that can use both standard eyepieces and the special 30mm ones used by the Leitz Orthoplan. (Simply inverting it changes it from one size to the other.) The image to the left shows a closeup of the attachment point of the microscope to the camera.

Digital video cameras are capable of recording scenes with low light levels, so problems seldom develop from insufficient illumination. However, uneven lighting can be painfully obvious on the final video image that can go unnoticed until the final digital video is viewed.

Once the digital camera is attached to the camera, the recording of the digital video is simply a matter of focusing and starting the video camera and allowing it to record while the microscopic events unfold.

The practical thing to do with digital video files is to transfer them to computers and view them with standard computer digital video display software. Unfortunately, the formats used by digital video cameras result in enormous digital files. Even though digital microscope video clips are are seldom longer than a few minutes, the files are so huge that it does not take very many video clips to consume gigabytes of mass storage!

Digital video editing software is absolutely essential to be able to select portions of the original video stream for inclusion into shorter video clips. The various flavours of Linux operating systems are very well suited for doing this, and virtually all the software is free, and, more often than not, equal or superior to the commercial software available for commercial operating systems. (It achieves this because of two factors: (1) Users have source code available and the users can thus fix coding errors. (2) The open source operating systems are not deliberately designed to be difficult to program.)

The most commonly used free video editing program seems to be "kino." Kino is easy to use, and fairly well documented on its web site. Kino comes with another program called "dvgrab" that is useful for transferring the digital files from digital video cameras to computers. Another free program that one really should obtain for doing this is one called "ffmpeg2theora". This shell program will convert the digital video files into ogg theora format. Ogg theora digital video files are highly compressed, and produce high quality playback. The POSIX operating system shell commands permit feeding the output from dvgrab directly into ffmpeg2theora, so one can produce an Ogg theora video file of a full digital video tape directly from the camera, provided one has a fast enough computer to handle the encoding. Another free program "mencoder" is a general video encoder that can be used to produce compressed video files in a variety of formats. Unfortunately, however, it can be a fairly user hostile program. (Both mencoder and ffmpeg2theora are shell command driven programs, this enables them to take command line arguments to govern how they operate, dramatically increasing their power.)


 

"Doing it with Linux!"

Many digital video cameras have ieee 1394, often called Firewire, connexions. When the camera is placed in playback mode it not only displays the video image on the camera's monitor, it also sends it to the ieee 1394 port. When a computer is connected to the video camera's ieee 1394 port, it can capture the image as it is played. Many cameras send a constant video stream to their ieee 1394 port all the time the camera is turned on, even when the camera is not recording or playing back images. It is often convenient with these cameras to capture images directly on the computer without ever recording them on tape.

Some computer motherboards have ieee 1394 ports, others do not. Inexpensive ieee 1394 interface cards are available for computers that lack this feature.

Most modern Linux distributions automatically sense when an ieee 1394 device is plugged into the computer and load appropriate kernel modules. Older versions may require manually loading kernel modules and device files.

Most modern Linux distributions have huge repositories of precompiled software, and they have a convenient system to resolve all library dependencies, downloading more libraries and programs if necessary. One can get kino and mencoder this way. ffmpeg2theora is available as a statically linked version that can simply be downloaded, should it not be available via a repository.

Once one has kino, ffmpeg2theora, and possibly mencoder successfully installed on one's computer, it is time to go to work!

With most ieee1394 equipped digital video cameras no special programs are needed to transfer the video image to the computer, other than a simple "grab" program like "dvgrab". To transfer images from a camera of this type to the computer first prepare the camera for playback. Connect the camera to the computer via a standard ieee 1394 cable. Start playback, and immediately from a text shell type simply "dvgrab filename" An enormous video file will begin building on the computer! (Some versions of Linux may require that you run the capture program logged in as root or using the sudo program as a security measure.) One can tell dvgrab with command line arguments to stop after a specified time, or one can stop it with "Ctl C" when the desired segment is transferred. (Kino itself can also be used to capture the video signal from the camera without having to use dvgrab.)

Now one needs to start a digital editor such as "kino". Although many computer users like to click on icons to start programs like this, it is more convenient and much less time consuming to start it from a text shell by simply typing "kino filename".

Once the digital video file is loaded into kino one can select the portion of the video file that one wants to put into the video clip. One can also add an appropriate sound track if desired. Kino can export this as a standard digital video camera type file, or it can convert it into a limited number of compressed formats. It may be preferable to export the edited image as a standard dv file, and then use ffmpeg2theora or mencoder to generate the final strongly compressed video clip. I prefer the open source Xvid and Ogg theora formats. They provide good compression with good play back.

It sometimes happens that it is desirable to convert an entire video tape to ogg theora without editing. As mentioned earlier, with a fast computer this can be accomplished via the magic of Unix shell commands without writing the huge digital camera file to disk. Instructions to do this can be obtained from the ffmpeg2theora program by running the starting command without any filename. Again, this only can be done with a fairly fast computer! With slower computers it is necessary to capture the original digital camera file and convert it to a compressed format in a separate step.


A short clip of an amoeba that was taken using a Leitz Orthoplan microscope with 40X phase contrast objective, and the Scopetronix ocular can be obtained by clicking here. This file is encoded using ogg theora. It plays for 20 seconds and is only about 2.8 megabytes long, and it still displays a 720x480 video image!

The same video clip encoded in Xvid can be obtained by clicking here. This file is slightly smaller.

A second video clip of a group of ciliates can be obtained by clicking here. (This one was obtained using the same system and is in xvid format.)

All comments to the authors via

Robert Pavlis are welcomed.

 Article supplement 'Terms Encountered in Digital Imaging'

  Microscopy UK Front Page
Micscape Magazine
Article Library


Microscopy UK or their contributors.

Published in the May 2009 edition of Micscape Magazine.

Please report any Web problems or offer general comments to the Micscape Editor.

Micscape is the on-line monthly magazine of the Microscopy UK website at Microscopy-UK  


Onview.net Ltd, Microscopy-UK, and all contributors 1995 onwards. All rights reserved. Main site is at www.microscopy-uk.org.uk with full mirror at www.microscopy-uk.net .