4

I want to process frames with Qt. I use QMediaplayer to load a video. I used the implmentation I found here. I have additional data stored as "frame by frame values" in a .csv file.

For this I want to get the exact frame number of the current frame which is processed in the "present" function of my QAbstractVideoSurface implementation. It works while playing/stopping and pausing the video, but not when I attach a slider to the video...it seems that the QMediaplayer is out of sync with the data which is displayed. I tried getting the current time of the QMediaplayer while being in the QAbstractVideoSurface::present() function but it just won't work. Setting the time from outside while the slider is being moved was also no success for me.

My main problem is that QVideoFrame::startTime() and QVideoFrame::stopTime() does not deliver correct results after QMediaPlayer::setPosition(int) was called!

Does anyone have ideas how I get the current frame number for a QVideoFrame?

Captain GouLash
  • 1,257
  • 3
  • 20
  • 33
  • I'm not really aware of video processing but since `QMediaPlayer::setPosition(int)` expects a value in milliseconds and if your frame rate is constant, I think you could get the frame duration once and for all at the beginning of the process and then divide the position value by the frame duration to know the frame number. Of course, if the frame rate is not guaranteed to be constant, this will not work. – Fareanor Aug 21 '19 at 07:40
  • It seems like QMediaplayer is moving forward while the QAbstractVideoSurface::present() is still trying to show older frames. I could recalculate the time, but I do not know at which time of the QMediaplayer this frame was processed and "sent out" to being processed... – Captain GouLash Aug 21 '19 at 07:54
  • 1
    @Amazonasmann Did you solve this? Would you care to share with the group? – karlphillip Dec 02 '20 at 23:30

0 Answers0