This article explains how to use dicom2jpeg and ffmpeg to convert a dicom file to a mp4 movie.

dicom2jpeg is an application distributed with DICOMHERO (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 from a series of images. Combining them together allows us to convert a DICOM file to a movie.

Let’s use the sample app dicom2jpeg to convert the DICOM file to a series of jpeg images and have it invoke ffmpeg to generate the movie.

Open the terminal and type:

dicom2jpeg pathToDicomFile pathToOutputImage -ffmpeg pathToFfmpeg pathToMovieFile

where:

  • pathToDicomFile = path to the dicom file that has to be converted to a movie
  • pathToOutputImage = path to the output jpeg images: e.g.: temp/tempimage.jpg will generate the series of images temp/tempimage0.jpg, temp/tempimage1.jpg, temp/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.: temp/movie.mpg for a mpg file or temp/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.

Comments are closed