Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Is update() fast enough for smooth animation?
Qt 6.11 is out! See what's new in the release blog

Is update() fast enough for smooth animation?

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 4 Posters 646 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kitfox
    wrote on last edited by
    #1

    I'm trying to play an Ffmpeg video by reading a video frame from a stream, dumping it into a QImage buffer and then using a component I've created to draw the image onscreen. My widget is passed the QImage I want to draw and then update() is called to redraw it.

    While this works, it leads to a choppy animation. I was wondering if this is due to the Qt UI pipeline I've created being not very efficient, or if the problem may lie elsewhere. Is there a more efficient way to draw a stream of images to a widget?

    aha_1980A W 2 Replies Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Indeed that's not optimal. Are you using ffmpeg to read that video file ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      K 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        Indeed that's not optimal. Are you using ffmpeg to read that video file ?

        K Offline
        K Offline
        kitfox
        wrote on last edited by
        #3

        @SGaist Yes, I'm using the ffmpeg 3rd party library.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          In that case, you should rather implement a QtMultimedia backend to integrate with its pipeline.

          Otherwise, VLC could be a good alternative as they provide Qt integration and also use ffmpeg IIRC.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          1
          • K kitfox

            I'm trying to play an Ffmpeg video by reading a video frame from a stream, dumping it into a QImage buffer and then using a component I've created to draw the image onscreen. My widget is passed the QImage I want to draw and then update() is called to redraw it.

            While this works, it leads to a choppy animation. I was wondering if this is due to the Qt UI pipeline I've created being not very efficient, or if the problem may lie elsewhere. Is there a more efficient way to draw a stream of images to a widget?

            aha_1980A Offline
            aha_1980A Offline
            aha_1980
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @kitfox why not using a dedicated media player?

            Qt has to stay free or it will die.

            1 Reply Last reply
            0
            • K Offline
              K Offline
              kitfox
              wrote on last edited by
              #6

              Unfortunately, QtMultimedia does not work with Windows. Also, I'm doing this as prep for a more complex project where I can splice together several videos, so I need more control than QtMultimedia gives me.

              I've been thinking using OpenGL might solve my problem if waiting for the UI update is what is causing the pausing.

              1 Reply Last reply
              0
              • K kitfox

                I'm trying to play an Ffmpeg video by reading a video frame from a stream, dumping it into a QImage buffer and then using a component I've created to draw the image onscreen. My widget is passed the QImage I want to draw and then update() is called to redraw it.

                While this works, it leads to a choppy animation. I was wondering if this is due to the Qt UI pipeline I've created being not very efficient, or if the problem may lie elsewhere. Is there a more efficient way to draw a stream of images to a widget?

                W Offline
                W Offline
                wrosecrans
                wrote on last edited by
                #7

                @kitfox I did something similar using FFMS2 to get decoded frames from video files, and https://doc.qt.io/qt-5/qopengltextureblitter.html to draw to a QOpenGLWidget. It's theoretically less efficient than if I was doing decode on the GPU and keeping the decoded frames from ever touching CPU memory, but it didn't cause me any performance issues. Just be very careful with how many times you copy the pixel data between the decoder and the screen -- that's the easiest/most-obvious place to waste a tone of CPU time for no reason.

                1 Reply Last reply
                3

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved