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. Change playback rate at runtime: problem with position (QMediaplayer)
Forum Updated to NodeBB v4.3 + New Features

Change playback rate at runtime: problem with position (QMediaplayer)

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 4 Posters 3.5k 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.
  • J Offline
    J Offline
    Janny
    wrote on last edited by
    #1

    Hi,

    I'm trying to change the playback rate (fast forward) of a video. In general that works fine. But I want to show the progression of the playback in a label and a slider. For this I use the property 'position' of the QMediaplayer. On normal speed (playbackrate=1.0) this works fine too.
    As soon as I want to speed up the video (for example setting playbackrate=2.0) while it's playing, the slider and the label jump back. Most of the time to a position that is 0, but sometimes it just jumps back a few steps. The video itself works fine. For example the video's position value is at 1000ms before speeding up and after changing the position value is 0 but the video itself didn't jump back to the beginning. From there on the position is "wrong", i.e. even if the video plays to the end, position will not have the value of the QMediaPlayer's duration property. Instead it is less.
    Why is this happening? Can someone help me in finding a solution for this? Maybe I'm just assuming the wrong things.

    I'm combining QMediaplayer with the QML type Videooutput. But after researching a bit I tested the Qt's Media Player Example and I get the same behaviour.
    Currently I tested with mkv and wmv files.

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

      Hi and welcome to devnet,

      You should add:

      • Which version of Qt you are using
      • Which OS you are running
      • Which compiler you are using

      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
      • J Offline
        J Offline
        Janny
        wrote on last edited by
        #3

        Argh, I forgot :).

        I'm using Qt 5.9.1 and gcc 7.2 on Arch Linux.

        Yesterday I was talking to a colleague and we were thinking that the cause for this behaviour could also be connected to GStreamer. So maybe it has nothing to do with Qt. Any thoughts?

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

          I would try again with a more recent version. Either the latest from the 5.9 series, 5.10.1 or even the 5.11 Beta.

          Which version of GStreamer are you using ?

          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
          • J Offline
            J Offline
            Janny
            wrote on last edited by
            #5

            My colleague tried it with the same result using Qt 5.10.1 on Arch Linux and I guess gcc 7.3.1.

            GStreamer's version is 1.12.3.

            If I have the time I will try this with Qt 5.11 Beta but don't know if it will be soon. And I don't have high hopes that this fixes it but who knows.

            1 Reply Last reply
            0
            • U Offline
              U Offline
              Usireland
              wrote on last edited by
              #6

              Sorry for digging up and old thread but I am experiencing the same issue as Janny.

              System Info:
              Os: Linux Mint 19.1
              Qt Version: Qt 5.8.0 & Qt 5.12.0
              Compiler: gcc 7.3.0
              Gstreamer: 1.14.1

              This is only a problem for me on linux. When I tested it with Windows it does not appear to be an issue. I have yet to test it with macOS.

              What appears to be happening is when the setPlaybackRate(qreal) function is called, the QMediaPlayer emits a positionChanged(qint64) signal with a value different from the previous value (even if the video player is paused). In my case this value is generally larger than the current value by a few thousand milliseconds.

              Does anyone have any suggestions on how to resolve this issue on linux?

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

                This would require digging in the GStreamer backend code in QtMultimedia sources.

                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
                • U Offline
                  U Offline
                  Usireland
                  wrote on last edited by Usireland
                  #8

                  I am working around this by doing the following:

                  qint64 currentPosition = mediaPlayer->position();
                  mediaPlayer->setPlaybackRate(playbackRate);
                  mediaPlayer->setPosition(currentPosition);

                  Its a bit ugly but it works.

                  T 1 Reply Last reply
                  1
                  • U Usireland

                    I am working around this by doing the following:

                    qint64 currentPosition = mediaPlayer->position();
                    mediaPlayer->setPlaybackRate(playbackRate);
                    mediaPlayer->setPosition(currentPosition);

                    Its a bit ugly but it works.

                    T Offline
                    T Offline
                    Tenderbread
                    wrote on last edited by
                    #9

                    @Usireland Your solution works for me. My problem is manifested by flushing the video buffer at maximum speed before the video stabilizes at the requested speed. On the screen when changing gears (acceleration or deceleration, it doesn't matter), I see the video scrolling at what appears to be the maximum speed (3X?) For 2 to 3 seconds before the video stabilizes at the requested speed .

                    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