Arnavion / libjass

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

Does libjass have any function to change timing on a fly? #90

Open XCanG opened 7 years ago

XCanG commented 7 years ago

The thing is I know website where libjass is used, also it have video and subtitles for it, but that subtitles are not syncronized (need add about +2 seconds to every line), I can't change any website resourses, but, will be great if I can call function from libjass what will automatically retime every line, something like assObject.setTimeShifting(2000); (+2000 ms, may be negative).

I check API and don't find function, so it looks like it not exist. Would be great having something like that in this library.

Arnavion commented 7 years ago

There's no public API for it. One workaround is that once you have the ASS object, you can iterate over each Dialogue in ass.dialogues and change its _start and _end private properties.

var ass = libjass.ASS.fromUrl(...).then(ass => { shift(ass, 2.000); return ass; });

function shift(ass, time) {
    for (const dialogue of ass.dialogues) {
        dialogue._start += time;
        dialogue._end += time;
    }
}
XCanG commented 7 years ago

Will be something like that added in API or not?