mbebenita / Broadway

A JavaScript H.264 decoder.
Other
2.73k stars 424 forks source link

Synchronization with external clock #93

Open zavitax opened 8 years ago

zavitax commented 8 years ago

A great benefit to the project would be the ability to synchronize the frames to an external clock, i.e. a time-based clock, or an audio file.

Currently there are no facilities available to do that, and frames are fed at the rate at which they are decoded which results in the video playing back too fast or too slow and never at the speed which was initially intended.

I believe this feature would really send it to the stars.

mbebenita commented 8 years ago

That's the job of the container format. I agree with you that it would be useful but it's somewhat outside of the scope of this particular library. The code does include a rudimentary .mp4 parser that can be used to pull out some of the timing information and do your own synchronization.

zavitax commented 8 years ago

I might be missing something.

What would you suggest to be the proper way to decode X frames ahead (and get the decoded images), and pause decoding when the forward buffer is full, and resume when it's below its undefill threshold?