Harden remux timestamp handling
This commit is contained in:
parent
1491d0b0c0
commit
de70448897
18
main.go
18
main.go
|
|
@ -3689,6 +3689,10 @@ func (s *appState) executeConvertJob(ctx context.Context, job *queue.Job, progre
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
isDVD := selectedFormat.Ext == ".mpg"
|
isDVD := selectedFormat.Ext == ".mpg"
|
||||||
|
remux := strings.EqualFold(selectedFormat.VideoCodec, "copy")
|
||||||
|
if vc, ok := cfg["videoCodec"].(string); ok && strings.EqualFold(vc, "Copy") {
|
||||||
|
remux = true
|
||||||
|
}
|
||||||
|
|
||||||
// DVD presets: enforce compliant codecs and audio settings
|
// DVD presets: enforce compliant codecs and audio settings
|
||||||
// Note: We do NOT force resolution - user can choose Source or specific resolution
|
// Note: We do NOT force resolution - user can choose Source or specific resolution
|
||||||
|
|
@ -3712,6 +3716,9 @@ func (s *appState) executeConvertJob(ctx context.Context, job *queue.Job, progre
|
||||||
cfg["pixelFormat"] = "yuv420p"
|
cfg["pixelFormat"] = "yuv420p"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if remux {
|
||||||
|
args = append(args, "-fflags", "+genpts")
|
||||||
|
}
|
||||||
args = append(args, "-i", inputPath)
|
args = append(args, "-i", inputPath)
|
||||||
|
|
||||||
// Add cover art if available
|
// Add cover art if available
|
||||||
|
|
@ -3747,10 +3754,6 @@ func (s *appState) executeConvertJob(ctx context.Context, job *queue.Job, progre
|
||||||
}
|
}
|
||||||
|
|
||||||
// Video filters
|
// Video filters
|
||||||
remux := strings.EqualFold(selectedFormat.VideoCodec, "copy")
|
|
||||||
if vc, ok := cfg["videoCodec"].(string); ok && strings.EqualFold(vc, "Copy") {
|
|
||||||
remux = true
|
|
||||||
}
|
|
||||||
var vf []string
|
var vf []string
|
||||||
if !remux {
|
if !remux {
|
||||||
// Deinterlacing
|
// Deinterlacing
|
||||||
|
|
@ -3839,8 +3842,6 @@ func (s *appState) executeConvertJob(ctx context.Context, job *queue.Job, progre
|
||||||
vf = append(vf, scaleFilter)
|
vf = append(vf, scaleFilter)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Aspect ratio conversion
|
// Aspect ratio conversion
|
||||||
sourceWidth, _ := cfg["sourceWidth"].(int)
|
sourceWidth, _ := cfg["sourceWidth"].(int)
|
||||||
sourceHeight, _ := cfg["sourceHeight"].(int)
|
sourceHeight, _ := cfg["sourceHeight"].(int)
|
||||||
|
|
@ -3901,6 +3902,7 @@ func (s *appState) executeConvertJob(ctx context.Context, job *queue.Job, progre
|
||||||
if len(vf) > 0 {
|
if len(vf) > 0 {
|
||||||
args = append(args, "-vf", strings.Join(vf, ","))
|
args = append(args, "-vf", strings.Join(vf, ","))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Video codec
|
// Video codec
|
||||||
videoCodec, _ := cfg["videoCodec"].(string)
|
videoCodec, _ := cfg["videoCodec"].(string)
|
||||||
|
|
@ -4122,6 +4124,7 @@ func (s *appState) executeConvertJob(ctx context.Context, job *queue.Job, progre
|
||||||
// DVD-specific parameters are set manually in the video codec section below.
|
// DVD-specific parameters are set manually in the video codec section below.
|
||||||
|
|
||||||
// Fix VFR/desync issues - regenerate timestamps and enforce CFR
|
// Fix VFR/desync issues - regenerate timestamps and enforce CFR
|
||||||
|
if !remux {
|
||||||
args = append(args, "-fflags", "+genpts")
|
args = append(args, "-fflags", "+genpts")
|
||||||
frameRateStr, _ := cfg["frameRate"].(string)
|
frameRateStr, _ := cfg["frameRate"].(string)
|
||||||
sourceDuration, _ := cfg["sourceDuration"].(float64)
|
sourceDuration, _ := cfg["sourceDuration"].(float64)
|
||||||
|
|
@ -4131,6 +4134,9 @@ func (s *appState) executeConvertJob(ctx context.Context, job *queue.Job, progre
|
||||||
// Calculate approximate source frame rate if available
|
// Calculate approximate source frame rate if available
|
||||||
args = append(args, "-r", "30") // Safe default
|
args = append(args, "-r", "30") // Safe default
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
args = append(args, "-avoid_negative_ts", "make_zero")
|
||||||
|
}
|
||||||
|
|
||||||
// Progress feed
|
// Progress feed
|
||||||
args = append(args, "-progress", "pipe:1", "-nostats")
|
args = append(args, "-progress", "pipe:1", "-nostats")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user