Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved QMediaPlayer setPosition shows previous frame first

    Qt for Python
    2
    3
    220
    Loading More Posts
    • 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.
    • S
      sssupply last edited by sssupply

      Hello,

      I am using QMediaPlayer to display a video and I have a step forward button that is supposed to move the video one frame forward.
      Here is the step forward function:

              def next_frame(self):
                  self.progress_slider.setSliderPosition(self.progress_slider.value() + self.frame_increment_interval)
                  self.player.setPosition(self.player.position() + self.frame_increment_interval)
                  return
      

      but when I click the button it shows a previous frame first (like 100 frames in the past) before it moves to the next frame.
      Any idea why this behaviour exists?

      Thanks!

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi,

        The behaviour will depend on several factors. The video stream format, the container format, the backend you are using which depends on the OS you are on.

        The files you are playing may be highly compressed with few keyframes in between and you will not have each and every frame stored in your file. The step size also is important.

        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 Reply Quote 0
        • S
          sssupply last edited by

          Oh okay. Is there a proper way to step through a video frame by frame using pyqt and without using openCV? I'd rather not have to swap back and forth between QMediaPlayer and openCV when playing the video normally and when I want to step through a video frame by frame. Also, I'm running this on Windows 10 with a mp4 video file.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post