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. QMediaPlayer Synchronization Problem
Qt 6.11 is out! See what's new in the release blog

QMediaPlayer Synchronization Problem

Scheduled Pinned Locked Moved Solved General and Desktop
10 Posts 4 Posters 1.3k 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.
  • D Offline
    D Offline
    DzCode
    wrote on last edited by
    #1

    I everyone, I have more than one mediaplayer and each mediaplayer has its own video in different videowidgets.

    I am using player2->setPosition(player1->position())

    However, there is a synchronziation problem. the second video is like coming 1 or 2 frame late.

    Is there any solution?

    jsulmJ 1 Reply Last reply
    1
    • D DzCode

      I everyone, I have more than one mediaplayer and each mediaplayer has its own video in different videowidgets.

      I am using player2->setPosition(player1->position())

      However, there is a synchronziation problem. the second video is like coming 1 or 2 frame late.

      Is there any solution?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @DzCode You could try to pause player1 first and also player2 and after setting position start both.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      D 1 Reply Last reply
      1
      • jsulmJ jsulm

        @DzCode You could try to pause player1 first and also player2 and after setting position start both.

        D Offline
        D Offline
        DzCode
        wrote on last edited by
        #3

        @jsulm YEs, I tried it too. But some of the videos can be created in run time later. If I create all videos at the start of the program, no problem about synchronization. However, if a video is created later than others, at the first play it takes time to render it; so that it comes late

        1 Reply Last reply
        0
        • D Offline
          D Offline
          DzCode
          wrote on last edited by
          #4

          Also, when I do connect(player1, &QMediaPlayer::positionChanged, player2, &QMediaPlayer::setPosition); the end user can see a little flickering

          jsulmJ 1 Reply Last reply
          0
          • D DzCode

            Also, when I do connect(player1, &QMediaPlayer::positionChanged, player2, &QMediaPlayer::setPosition); the end user can see a little flickering

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @DzCode said in QMediaPlayer Synchronization Problem:

            when I do connect(player1, &QMediaPlayer::positionChanged, player2, &QMediaPlayer::setPosition); the end user can see a little flickering

            Yes, because you do the positioning over signals/slots for every frame I guess :-)
            Maybe you could start the new video and somewhat later position it? To avoid the delays caused by loading the video.

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            D 1 Reply Last reply
            1
            • B Offline
              B Offline
              Bonnie
              wrote on last edited by
              #6

              Are these players playing the same media?
              In that case maybe you can try the function added in 5.15

              void QMediaPlayer::setVideoOutput(const QVector<QAbstractVideoSurface *> &surfaces)

              It should be able to make one single player having multiple video outputs.

              D 1 Reply Last reply
              2
              • B Bonnie

                Are these players playing the same media?
                In that case maybe you can try the function added in 5.15

                void QMediaPlayer::setVideoOutput(const QVector<QAbstractVideoSurface *> &surfaces)

                It should be able to make one single player having multiple video outputs.

                D Offline
                D Offline
                DzCode
                wrote on last edited by DzCode
                #7

                @Bonnie for just trial, I am using the same video, but they will have different video. Also I have to use Qt 5.12.x versions. I have different mediaplayers and different qvideowidgets for each video. However, the time should be synchronized

                1 Reply Last reply
                0
                • jsulmJ jsulm

                  @DzCode said in QMediaPlayer Synchronization Problem:

                  when I do connect(player1, &QMediaPlayer::positionChanged, player2, &QMediaPlayer::setPosition); the end user can see a little flickering

                  Yes, because you do the positioning over signals/slots for every frame I guess :-)
                  Maybe you could start the new video and somewhat later position it? To avoid the delays caused by loading the video.

                  D Offline
                  D Offline
                  DzCode
                  wrote on last edited by
                  #8

                  @jsulm Currently I am trying to do it. I I am able to do, i will write here

                  1 Reply Last reply
                  0
                  • D Offline
                    D Offline
                    DzCode
                    wrote on last edited by
                    #9

                    I forgot the write down the solution.

                    When I add a new video dynamically when other videos are running, I am not stopping videos. I set up a dynamic QTimer which works 2 times for synchroniation, and updates the posiitons just for 2 seconds, and then timer stops

                    1 Reply Last reply
                    0
                    • K Offline
                      K Offline
                      kk17baba
                      wrote on last edited by
                      #10

                      Hi @DzCode, I am facing the same problem at the moment - could you share a code snippet of your solution ? :)

                      Kind regards,

                      Kobe

                      1 Reply Last reply
                      0

                      • Login

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