Friday, 27 March 2009

The easy way to add MPEG2 encoding to VTK!

The Visualization Toolkit (VTK) can be set up at build time to provide MPEG2 encoding. This is an optional extra due to the fact that there are patents attached to MPEG2 encoding and Kitware, who develop VTK, want to be able to distribute it as both free and unencumbered software. They do provide an MPEG2 library that can be slotted in at build time but it is not immediately obvious how to do so.

I have found that the most straight forward method of building this MPEG2 library is to drop it into the VTK source directory and add it directly into the build system rather than building it separately outside of VTK. Indeed, the VTK MPEG2 distribution has all the necessary CMake hooks required to do just that.
  • Once you have un-tarred the VTK source tree cd into VTK/Utilities.
  • Un-tar the VTK MPEG2 library here.
  • Go back to the root of the VTK source tree and load CMakeLists.txt into your favourite editor.
  • Search for 'MPEG2' in the file (line 764 in version 5.2.1, line 793 in version 5.4.0) and about 30 lines below that comment out this line: INCLUDE(${VTK_CMAKE_DIR}/FindMPEG2.cmake OPTIONAL) - CMakeLists.txt uses # as a comment marker.
  • In place of that line you need to add the following one: ADD_SUBDIRECTORY(${VTK_SOURCE_DIR}/Utilities/vtkmpeg2encode)
Now you can build VTK as normal, making sure that you turn on VTK_USE_MPEG2_ENCODER in the configure stage. When building VTK the MPEG2 library will be one of the first to be built.

Monday, 23 March 2009

AVS/Express on Ubuntu

Ubuntu (Dapper Drake - 6.06 and Hardy Heron - 8.04) doesn't have a modern enough version of Motif/Lesstif for AVS/Express by default. Installing the latest version of OpenMotif will do the trick, but you still need to tell Express where this self-installed OpenMotif is. This didn't bite me until I had to compile and use my own modules within Express so you may not need to do this if you're just using the standard tools.
  • In the Express installation, find the file include/MACHINE/machinc.mk (where MACHINE is your architecture, eg. linux_64).
  • Edit the MOTIF_HOME variable to point at your new OpenMotif installation. The, incorrect, default will be $(X11_HOME).
  • Edit the XMPATH variable to point to the lib directory within your OpenMotif installation if required. This should most likely be $(MOTIF_HOME)/lib.
That's it!