Open brys0 opened 3 hours ago
Most anime video frame is 24 fps, while requestAnimationFrame
match the display refresh rate, most common is 60 fps.
Isn't requestAnimationFrame
better than requestVideoFrameCallback
?
And requestAnimationFrame
is only used for checking when a subtitle should display, not used for animations.
Animations (\t()
) is implemented with Web Animation API, which may be same as requestAnimationFrame
, but we have no way to change Web Animation API to use requestVideoFrameCallback
.
requestVideoFrameCallback() is meant to be more accurate in terms of getting a time on the video, chrome's currentTime is purposely inaccurate to avoid fingerprinting, but requestVideoFrameCallback includes metadata.mediaTime, which should be more frame perfect. At least in my testing it appears to be more accurate then just using requestAnimationFrame(), but your mileage may vary.
Oh, I got your point.
media.currentTime
precision might be 100ms, only 10 fps, requestVideoFrameCallback
is a better than it.
Precisely, sorry if I didn't make myself very clear, but yes, it should be a fair bit more accurate then using requestAnimationFrame for displaying subtitles at the right time.
Chrome and other browsers now offer the use of requestVideoFrameCallback() which will allow a callback function to be run on every video frame. This should be more consistent then something like requestAnimationFrame. In my experience when dealing with sync issues using requestVideoFrameCallback() helped greatly for a move smooth experience.