jvcleave / ofxOMXPlayer

OpenMax accelerated video player for openFrameworks on the Raspberry Pi 0-3. Does not work with RPI4
GNU General Public License v2.0
180 stars 61 forks source link

onVideoEnd and onVideoLoop not accurate #24

Closed Maigre closed 6 years ago

Maigre commented 10 years ago

Hi, the onVideoEnd and onVideoLoop events are fired too early regarding the current frame / time of the video.

most of the time those events hare fired 5 to 20 frames before the end of a 912 frames long video...

i had to reimplement in my script a watchdog

it's a dirty workaround, but i did not take the time to digg into the code. I'll post some fix once i did some research.

But are the getCurrentFrame() and getTotalNumFrames() accurate ?

I had some trouble also with getMediaTime() that is some kind of time of living of the engine and not the time position in the media (doesn't restart when video loop, and doesn't stop when video end without looping)...

I did reimplement something using position = .getCurrentFrame() * .getDuration() / getTotalNumFrames()

Do you think it's accurate ?

Thank you Best Regards, Thomas

jvcleave commented 10 years ago

It depends on a lot of factors

Right now in master getCurrentFrame has been accurate in my test videos. I use stuff like this with the frame number burned in

Unfortunately due to threading and caching (for example with non-texture the video has been long decoded before it gets to the screen). I recently realized that looping with very short or highly compressed videos causes it to behave differently.

Related #14

timesuptim commented 9 years ago

I am having similar troubles. I am trying to have a looping video join to a second looping video with a given video transition. So I would like to have this: 0: first video is looping, a signal comes in that it is time to change 1: wait for the first video to get to its loop point 2: start the second video and play it 3: wait for the second video to reach its loop point 4: start the third video and let it keep looping All this should happen at full screen, i.e. nontextured mode. I have attempted various things, similar to those indicated above, but have no satisfying solution. Is there a "right way" to do this? All videos are 30 second long, 750 frames, h264 compression, 1920x1080 pixels, no audio.

I hope this can be done "easily" as I thought I had it nailed, but things are looking messy now...

Tim

jvcleave commented 9 years ago

@timesuptim I would try and add an audio track (even a silent one) and see if that helps it

timesuptim commented 9 years ago

Which of the ways to detect the end of a file are correct?

jvcleave commented 9 years ago

I use the callback system (onVideoLoop, etc). Keyframes also play a big part so making sure you have a keyframe every frame has made it more accurate for me. I use Apple Compressor as it seems to do this best.

Maigre commented 9 years ago

You could also try to use getCurrentFrame() and getTotalNumFrames() in your show() function to detect the end of the file. I add good result with those ones (see the implementation in the first message of this thread). But i don't know how different it might be from the onVideoLoop callback..

It can also allow you to preload the next media, before the current one reached his loop point. (might help the transition)

You could also try to use textured mode (it will play fullscreen too), since the frame count might be more accurate ? but that's a wild guess..

viniciolindo commented 7 years ago

hi i have the same issue and i discovered that the problem is in getcurrentframe() that return wrong value i'm usign non textured mode