yichengchen / ATV-Bilibili-demo

BiliBili Client Demo for Apple TV (tvOS)
GNU General Public License v2.0
2.33k stars 437 forks source link

Danmu mask goes out of sync with the video due to wrong data from API #45

Closed qsz13 closed 1 year ago

qsz13 commented 1 year ago

The danmu mask in BMaskProvider doesn't match for some video, such as https://www.bilibili.com/video/BV11x4y1g7yw/ There's a delay for the mask, and the delay increases as we watch the video. Here's a screenshot using the red mask layer.

image

The issue is that the API returned an FPS of 29 for the mask data, while the actual FPS is about 30: https://api.bilibili.com/x/player/v2?aid=990156715&cid=961806418

"dm_mask":{"cid":961806418,"plat":0,"fps":29,"time":0,"mask_url":"//upos-sz-staticcos-cmask.bilivideo.com/cmaskboss/961806418_29_0.webmask?trid=3c23696d105148cf8ef19b8a1c1ee4ccB\u0026orderid=0,1\u0026logo=00000000"}

The length of the video is 1512490 milliseconds, and the number of mask frames we get is 45283, so that's 45283/1512 = 29.949.

The issue doesn't happen on bilibili web, so I suspect that they have a different implementation that doesn't rely on the API data.

I'll see if I can come up with a fix. BTW, this is an awesome project!