I have developed a program in C++ that works in 2 major steps :
extract frames from a video with ffmpeg and convert them to jpeg
ffmpeg -i videofile.mp4 -q:v 1 -r desired_framerate tmp_04%d.jpeg
create a multiframe Dicom file from those jpeg images via DCMTK
//Example for one image // Get the n-th image QFile* imageFile = new QFile("Path/To/Image"); // Read the image inside a byte array QByteArray * ba = new QByteArray(); imageFile->open(QIODevice::ReadOnly); *ba = imageFile->readAll(); // Insert the byte array in the Dicom file cond = jpegPixelItem->putUint8Array(reinterpret_cast<Uint8 *>(ba->data()), ba->size()); // Rinse and repeat
It works well and can be displayed on most viewers but some complain about the Transfer Syntax being wrong. As of now, I'm using the "JPEGLossless:Non-hierarchical-1stOrderPrediction" but It seems some viewers can't read my Dicom file unless I change the Transfer Syntax to "JPEG Baseline (Process 1)" which is a lossy Transfer Syntax.
I assume the problem comes from the first step of the program with ffmpeg that might be creating lossy JPEG images but I'm not sure because I'm using the "best" q:v scale as I've seen in other posts on the subject.
Therefore, my 2 main questions are:
- why do some viewers have no problems displaying the dicom file whereas some others can't?
- is there any way to obtain lossless JPEG images from a ffmpeg command?