Reset merge output on clear

This commit is contained in:
Stu Leak 2025-12-24 01:38:57 -05:00
parent a7b3452312
commit a91a3e60d7

26
main.go
View File

@ -2937,10 +2937,6 @@ func (s *appState) showMergeView() {
addFiles([]string{path}) addFiles([]string{path})
}, s.window) }, s.window)
}) })
clearBtn := widget.NewButton("Clear", func() {
s.mergeClips = nil
buildList()
})
// Helper to get file extension for format // Helper to get file extension for format
getExtForFormat := func(format string) string { getExtForFormat := func(format string) string {
@ -2998,6 +2994,13 @@ func (s *appState) showMergeView() {
s.mergeOutput = val s.mergeOutput = val
} }
clearBtn := widget.NewButton("Clear", func() {
s.mergeClips = nil
s.mergeOutput = ""
outputEntry.SetText("")
buildList()
})
// Helper to update output path extension (requires outputEntry to exist) // Helper to update output path extension (requires outputEntry to exist)
updateOutputExt := func() { updateOutputExt := func() {
if s.mergeOutput == "" { if s.mergeOutput == "" {
@ -8999,6 +9002,7 @@ type playSession struct {
audioTime atomic.Value // float64 - Audio master clock time audioTime atomic.Value // float64 - Audio master clock time
videoTime float64 // Last video frame time videoTime float64 // Last video frame time
syncOffset float64 // A/V sync offset for adjustment syncOffset float64 // A/V sync offset for adjustment
audioActive atomic.Bool // Whether audio stream is running
} }
var audioCtxGlobal struct { var audioCtxGlobal struct {
@ -9304,24 +9308,32 @@ func (p *playSession) runVideo(offset float64) {
// Video is way ahead of audio (>3 frames) - wait longer // Video is way ahead of audio (>3 frames) - wait longer
time.Sleep(frameDur * 2) time.Sleep(frameDur * 2)
if p.frameN%30 == 0 { if p.frameN%30 == 0 {
logging.Debug(logging.CatFFMPEG, "video ahead %.0fms, slowing down", -avDiff*1000) logging.Debug(logging.CatFFMPEG, "A/V sync: video ahead %.0fms, slowing down", -avDiff*1000)
} }
} else if avDiff > frameDur.Seconds()*3 { } else if avDiff > frameDur.Seconds()*3 {
// Video is way behind audio (>3 frames) - drop frame // Video is way behind audio (>3 frames) - drop frame
if p.frameN%30 == 0 { if p.frameN%30 == 0 {
logging.Debug(logging.CatFFMPEG, "video behind %.0fms, dropping frame", avDiff*1000) logging.Debug(logging.CatFFMPEG, "A/V sync: video behind %.0fms, dropping frame", avDiff*1000)
} }
p.frameN++ p.frameN++
p.current = offset + (float64(p.frameN) / p.fps) p.current = offset + (float64(p.frameN) / p.fps)
continue continue
} else if avDiff > frameDur.Seconds() { } else if avDiff > frameDur.Seconds() {
// Video slightly behind - speed up (skip sleep) // Video slightly behind - speed up (skip sleep)
// No sleep, render frame immediately if p.frameN%60 == 0 {
logging.Debug(logging.CatFFMPEG, "A/V sync: video slightly behind %.0fms, catching up", avDiff*1000)
}
} else if avDiff < -frameDur.Seconds() { } else if avDiff < -frameDur.Seconds() {
// Video slightly ahead - slow down // Video slightly ahead - slow down
if p.frameN%60 == 0 {
logging.Debug(logging.CatFFMPEG, "A/V sync: video slightly ahead %.0fms, waiting", -avDiff*1000)
}
time.Sleep(frameDur + time.Duration(math.Abs(avDiff)*float64(time.Second))) time.Sleep(frameDur + time.Duration(math.Abs(avDiff)*float64(time.Second)))
} else { } else {
// In sync - normal timing // In sync - normal timing
if p.frameN%180 == 0 && p.frameN > 0 {
logging.Debug(logging.CatFFMPEG, "A/V sync: good sync (diff %.1fms)", avDiff*1000)
}
time.Sleep(frameDur) time.Sleep(frameDur)
} }
// Allocate a fresh frame to avoid concurrent texture reuse issues. // Allocate a fresh frame to avoid concurrent texture reuse issues.