rkscv / danmaku

Danmaku plugin for mpv powered by dandanplay API
GNU General Public License v3.0
9 stars 0 forks source link

Add script-message to allow adjusting danmaku delay #8

Closed dyphire closed 1 month ago

dyphire commented 1 month ago

It can be script-message danmaku-shift {ms}, This will allow it to be used via commands (like key script-message-to danmaku danmaku-shift 1000) or called by other scripts , adding extensibility.

rkscv commented 1 month ago

Since the dandanplay API includes the shift parameter in its return value, I'd like to use it first, which is also easier to implement than adding script-message. If the server side doesn't handle all the videos that require danmaku shifting, then let users do it on their own.

I can't find a video that requires danmaku shifting. You may execute head -c 16M video.mkv | md5sum, then enter the hash value in https://api.dandanplay.net/swagger/ui/index#!/Match/Match_MatchAsync to get the matching episodes (fileName is not really necessary here), and measure the length of the extra content at the beginning of the video to see what the unit of the shift parameter is.

dyphire commented 1 month ago

If the server side doesn't handle all the videos that require danmaku shifting, then let users do it on their own.

The script-message is what is used for manual adjustments.

I can't find a video that requires danmaku shifting.

On the bilibili site, every episode of anime produced by bilibili has an extra 10 seconds or so of bilibili credits, such as 炎炎消防队.

rkscv commented 1 month ago

If the server side doesn't handle all the videos that require danmaku shifting, then let users do it on their own.

The script-message is what is used for manual adjustments.

I mean we don't need script-message if there is no need for manual adjustment.

Download speed of 炎炎消防队 is 0. I picked 疑似ハーレム from bangumi for testing. The server doesn't specify the shift parameter for videos from bilibili or videos from other sites, so we do need to adjust it manually. For this anime, videos from baha also have bilibili credits, and danmaku from baha and danmaku from bilibili are not being shifted on the server side, that's fine, but I'm not sure if other videos are being handled correctly as well.

Try e601cd6.

dyphire commented 1 month ago

Try e601cd6.

It works.

For this anime, videos from baha also have bilibili credits, and danmaku from baha and danmaku from bilibili are not being shifted on the server side, that's fine, but I'm not sure if other videos are being handled correctly as well.

This actually exposes the problem with dandanplay. It aggregates the various danmaku sources, which is supposed to be a plus, but if the video durations corresponding to the danmaku from bilibili and baha don't match up (more credits or content deletions) it can lead to the user not being able to get the correct available danmaku.

I'm not sure if dandanplay has an api available to exclude a particular source of danmaku. If not perhaps this needs to be accomplished through a keyword blocking feature.

rkscv commented 1 month ago

I'm not sure if dandanplay has an api available to exclude a particular source of danmaku

No out-of-the-box API for this. But it's easy to implement on the client side, although some docs are missing. I've sent an email to the author of dandanplay to ask about this and the timeline issue of the danmaku.

rkscv commented 1 month ago

According to the author's reply, the dandanplay server doesn't make any special adjustments to the timeline of danmaku. The shift parameter is indeed used to adjust the timeline of danmaku, but this value depends on the users' upload, and most users don't adjust the timeline of danmaku.

Since fewer users upload the shift parameter, I don't think this parameter is authoritative, and it's rarely specified, let's leave it unimplemented for now.