PDA

View Full Version : Video in Qt designer 3



yjames
3rd June 2006, 20:12
Does anybody know how to display a video within a Qt generated dialog box? The video is being captured off a frame grabber card and uses gtk. Any help or suggestions would be greatly appreciated. I'm using Suse Linux 9.0 and Qt3. Thanks.:)

axeljaeger
7th June 2006, 19:23
You will have to use some media player backend: On Windows, DirectShow, on Mac Quicktime, on Linux either Mplayer or xine. There are may be others, but these are the most common I think.

You would then get a window handle for a QWidget and pass it to these engines to play a video in that widget.

Edit: What is your GTK-thing? Maybe you can embed that into Qt. But why do you want a QDialog when there is already a GTK solution?

yjames
14th June 2006, 18:04
Let me clarify my dilemma. I'm able to generate the video in a separate window from my Qt generated interface window using this line of code:

char* arg1[3];
arg1[0] = new char[128];
arg1[1] = new char[128];
arg1[2] = new char[128];
strcpy(arg1[0],"vision");
strcpy(arg1[1],"-d1");
arg1[2]=NULL;
int pid;
pid = fork();
if(pid ==0)
{
chdir("/home/dev/work/vision/0handvision/vision/");
execvp( "./vision", arg1);
}

Its basically jumping to a different folder and running the video program from there but opens up in a separate window. My problem is....how do you display the video within my Qt generated interface window, so that there is only one window open? Much like how windows media player can be played within web browsers or quicktime within web browsers, etc.

Any more help will be appreciated. Thank you.

wysota
14th June 2006, 18:31
Media player is used as an activeX control. If you want to embed a XServer application, it has to make embedding possible (like mplayer does).

frog
23rd August 2006, 14:20
I was wondering if you would know some plugin and associated API or classes for video codec allowing to play and extract video frame using Qt4 using QImageIOPlugin class.


You will have to use some media player backend: On Windows, DirectShow, on Mac Quicktime, on Linux either Mplayer or xine. There are may be others, but these are the most common I think.

You would then get a window handle for a QWidget and pass it to these engines to play a video in that widget.

Edit: What is your GTK-thing? Maybe you can embed that into Qt. But why do you want a QDialog when there is already a GTK solution?

frog
23rd August 2006, 14:23
I was wondering if you would know some plugin and associated API or classes for video codec allowing to play and extract video frame using Qt4 using QImageIOPlugin class.

PS sorry for the quote I messed up - first time using the forum !

ball
24th August 2006, 14:45
In order to achieve cross-platform purposes, maybe you can consider using MPlayer built-in feature that can be embedded in a window using the [-wid] option and QWidget's [winId()] method?

high_flyer
29th August 2006, 12:49
during my early days with Qt3, I made a QVideo designer plugin.
The plugin is cross platfrom, but it will axpect the image buffer as one of the following:
unsigned char* - as gray scale
unsigned int* - as RGB32
unsigned short* - as RGB565
unsigned char* - as RGB24
or a QImage.

If your frame grabber delivers one of these formats, I can post the plugin code for you here.
QVideo has slots for the various buffers, so if you wrap your frame grabber in a Qt class, and send the frames via signals, the code is very elegant then. (thats the way I use it under linux)
The plugin does no coding/decoding, just displays the given buffer, you will have to do that on your own (in your grabber class).
It is for Qt3/Designer. (I hope to find some time to port it to Qt4... some day...:rolleyes: )

Let me know.

hypermole
11th September 2006, 03:53
high_flyer: I really would like to see QVideo code..and as the rest of my application uses QT4 I'd maybe have time to port it too.. (qt4 supports doublebuffering natively, that would be interesting)

is your QVideo implementation suitable for real time applications (20-25fps)?

high_flyer
11th September 2006, 09:44
Ok, here it is.
Remember, I made it a long time ago, so its not that nice to look at (code).
But it works.
Regarding realtime,yes, on a low end P4 with 500MB RAM, with low end graphic card, it has no problem doing a stereo ( two video streams) 640x480 at 30fps, under linux.
I haven't tried it under windows.
I'd be happy if you could post the Qt4 code if you'll port it.
Regarding double buffering:
I would tend to say that double buffering should be turned off when done in Qt4.
I don't see how double buffering can help in such a widget as this one, where you want the full context of the widget repainted every time and as fast as possible, double buffering will only make it slower.
Oh, and if you find time, it would be good to add a "repaint" after being partly or fully concealed by another widget.
When the video is running, this is not needed ofcourse, but if currently the video is not running, the the current frame shown will not be refreshed.
Hope this helps.