Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Processing Every Frame in a Video File
QtWS25 Last Chance

Processing Every Frame in a Video File

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
qmlmediaplayervideovideooutputqvideofilter
5 Posts 2 Posters 936 Views
  • 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.
  • P Offline
    P Offline
    PetrichorShark
    wrote on 14 Sept 2022, 18:59 last edited by
    #1

    Hi! I'm working on an application that processes video, which I am performing using video filters for a VideoOutput. The source for this VideoOutput is a MediaPlayer, which has a video file (e.g., an .mp4) as input. That is, my QML basically looks like this:

    MediaPlayer {
        id: playVid
        source: "someFilePath/someVideo.mp4"
        autoPlay: true
    }
    
    VideoOutput {
        id: videoOutput
        source: playVid
        filters: [ someVidFilter ]
        ...
    }
    
    SomeVidFilter {
        id: someVidFilter
    }
    

    However, with this setup, if the filter takes "n" seconds to process a frame, the next frame it receives will be the one from "n" seconds further into the video, skipping all of the frames in-between. This behaviour makes sense, but it's not what I require. I need to process every frame in the video, in order.

    Is there a way to easily do this with Qt? After a fair bit of reading through the documentation and similar questions online, it looks like the only option is something like this StackOverflow post, where setPosition() is used to select the desired frame each time.

    Is this the best/only way to achieve this in Qt? I'm a bit hesitant to implement the above because I'm not very familiar with Qt/QML and so I don't know exactly where setPosition()/play() would need to be called to get the expected result. E.g., would it be acceptable to call them at the very end of my QVideoFilterRunnable's run() implementation? Or would the MediaPlayer consider time to have passed since that setPosition() call, giving me a frame further into the video than what I want?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 14 Sept 2022, 19:12 last edited by
      #2

      Hi and welcome to devnet,

      I would recommend switching to PySide6 and Qt6. The QtMultimedia module has seen a big overhaul that might help in your situation.

      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
      0
      • P Offline
        P Offline
        PetrichorShark
        wrote on 14 Sept 2022, 20:49 last edited by PetrichorShark
        #3

        Thanks! I've given the new QtMultimedia module a look, but I did not see anything new that would address this problem. I could receive video frames in a video sink as opposed to a filter or abstract video surface, but I don't think that would change which video frames Qt gives me; it'd just be a different way to handle the same frames. Is this reasoning correct, or am I missing a key feature of the overhaul?

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 15 Sept 2022, 19:09 last edited by
          #4

          If memory serves well, the video sink should give you each and every frame of the video for you to process in a more consistent manner.

          That said, how long does your processing take ?

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

          P 1 Reply Last reply 15 Sept 2022, 23:43
          0
          • S SGaist
            15 Sept 2022, 19:09

            If memory serves well, the video sink should give you each and every frame of the video for you to process in a more consistent manner.

            That said, how long does your processing take ?

            P Offline
            P Offline
            PetrichorShark
            wrote on 15 Sept 2022, 23:43 last edited by
            #5

            @SGaist Ah, in that case, I'll give it a try. Would that also be the case with QAbstractVideoSurface, or would that one receive further-in frames if more time passes?

            Processing takes about 250ms per frame on Android right now. I'm working on ways to speed that up, but the processing fps is going to be worse than the video file's fps for some time yet.

            1 Reply Last reply
            0

            1/5

            14 Sept 2022, 18:59

            • Login

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