Change playback rate at runtime: problem with position (QMediaplayer)
-
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. -
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
-
-
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 ?
-
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.
-
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.1This 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?
-
This would require digging in the GStreamer backend code in QtMultimedia sources.
-
@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 .