Arnavion / libjass

Renders ASS subs in the browser.
Apache License 2.0
174 stars 29 forks source link

\fad with a fadeout of 0 is treated as fading out for the duration of the line #111

Closed DoomTay closed 6 years ago

DoomTay commented 6 years ago

Example file:

[Script Info]
; Script generated by Aegisub 3.2.2
; http://www.aegisub.org/
Title: Fade Test
ScriptType: v4.00+
WrapStyle: 0
PlayResX: 720
PlayResY: 400
Language: English (US)

[V4+ Styles]
Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
Style: Main,Arial,30,&H00FFFFFF,&H0000FFFF,&H00000000,&H7F404040,0,0,0,0,100,100,0,0,1,2,1,2,30,30,30,0

[Events]
Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
Dialogue: 0,0:00:00.60,0:00:03.27,Main,Fader,0,0,0,,{\fad(160,0)}I fade into the eternal infinity

According to the docs, the second number being 0 should mean that the line will end with no fading out, and that's how Aegisub treats it. Libjass, however, will have the line fade immediately for the duration of the line.

Arnavion commented 6 years ago

Yes, a parameter of 0 causes two keyframes to be generated for the same completion percentage. Eg for your case:

@keyframes animation-0-0-0 {
    0.000% {
        opacity: 0;
    }
    5.993% {
        opacity: 1;
    }
    100.000% {
        opacity: 1;
    }
    100.000% {
        opacity: 0;
    }

}

Since there are two keyframes for 100%, the second overrides the former. So the opacity reaches 1 and immediately starts dropping back to 0.

As a workaround, you can use 0.001 or some smaller value instead of 0 so that both keyframes have different completion percentages.