Important: Please read the Qt Code of Conduct -

QMediaPlayer Synchronization Problem

  • 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?

  • Lifetime Qt Champion

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

  • @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

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

  • Lifetime Qt Champion

    @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.

  • 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.

  • @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

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

  • 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

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

    Kind regards,


Log in to reply