AniDevTwitter/animeopenings

Handle ASS on multiple lines

Closed this issue · 15 comments

Hello.

I installed AnimeOpenings on my server with a karaoke database we run. Setting it up was pretty easy and we generated a names.php from our database just fine. Thank you lots for making this.

I have several little issues though related to subtitles, I'll post them and this is the first one.

On videos where there is supposed to be several subtitles lines at the same time (the lyrics are quite fast) lyrics are overlapping each other. Would it be possible to handle multiple lines when one isn't completed yet?

Sample video : http://live.karaokes.moe/?video=%20Opening%20-JAP%20-%20DuckTales%20%282017%29%20

Here's the ASS file :
https://lab.shelter.moe/karaokemugen/karaokebase/blob/master/lyrics/JAP%20-%20DuckTales%20(2017)%20-%20OP%20-%20DuckTales.ass

Thanks for reading this :)

Well, apparently links don't work because the names are too long >.> But loading the .ass file I provided on any video should do the trick anyway.

Would it be possible to handle multiple lines when one isn't completed yet?

Maybe. This is actually due to a currently unsupported feature - "Collisions". Basically, if two subs are placed in the same spot, one of them is supposed to be moved above the other. The hard part is figuring out when two subs overlap [1]. I did actually think of a possible naive solution a few days ago, but I don't know when I'll have time to try using it. Since that file actually isn't very long, it would be easier to manually change it for the time being.

[1] Or rather, figuring out if two overlap isn't hard, but figuring out if any two lines of any of the potentially hundreds of lines in the script overlap, and doing that every 16ms, is hard.

Isn't it possible to detect this when loading the ASS script? It won't change during runtime, so maybe figuring out in advance on which line putting which dialogue event could be doable.

Dialogue: 0,0:00:00.78,0:00:05.56,1920X1080,,0,0,0,fx,{\fade(255,0,255,0,850,4680,4780)\k100}{\k100}{\k29}ki{\k36}ra{\k36}ku {\k30}ni {\k58}tsu{\k22}ppa{\k23}shi{\k24}re{\k10}
Dialogue: 0,0:00:03.44,0:00:08.04,1920X1080,,0,0,0,fx,{\fade(255,0,255,0,850,4500,4600)\k100}{\k100}{\k49}i{\k76}tsu{\k49}de{\k66}mo{\k10}

These two lines for example overlap since line 1's end time is after line 2's beginning time.

It might be a bit too simple though and there could be caveats I can't seem to think about right now...

I think most of your subtitles are on the top line, so commit 59caaf2 should I think handle them. There's still a lot of optimizations and improvements I can do, but this should get you started.

I just git pulled, and it doesn't seem to solve anything... Plus now the first syllabe of each line doesn't get colored anymore :)

(╯°□°)╯︵ ┻━┻

I'm not seeing the first syllable issue though.

Okay, now it should work.

Not terribly better :p

I don't get the syllabe issue anymore but it's hard to tell as as soon as the second line begins, the subtitle layout suddenly gets reduced and it produces garbage and stops rendering anything new

firefox_2018-08-23_23-55-01

firefox_2018-08-23_23-57-22

I enabled Stylus again to show you how I see that it resized the part where it draws subtitles.

Alright, that issue should be fixed now.

The first-syllable bug is a different issue, since it appears before any collisions happen.

Yep, I'll make a separate issue for that later.

Though, I git pulled and it doesn't seem to solve anything regarding any collisions though. Example : https://live.karaokes.moe/?video=%20Ending%20-JAP%20-%20Boku%20no%20Kanojo%20ga%20Majimesugiru%20Sho-bitch%20na%20Ken%20

Subs are still on top of each other instead of being on different line when there are two lines at the same time on screen.

Alright, it's actually definitely working now. https://openings.moe/Yay295/test/?video=Opening1-AokiHaganeNoArpeggio%3AArsNova

I think I might know what caused the other issue too, but I haven't checked yet.

Yeah, it works perfect now! Thank you so much!

I noticed another weird behaviour unrelated to this, I'll open another issue to show you.

I'll close this one in the meantime. Should I open one for the first syllabe thing?

Yes please.