PDA

View Full Version : Performance: Displaying video in GUI without Phonon



aamikkelsen
17th November 2011, 20:01
First time at QtCentre forum.. so I hope that you guys can help me!

I currently developing an application, where I shall stream (or read) a video on a local hard-drive with a special format. This format has a special header and afterwards it has raw bytes of images with additional timestamps. These videos are normally >100 GB (not joking), so I want a efficient way of reading every frame in these files. At the moment I'm reading these by using QDatastream, but I have been suggested to use Memory Mapping instead. Is this the way to go?

To make this more challenging, my application consist of a video player (where the functionality should be: show the current video, step between frames), where meanwhile an activated background thread should could process the video, frame by frame. I have to decide:

What kind of canvas should I display the video on?
How do I ensure, that I can see the video, while processing it in the background?

d_stranz
17th November 2011, 21:21
I have been suggested to use Memory Mapping instead

Unless you have 100 GB of RAM, memory mapping probably is a waste of time if you are streaming through the video. The underlying operating system and disk controller will take care of buffering incoming data. Memory mapping is only useful when you have a very large chunk of RAM available and you can put a significant part of the file into it. With streaming, you'd be swapping out of the memory map as fast as you loaded into it.


What kind of canvas should I display the video on?

QLabel is typically used to display images.


How do I ensure, that I can see the video, while processing it in the background?

To ensure your GUI stays responsive, you could set the priority of the background thread lower than normal, unless you mean that the background thread is responsible for reading the data from disk and converting it to images to be displayed. If you mean that the processing has to keep up with normal video display rates, I'm not sure what you can do here.

Why can't you use Phonon? It seems that nearly all the functionality needed is in there; you will need to roll your own back end for serving video frames, but you'll be doing that anyway in your own implementation.

aamikkelsen
17th November 2011, 22:12
Why can't you use Phonon? It seems that nearly all the functionality needed is in there; you will need to roll your own back end for serving video frames, but you'll be doing that anyway in your own implementation.

Is that possible? Do you have an example on how do this? I think this can be preliminary solution. But with time, it should be possible to modify each frame with some signal processing, and even mark objects in the movie with a dot.

d_stranz
17th November 2011, 23:40
I don't know a lot about Phonon, but I think if you create a MediaObject type to serve your frames off the disk, then you will be able to use the framework. It looks like the Effect type is what you would use to implement frame-by-frame processing. My understanding from reading the documentation is that Phonon uses what they call a "graph" (actually a processing pipeline) to move frames from a media source (like a file) to a media sink (like a video widget). You can insert nodes into this pipeline, branch it, connect multiple inputs together, etc. Looks pretty powerful.

If you don't have audio associated with your images, you might be able to get by using QMovie with a custom QImageReader class. If you designed the QImageReader class correctly, you might be able to chain them together to implement your on-the-fly processing.

Marking things on screen means that you will want to save that information somewhere, right? That means that you might have time-stamped metadata associated with your images, so that when you play it back the second time, the metadata marks appear along with the video. I think in that case you would have to use something like Phonon, and use an Effect to merge the metadata with the image frames.

Sounds like a hard project, but interesting. The book "Advanced Qt Programming" by Mark Summerfield has a chapter on QMovie and Phonon with example code.

SOS
10th January 2012, 11:21
Hello Guy,A need a help please!!!!!!!!!! i'm new in Qt and OpenCv programming and I need for my application a GUI that's help me to play video and after processing an other window show me the vidéo after processing. someone can help me pleaseeee!!!!!!!!!!
My contact :skyp:sossos1926

stampede
10th January 2012, 11:36
@up: on this forum you can get help with specific problem with your code, if you think you are gonna get whole working application for free, then you are wrong.
There are many threads about Opencv + Qt on this forum, just use the "search" option. Try to write the code, and ask specific questions if you don't know how to proceed.