BanchouBoo / mpv-youtube-chat

mpv lua script to overlay youtube chat on top of a video using yt-dlp
MIT License
40 stars 3 forks source link

[Feature Request] support downloaded videos? + more #4

Open BhaturaGuy opened 1 year ago

BhaturaGuy commented 1 year ago
BanchouBoo commented 1 year ago

Videos downloaded with yt-dlp have PURL and it contains video link. So it can just look for that to download live chat, also if a video already has livechat embedded in it then use it?

If you try to load a live chat without manually passing in a file name (script-message load-chat) and it's from a local video file, it will look for a live chat with the same name as the video in the same directory as the video (e.g. file.mp4 will look for file.live_chat.json), so you can just download the live chat with the video when you download via yt-dlp.

Insert line breaks if characters reach certain threshold so that spam messages don't take entire horizontal screen.

I do have a limit for line length but it's flexible so it only breaks at word boundaries, I guess this would be a problem if a message was really long and had no spaces, I'll think about how to approach it

Custom font support + colors, borders config

Done, update to the latest commit. Also changed color format option to author-color. Wasn't able to get emoji to work when changing the font though, let me know if you get that working.

BhaturaGuy commented 1 year ago

Wasn't able to get emoji to work when changing the font though, let me know if you get that working.

Nerd fonts directly doesn't support emoji but there is a long way to patching fonts with Noto Color Emoji font to support them. A second method is to use Noto Color Emoji as the default font for emoji, since live_chat.json does have text, emoji, emojiId it should be somehow possible to use different font for them? text can be configurable by the user and emoji font would be Noto Color Emoji.

But for some reason I still can't see the emojis in mpv even after setting font=Noto Color Emoji

Though any font manager shows it should support emoji image

Maybe this can be used as a reference https://pypi.org/project/softchat/

BanchouBoo commented 1 year ago

I definitely could make a seperate font setting for emoji pretty easily, but I'm not sure to what extent mpv supports emoji. It seems libass doesn't support colored emoji (https://github.com/libass/libass/issues/381), supposedly monochrome emoji fonts should work, haven't tested myself yet. If you test one, let me know the results, if monochrome emoji fonts work then I'll add a setting for emoji font as well.

mrfragger commented 7 months ago

I tried tons of workarounds. EmojiOne, Nerd Font patched ones, Google's Noto Emoji (25% are monochrome) and all don't work and display the boxes for colored emoji. Yes monochrome emoji show just fine on most any font.

Screenshot 2024-01-20 at 1 10 09 PM

Only font that doesn't show boxes is Twitter Color Emoji "Regular B&W outline emoji are included for backwards/fallback compatibility." https://github.com/13rac1/twemoji-color-font/releases opts['font'] = 'Twitter Color Emoji'

Screenshot 2024-01-20 at 1 12 12 PM

In the end though it might just be better to use a better font though for readibility and just ignore the boxes.

not worth to ("emojiId": ").*?(",) / $1$2replace them each time either.

mrfragger commented 3 weeks ago

emojis

Now using mpv 0.38 and it sure seems to be getting almost all emojis. Maybe it just has so many B&W for the colored ones. I tried nerd font..that was a no go. Also tried Noto Emoji again and the spacing between letters was way off. Only downside to using this Twitter Color Emoji is it's 14MB.