GithubHelp home page GithubHelp logo

Comments (17)

tobiasebsen avatar tobiasebsen commented on June 3, 2024 1

Here is one of the files:
https://we.tl/jMYR1tckmN

The problem may be a combination of having multiple players - and running at low frame rate. At 12fps it buffers only 3 frames, which seems to under-run the cache at some frames. But I'm not sure - it's very difficult to debug this asynchronous stuff.

from ofxhapplayer.

bangnoise avatar bangnoise commented on June 3, 2024

Do the movies have audio?

from ofxhapplayer.

tobiasebsen avatar tobiasebsen commented on June 3, 2024

No. Only video track.

from ofxhapplayer.

bangnoise avatar bangnoise commented on June 3, 2024

Cheers - can you pull and try now?

from ofxhapplayer.

tobiasebsen avatar tobiasebsen commented on June 3, 2024

Didn't help.
The strange thing is that it's not increasing CPU usage. The frame rate of my entire ofApp just drops increasingly for each time i start the next player. I will try to narrow it down further...

from ofxhapplayer.

bangnoise avatar bangnoise commented on June 3, 2024

I can't reproduce this based on your description. One way to narrow it down would be to start with a new project and make it produce the same effect - you could then attach the project to this issue.

from ofxhapplayer.

tobiasebsen avatar tobiasebsen commented on June 3, 2024

So here is what I found out....

  • The drop in frame rate is due to increased time spent between ofApp::update() and ofApp::draw()
  • After some investigation I found out that the time is used by event calls to ofxHapPlayer::update(ofEventArgs & args). As much as over 30ms is used when a video is paused
  • Futher investigation revealed the sinner to be the call to _videoPackets.fetch(...) - and more precisely when it returns false (timeout)
  • Finally, looking at the ofxHap::LockingPacketCache::fetch(...) shows that it is probably looking for an AVPacket, but gets a timeout (default 30ms)

But, why the PacketCache cannot find the packet, I don't know.
Should it even be fetching when it is paused?

from ofxhapplayer.

tobiasebsen avatar tobiasebsen commented on June 3, 2024

It seems that the PacketCache does not contain any packet for the requested vidPosition. Maybe the Demuxer gets out of alignment with the Clock when pausing the playback? And perhaps my case is particularly prone to this condition because my videos run at 12fps ??

from ofxhapplayer.

bangnoise avatar bangnoise commented on June 3, 2024

Many thanks for the detailed investigation. 0.25 seconds of video should be read after load (which should be fine at 12 fps). I'll see if I can recreate the problem with a 12 fps video, and avoid having a player churn away indefinitely if there isn't a frame for any reason.

from ofxhapplayer.

tobiasebsen avatar tobiasebsen commented on June 3, 2024

Just to clarify: videos that have been loaded (but is not playing) does not have this problem. The missing frame occurs when the video playback is paused - perhaps at a point in time where no frame is available (in-between frames).

from ofxhapplayer.

tobiasebsen avatar tobiasebsen commented on June 3, 2024

One more thing: the packet-timeout also occur while playing - at the end of a looping video.

from ofxhapplayer.

bangnoise avatar bangnoise commented on June 3, 2024

Okay - your movies sound a little unusual, as generally one encodes an unbroken stream without gaps between frame times, but I will make changes so players only wait for the timeout when they can reasonably expect a frame may arrive.

from ofxhapplayer.

bangnoise avatar bangnoise commented on June 3, 2024

If you're able to share a small problematic movie, or give instructions to create one, then that would help me test.

from ofxhapplayer.

bangnoise avatar bangnoise commented on June 3, 2024

As well as the noted problem with the timeout on the main thread, this example eats CPU cycles as the audio thread spins hoping for missing audio samples.

from ofxhapplayer.

tobiasebsen avatar tobiasebsen commented on June 3, 2024

It looks like the timeout happens on the first few frames right after the video loops. This tells me that there is something wrong with the way the demuxer is told to read future frames at the end of the video.
It could be a problem with time ranges or perhaps the order of the demuxers actions (read/seek). Still looking further into this...

from ofxhapplayer.

bangnoise avatar bangnoise commented on June 3, 2024

The original problem is fixed, still to do, related to this issue/test clip:

  • don't wait for timeout when no frames are expected (eg if there's a gap in video or the demuxer has an error)
  • the audio track in this sample causes the audio thread to churn at 100% CPU usage

from ofxhapplayer.

tobiasebsen avatar tobiasebsen commented on June 3, 2024

Wow. Two lines of code was all it took. I've spent hours trying to find the problem. Looking forward to having the last two issues fixed. Thanks!

from ofxhapplayer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.