Dahaarl
Dahaarl

Reputation: 53

Play a video frame by frame - Kivy

I'm learning Kivy and it's API and I decided to code a small Video Player using the Video widget.

I already implemented a play/pause button and a slider which refers to the length and position of the video for easy navigation but I don't know how to do a "next frame" button ! (and a "last frame" also)

I tried something like that:

def nextFrame(self):
    self.video.seek(self.video.position + 0.04166666666666666666666666666667)

video refers to the Video widget and 0.04166666666666666666666666666667 is meant to be 1 frame in seconds in a 25 fps video... maybe i'm totally wrong though.

This function jumps somewhere in the video (but not a frame later and I can't reuse the button after clicked) and directly to the end of the slider because I mapped it to a max of 1 and the result given by the function is always greater than 1.

So I wonder if someone has an idea to make things work ?

Upvotes: 1

Views: 1123

Answers (1)

Austin Yates
Austin Yates

Reputation: 108

The Video.seek() method takes a percentage of the video as its argument - not a time in seconds (which is what Video.position stores)

You can check out the doc for more info.

Hope this helps!

Upvotes: 1

Related Questions