Results 1 to 10 of 10

Thread: Simulating Video on QLabel or QGraphicsView

  1. #1
    Join Date
    Oct 2006
    Posts
    83
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Simulating Video on QLabel or QGraphicsView

    I want to simulate video by displaying incoming image frames. I wanted to display the video on a QGraphicsView's scene, but was unsure if there would be a problem with performance. Is there any known performance problems with setting a pixmap on QGraphicsView rather then a QLabel? The reason I want it on a QGraphicsView, is so that I can add overlays to the scene (which will be shown over the video).

    Thanks in advance

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Simulating Video on QLabel or QGraphicsView

    I made a QVideo widget with Qt3.3.
    There is no issue with perfomance, but the way to go is not with QPixmap.
    Under Qt3.3 I bitBlt() the buffer directly on the widget.
    I had no problem showing a stero stream at 30fps. each video was 640x480.
    I guess (but didn't check it out) that with Qt4 it will be more elegant then using bitBlt().
    I suggest reading the Arthur docs. http://doc.trolltech.com/4.0/qt4-arthur.html

  3. #3
    Join Date
    Jan 2006
    Location
    Norway
    Posts
    124
    Thanked 38 Times in 30 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Simulating Video on QLabel or QGraphicsView

    The fastest approach should be to call drawImage() from your video item.
    Bitto / Andreas Aardal Hanssen - andreas dot aardal dot hanssen at nokia
    Nokia Software Manager, Qt Development

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Simulating Video on QLabel or QGraphicsView

    The fastest approach should be to call drawImage() from your video item.
    Could you elaborate on that?
    What video object?

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Simulating Video on QLabel or QGraphicsView

    I implemented a video widget using Qt4 and QGLWidget. Works nice (smooth), even on fullscreen, and there is still some place for optimisations (for instance hardware accelerated yuv to rgb conversion or buffering the video stream).

  6. #6
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Simulating Video on QLabel or QGraphicsView

    Wysota - could you explain in few words how did you implement that?
    Thanks.

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Simulating Video on QLabel or QGraphicsView

    In a few words? Hmm... Video stream is decoded using libavcodec (so should be portable) to rgb frames (the yuv->rgb conversion is slow, so we lose some time here) which are placed in a small buffer. A QTimer synchronises the display that takes such a rgb image and converts it to an OpenGL texture which is then applied to an orthogonal plane inside QGLWidget. I can't get sound to work, unfortunately I don't have any experience with using ALSA, OSS or anything else (I'm developing under Linux) and using xinelib is out of question (it would be silly then not to use it for display as well). The code is a mess though, so I won't make it public right now

  8. #8
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Simulating Video on QLabel or QGraphicsView

    hehe..
    I just meant this:
    that takes such a rgb image and converts it to an OpenGL texture which is then applied to an orthogonal plane inside QGLWidget.
    that is, the frame drawing implementation.
    So basically you are doing it in openGL (creating a texture), and using Qt to show show your openGL (texture).
    Don't worry, I wont ask for the code, I was after the principal.
    As I noted above, on Qt3 it was possible with out openGL, I wonder if Qt4 allows it as well.
    It would be cool if Bitto would elaborate on that - Bitto?

  9. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Simulating Video on QLabel or QGraphicsView

    Yes, I'm using OpenGL. It's portable and fast enough (probably even on software) and gives easy ways of manipulating the image displayed (like making it full screen). Using QWidget with a QLabel or whatever is sooo slow - I doubt I'd achieve 25fps and full screen. For smaller streams you can surely write data directly to QImage and render it on a widget or graphicsview (QGraphicsViewMovieItem?).

    A side question - how much work would it be to render an OpenGL item on the graphics view? I'm not an expert on QGL, but it should be possible using QGLFrameBufferObject, right?

  10. #10
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Simulating Video on QLabel or QGraphicsView

    Using QWidget with a QLabel or whatever is sooo slow - I doubt I'd achieve 25fps and full screen
    As I said, I had no trouble doing 2 x 640x480 video streams in parallel at 30fps. with QWidget and bitBlt(), on a low end maschine.
    I don't claim it is better then using OGL, I think if I would had to do it today again, I wouild go for OGL too.
    I am no OGL expert either, so I can't answer your last question...

Similar Threads

  1. [SOLVED] DirectShow Video Player Inside Qt
    By ToddAtWSU in forum Qt Programming
    Replies: 16
    Last Post: 3rd November 2011, 07:47

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.