Converting a Dicom file to a jpeg or video file using dicom2jpeg and FFMpeg

Posted on Sep 20, 2011

This article explains how to use dicom2jpeg and ffmpeg to convert a dicom file to a flash movie, suitable for streaming from a website.

dicom2jpeg is an application distributed with Imebra (look in the examples folder), while ffmpeg is an open source application downloadable from here or here (windows).

dicom2jpeg can convert a dicom file to one or more jpeg images, while FFMpeg is able to produce a movie (mpeg, flash and other) from a series of images. Combining them together allows us to convert a dicom file to a movie.

The version 0.0.45 of Imebra introduced a new feature to dicom2jpeg that makes it able to call directly ffmpeg with the automatic setting of few key options (like the frame rate).

In order to conver a dicom file to a flash movie, open a command line terminal and type:

dicom2jpeg pathToDicomFile pathToOutputImage -ffmpeg pathToFfmpeg pathToMovieFile


  • pathToDicomFile = path to the dicom file that has to be converted to a movie
  • pathToOutputImage = path to the output jpeg images: e.g.: c:tempimage.jpg will generate the series of images c:tempimage0.jpg, c:tempimage1.jpg, c:tempimage2.jpg,…
    The folder where the images will be create has to exist
  • pathToFfmpeg =path to the ffmpeg application. Most of the time the string ffmpeg is enough
  • pathToMovieFile = path to the movie file that generated by ffmpeg, e.g.: c:movie.flv a flash file or c:movie.wmv to generate a windows media video file

After -ffmpeg you can specify all the options accepted by ffmpeg, using the same syntax specified in the ffmpeg manual.

Some parameters needed by ffmpeg, like the frame rate and the input images are automatically added by dicom2jpeg.

Using dicom2jpeg on a web server

Few precautions have to be taken to use dicom2jpeg on a web server.

The software may be called from several threads at the same time; it is important that when dicom2jpeg is called a fresh folder for the images and the final movie is generated, possibly using a session identifier in the folder name.

After the movie has been generated, the images or all the folder should be deleted by the calling application.