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. How to processing multiple camera/video by a filter in qml/qt?
Forum Update on Monday, May 27th 2025

How to processing multiple camera/video by a filter in qml/qt?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
4 Posts 2 Posters 494 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.
  • U Offline
    U Offline
    Unique66
    wrote on 19 Aug 2020, 08:52 last edited by
    #1

    I have multiple Camera/video and i want to processing all concurrently by a unique filter (QAbstractVideoFilter) . I need show processed frame results separately too. It means that my filterFrame should know about each frame that have send by different Camera/video. how to implement this idea ? i think i have to send a parameter to filter from each VideoOutput like code below but how to do that ?

    MediaPlayer {
           id: mediaPlayer1
           source: "video1.mp4"
       }
    VideoOutput {
           id: videoOutput1
           source: mediaPlayer1
           filters: [FilterFrame](parameterVideo1)
    }
    ————————
    MediaPlayer {
           id: mediaPlayer2
           source: "video2.mp4"
       }
    VideoOutput {
           id: videoOutput2
           source: mediaPlayer2
           filters: [FilterFrame](parameterVideo1)
    }
    
    1 Reply Last reply
    0
    • G Offline
      G Offline
      GrecKo
      Qt Champions 2018
      wrote on 19 Aug 2020, 11:55 last edited by
      #2

      You can't do that with a QAbstractVideoFilter

      The solution would be to instantiate multiple QAbstractVideoFilter and link them to your own object doing the processing.

      MultipleVideoProcessor {
          id: videoProcessor
      }
      MediaPlayer {
          id: mediaPlayer1
          source: "video1.mp4"
      }
      VideoOutput {
          id: videoOutput1
          source: mediaPlayer1
          filters: CustomVideoFilter {
              processor: videoProcessor
              parameter: "video1"
          }
      }
      ————————
      MediaPlayer {
          id: mediaPlayer2
          source: "video2.mp4"
      }
      VideoOutput {
          id: videoOutput2
          source: mediaPlayer2
          filters: CustomVideoFilter {       
              processor: videoProcessor       
              parameter: "video2"
           }
      }
      

      The filterRunnables of the filters will just proxy the frame to the actual processor, giving it an additional parameter.
      Something like this:

      void CustomVideoFilterRunnable::run(QVideoFrame *input, const QVideoSurfaceFormat &surfaceFormat, QVideoFilterRunnable::RunFlags flags)
      {
          m_processor->run(input, surfaceFormat, flags, m_parameter);
      }
      
      1 Reply Last reply
      2
      • U Offline
        U Offline
        Unique66
        wrote on 19 Aug 2020, 18:43 last edited by
        #3

        something is not clear for me in your sample code, please explain little more about where i can access to (parameter: "video1") in filter class, and where and how i implement MultipleVideoProcessor class in relation to CustomVideoFilter ? because i need multiple threads to run each video in filters. thanks again

        G 1 Reply Last reply 20 Aug 2020, 11:18
        0
        • U Unique66
          19 Aug 2020, 18:43

          something is not clear for me in your sample code, please explain little more about where i can access to (parameter: "video1") in filter class, and where and how i implement MultipleVideoProcessor class in relation to CustomVideoFilter ? because i need multiple threads to run each video in filters. thanks again

          G Offline
          G Offline
          GrecKo
          Qt Champions 2018
          wrote on 20 Aug 2020, 11:18 last edited by GrecKo
          #4

          please explain little more about where i can access to (parameter: "video1") in filter class

          You declare a new type in C++ inheriting from QAbstractVideoFilter with a processor Q_PROPERTY with your processor class as a type, a parameter Q_PROPERTY (or multiple) with whatever you need as a type and expose it to QML.

          how i implement MultipleVideoProcessor class in relation to CustomVideoFilter ? because i need multiple threads to run each video in filters.

          Like in my example, you declare a function similar to QAbstractVideoFilter::run but with the parameters you need for each video in addition.
          The threading should be handled by the multimedia framework, meaning that your different Filter run methods will be called in different threads. Just make sure your Processor class is thread safe.

          1 Reply Last reply
          0

          1/4

          19 Aug 2020, 08:52

          • Login

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