Made precise ASS timings a setting

This commit is contained in:
DataHoarder 2023-11-29 02:35:10 +01:00
parent f9a29ab800
commit 52efe64f40
Signed by: DataHoarder
SSH key fingerprint: SHA256:OLTRf6Fl87G52SiR7sWLGNzlJt4WOX+tfI2yxo0z7xk
3 changed files with 12 additions and 4 deletions

View file

@ -4,6 +4,7 @@ import (
"fmt"
"git.gammaspectra.live/WeebDataHoarder/swf2ass-go/ass/tag"
asstime "git.gammaspectra.live/WeebDataHoarder/swf2ass-go/ass/time"
"git.gammaspectra.live/WeebDataHoarder/swf2ass-go/settings"
"git.gammaspectra.live/WeebDataHoarder/swf2ass-go/types"
"git.gammaspectra.live/WeebDataHoarder/swf2ass-go/types/shapes"
"regexp"
@ -123,10 +124,12 @@ func (l *EventLine) Encode(frameDuration time.Duration) string {
text := make([]string, 0, 1+len(l.Tags))
eventTimeTags := eventTime.Encode()
if settings.GlobalSettings.ASSPreciseTiming {
eventTimeTags := eventTime.Encode()
if len(eventTimeTags) > 0 {
text = append(text, eventTimeTags)
if len(eventTimeTags) > 0 {
text = append(text, eventTimeTags)
}
}
for _, t := range l.Tags {

View file

@ -118,7 +118,6 @@ func (t EventTime) GetDurationFromEndOffset(frameOffset int64) time.Duration {
func (t EventTime) Encode() string {
if t.Start.AdjustedMillisecondError != 0 || t.End.AdjustedMillisecondError != 0 {
//Adjust frame precision exactly to frame boundaries. This is necessary due to low ASS timing precision
//TODO: Maybe use fade?
frameStartTime := t.GetDurationFromStartOffset(0).Milliseconds()
frameEndTime := t.GetDurationFromEndOffset(0).Milliseconds()
//TODO: maybe needs to be -1?

View file

@ -8,6 +8,11 @@ type Settings struct {
// Note that at high ASSDrawingScale >= 5 this will be brought down to 0 regardless
ASSDrawingPrecision int
// ASSPreciseTiming Enables precise timing via \fade transitions for each event.
// libass is only precise to 1/100th of a second, causing issues with higher framerate content
// Additionally extra \err annotations will be placed to note the current error adjusted
ASSPreciseTiming bool
// VideoRateMultiplier Adjusts the viewport scale. All operations and transforms will be adjusted accordingly
// For example, VideoScaleMultiplier = 2 will make a 640x480 viewport become 1280x960
VideoScaleMultiplier float64
@ -49,6 +54,7 @@ const DefaultASSDrawingPrecision = 2
var GlobalSettings = Settings{
ASSDrawingScale: DefaultASSDrawingScale,
ASSDrawingPrecision: DefaultASSDrawingPrecision,
ASSPreciseTiming: true,
VideoScaleMultiplier: 1,
VideoRateMultiplier: 1,