PDA

View Full Version : Need Advice: How to import and handle masses of images for a image sequence



[?]jNs
16th June 2011, 15:05
Hi everyone!
I'm new to this forum because I got some (in my opinion) difficult questions concerning Qt (4.7) and I thought this forum could be the best way to get them answered.

First of all: YES, I already used the mighty function "Search", but I'm not that satisfied with the answers.

My goal is to implement a little tool for video editing and manipulation, but the main problem are my source files. They are stored in single *.pgm files and have about 20-30GB in total. For this I got two different approaches:

First approach:

convert all pgms (lossless) via video encoder to a single media source
playback file using "QPhonon" classes
extract a single image/sequence of images to use filters/manipulate them with plugins
export to a single file


progress & assessment
Converting to a single video file is no big deal with external programms (ffmpeg).
Playing and displaying the movie with Phonon is easy too.
Export a images of the file manipulate them, and integrate them - NO IDEA :confused:
>> It takes some time to cache the big file but when its loaded, it plays very smoothly.



Second approach:

import all images to the my application into a QList<QPixmap*>
"play" them in a very atypical way (see below)
manipulate one by one and reintegrate them into the "image sequence"


progress & assessment
Creating the QList and importing the pictures from a directory [check]
To "play" them i used the following code snippet:



void MainWindow::displayImage()
{
QPixmap *img = this->getNextImage();
ui->imgLabel->setPixmap(*img);
ui->imgLabel->show();
timer->start(100);
}


getNextImage() returns a reference to the next QPixmap, that has to be displayed.
ui->imgLabel is of type QLabel and the timer is connected to displayImage().
So if one image is displayed and 100 msecs passed, the next image will be displayed.
This works fine for 20pictures ~ 100MB. When I try using it with 120 pictures ~720MB, its slows down significantly (inacceptable).
I would prefer this solution because of the handling with filters/plugins/..., but if someone would teach me a better way to do it - I'm open minded! :)

The final export has to work on lossless files, thats why I didn't compress them at the beginning. Should I split it up to export data and preview data and compress the preview images?

Thanks for reading carefully & taking some time to think about it!

wysota
17th June 2011, 01:43
In my opinion preloading all the images is out of the question. Simply it is not possible to cache 20GB worth of pixmaps. In my opinion you should have a buffer and you should feed images to that buffer, at the same time reading from the buffer and displaying the frames. If you have a multicore/SMP machine, you can read the images in a worker thread to get better efficiency. Just remember that you have to do the conversion to a pixmap in the main thread, on Windows this should be quite cheap.

One more thing, once you have the final frames, you can use some library (like libavformat/libavcodec) or even ffmpeg to assemble them into a movie.

[?]jNs
18th June 2011, 08:57
Thank you, for your suggestions. I'll try to realize it ;)