0

I'm developing an application, where it is necessary that a video is exactly at the playback position, where it should be if there were no lack of data, even if there is such.

eg. video.currentTime == timeSinceTheVideoWasStarted

The tolerance is about 0.1s and it is also possible to increase or decrease the playback speed a little bit to match the time. All the media data is cached in a ObjectURL, but the decoding may be slow, because the application is very computation intensive.

I thought about setting the correct playback time at the playing event, but when data is present again and the currentTime is updated this will case the next lack of data.

I'm using the video element as a video texture source in WebGL as described here.

The fixed points are that the video is downloaded from a local server (for example http://localhost:8000/assets/foo.mp4) and displayed on WebGL. Your Soulutions may include different video decodings than the native <video>.

To reproduce it: Do something CPU intensive and play a video - it won't be smooth. (As you would expect)

I hope you can help me.

EDIT:

  1. The main thing I worry about is the situation, I aleady experienced many times while nornaly working, likely windows itself is doing some sync disk IO, which causes everything to wait, even the mouse cursor...

  2. I'll try it out to compensate small time differences (< 1s) by the playback speed

hansSchall
  • 11
  • 3
  • Are you pausing the video somehow? It should be enough to just play the ` – VC.One Aug 03 '22 at 12:42
  • **(1)** See if [this video capture setup](https://stackoverflow.com/a/68037735/2057709) works better for you to achieve `video.currentTime == timeSinceTheVideoWasStarted` even if you do heavy GPU processing... It's simple, don't pause the video and you will have the state of `currentTime` not being wrong or behind. **(2)** I don't understand _"When data is present again and the currentTime is updated this will cause the next lack of data."_ sounds like a design issue. Is "data" meaning "pixels" here (frame capture)? I did not test MDN code, show us **how to recreate your problem by code**. – VC.One Aug 03 '22 at 12:52
  • To reproduce it: Do something CPU intensive and play a video - it won't be smooth. @ 2.2: "data" is meaning the decoded video @ 2.1 I'll take a look at this – hansSchall Aug 06 '22 at 14:51
  • 1
    Solved it by writing a small libary: https://github.com/hansSchall/compensate-playback-time – hansSchall Aug 07 '22 at 11:23

0 Answers0