As in the previous article, we have used just open source software for every action or transformation carried out.
This solution appeared in one ocasion when we were looking for a quick solution to share some cardiology studies among cardiologists. We wanted a solution with minimal software requirements, and fully multiplatform, in order to ease and promote the migration to open source workstations in public healthcare organizations.
One of the goals was to preserve the original quality of the contents, so we should preserve the original frame rate of the sequence as well as the original image quality (lossless transformations).
1.- The first step is to extract individual frames of the multiframe object. This step can be done using the dcmtk tools.
$ dcmj2pnm +Fa +ob multiframe.dcm /tmp/multiframe_
+omodifier to indicate the output format.
+obto generate BMP,
+onto generate PNG (You can test other available formats, but be careful to avoid loosy formats, such as Jpeg)
2.- Optional step: Obtain the frame-rate if you want to maintain the original values. I am not sure if the video format used (.flv) has a maximum allowed frame rate (59.94 is mentioned in some sites). O the other side, you will need a powerfull machine if you want to display the output at such high framerates. Anyway, you can alway create a slow motion version of the original content using lower framerates. If you choose this option, you must inform the user about the variation with respect to the original content.
$ dcmdump +P "0018,0040" multiframe.dcm
3.- Once you have done the extraction of the frames, you should convert the set of images to the desired video format (.flv in this example). We have tested with
mencoder. Both of them have their own advantages and limitations. Be sure to have the necessary codecs (flv) installed on your system.
Example 1: Assuming a framerate of
bmpframes, and maintaining the original size (800x564 in our case).
$ ffmpeg -r 30 -i /tmp/multiframe_.%d.bmp -f flv -s 800x564 -sameq -an -r 30 multiframe.flv
Example 2: If you prefer to try with mencoder (
$ mencoder "mf:///tmp/multiframe_.%d.png" -mf fps=30:type=png -ovc lavc -lavcopts vcodec=flv -o multiframe.flv
Below, there is just an illustrative video, but you can see the full quality DICOM multiframe ultrasound video.