mbebenita / Broadway

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

Regulating FPS/non-smooth playback #61

Open yarontorbaty opened 9 years ago

yarontorbaty commented 9 years ago

At times the video moves either too fast or too slow, In order to provide a smooth user experience displaying frames should be done in a constant interval (1000/FPS)

soliton4 commented 9 years ago

good idea i am thinking about creating a "real" player supporting not only broadway.js but different video decoders. at the time i see broadway.js only as a decoder.

alastaircoote commented 9 years ago

Yes - I was looking for a way to do this myself, but the onPictureDecoded only returns buffer, width and height. If it also returned the timestamp of the frame that would be ideal - and would also (I think?) allow you to pre-render some frames and increase FPS. That might negatively impact memory usage, though.

soliton4 commented 9 years ago

@alastaircoote do you know if the timestamp information is even provided in the h264 stream data?

alastaircoote commented 9 years ago

@soliton4 I don't know. If FPS is available in the header you could calculate it that way, but I don't know much about decoding that data/if it's even possible.

mbebenita commented 9 years ago

Timestamp information is available in the container format, not in the raw stream. Broadway includes an mp4 parser, you should be able to figure out the timestamp using that. Read the mp4 spec, (or the qucktime spec from which it is derived, the Apple docs are better).

soliton4 commented 9 years ago

i created the foundation for a frame buffer here: https://github.com/mbebenita/Broadway/commit/0324cb3a319441bc04d3e132a05e77fdec978deb

Zaithe commented 8 years ago

How would you set the fps with your code?