Video Player - Seek to function

Hello,

I'm trying to integrate an video with an animation of a kinematic, which I want to manipulate by calling specific frames / timemarks. I doing this already with a nextion display to show the current position of my kinematic in dependencies of sensors values from an ESP32.

But in App Inventor I had no success so far. I can play and pause the video, but I can't let it jump to a specific time /frame.

When I use the "seek to" function of the video player, only the time bar of the videoplayer moves to the specified time (in my example 1000ms) and that's all. The videoplayer is not showing the correct frames which correspond with the 1000ms and when I use the "videoplayer1.start" function the video starts from the beginning (frame1).

My blocks lock like this

Here my designer view

The video is a mp4 (H.263) video with a size of 100 kB.

I have tried this example via USB connection (Companion App V2.71u) and also via apk, but the result is the same.

Has anyone an idea, how I can solve my problem?

An alternative would be to break your video up into individual images of each frame (ffmpeg can do this on a computer), then you could cycle through these in your app, and use a clock to "play" the video (frames).

It should work. Show the details of your video, like this:

and post the aia.

Here are some additional information about the video I used.

image

File Size: 96,4 KB
Bitrate:388 KBit/s

Here is also the Aia file

Test_Videofeatures.aia (97.5 KB)

I did some tests and it seems that it doesn't work with short video (< 8 sec).

Check this one: Test_Videofeatures_2.aia (748.9 KB)

Herewith a quick example using images from frames:

frameByframeLoaded.aia (900.8 KB)

I used this command to get the images for each frame from the video.

$ ffmpeg -i ak.mp4 -c:v png -s 300x225 %04d.png

(more info about this here)

and added them all to the assets folder of the aia file.

( I should have added a Pause button, basically just stopping the clock)

In practice you could add the image files to a zip file, then upload this zip file to your app, then unzip it to a folder, setting your file path accordingly.

Thanks a lot Anke and TIMAI2 for your help. I think now I can go on with my project.

@Anke: That is very interesting, that there is a limitation in the length or better shortness of the videos. I think I can work around that 8s limitation, by rendering longer videos, but only using the part of the video which I really need.

Try this: Video_playAt1000ms.aia (516.0 KB)

Hi Anke,

thanks for this additional example. It works as expected.

I noticed, that you converted the original video, to a one with a higher framerate. Is that the only difference? Are there any other conditions that the video must fulfil to work with the plyr extension?

Frame rate and bit rate, because the video did not run properly on my test device, neither with the VideoPlayer component nor with the Plyr extension.


Why the SeekTo_ms method does not work for short videos with the VideoPlayer component can probably only be answered by someone from the AI2 team.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.