forked from Leak_Technologies/VideoTools
Track direct conversion progress in stats and queue
This commit is contained in:
parent
d71a50eff1
commit
58773c509c
66
main.go
66
main.go
|
|
@ -154,33 +154,34 @@ func (c convertConfig) CoverLabel() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
type appState struct {
|
type appState struct {
|
||||||
window fyne.Window
|
window fyne.Window
|
||||||
active string
|
active string
|
||||||
source *videoSource
|
source *videoSource
|
||||||
loadedVideos []*videoSource // Multiple loaded videos for navigation
|
loadedVideos []*videoSource // Multiple loaded videos for navigation
|
||||||
currentIndex int // Current video index in loadedVideos
|
currentIndex int // Current video index in loadedVideos
|
||||||
anim *previewAnimator
|
anim *previewAnimator
|
||||||
convert convertConfig
|
convert convertConfig
|
||||||
currentFrame string
|
currentFrame string
|
||||||
player player.Controller
|
player player.Controller
|
||||||
playerReady bool
|
playerReady bool
|
||||||
playerVolume float64
|
playerVolume float64
|
||||||
playerMuted bool
|
playerMuted bool
|
||||||
lastVolume float64
|
lastVolume float64
|
||||||
playerPaused bool
|
playerPaused bool
|
||||||
playerPos float64
|
playerPos float64
|
||||||
playerLast time.Time
|
playerLast time.Time
|
||||||
progressQuit chan struct{}
|
progressQuit chan struct{}
|
||||||
convertCancel context.CancelFunc
|
convertCancel context.CancelFunc
|
||||||
playerSurf *playerSurface
|
playerSurf *playerSurface
|
||||||
convertBusy bool
|
convertBusy bool
|
||||||
convertStatus string
|
convertStatus string
|
||||||
playSess *playSession
|
convertProgress float64
|
||||||
jobQueue *queue.Queue
|
playSess *playSession
|
||||||
statsBar *ui.ConversionStatsBar
|
jobQueue *queue.Queue
|
||||||
queueBtn *widget.Button
|
statsBar *ui.ConversionStatsBar
|
||||||
queueScroll *container.Scroll
|
queueBtn *widget.Button
|
||||||
queueOffset fyne.Position
|
queueScroll *container.Scroll
|
||||||
|
queueOffset fyne.Position
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *appState) stopPreview() {
|
func (s *appState) stopPreview() {
|
||||||
|
|
@ -213,7 +214,7 @@ func (s *appState) updateStatsBar() {
|
||||||
// Reflect direct conversion as an active job in the stats bar
|
// Reflect direct conversion as an active job in the stats bar
|
||||||
running = 1
|
running = 1
|
||||||
jobTitle = fmt.Sprintf("Direct convert: %s", filepath.Base(s.source.Path))
|
jobTitle = fmt.Sprintf("Direct convert: %s", filepath.Base(s.source.Path))
|
||||||
progress = 0
|
progress = s.convertProgress
|
||||||
}
|
}
|
||||||
|
|
||||||
s.statsBar.UpdateStats(running, pending, completed, failed, progress, jobTitle)
|
s.statsBar.UpdateStats(running, pending, completed, failed, progress, jobTitle)
|
||||||
|
|
@ -451,7 +452,7 @@ func (s *appState) refreshQueueView() {
|
||||||
Status: queue.JobStatusRunning,
|
Status: queue.JobStatusRunning,
|
||||||
Title: fmt.Sprintf("Direct convert: %s", filepath.Base(s.source.Path)),
|
Title: fmt.Sprintf("Direct convert: %s", filepath.Base(s.source.Path)),
|
||||||
Description: fmt.Sprintf("Output: %s", s.convert.OutputFile()),
|
Description: fmt.Sprintf("Output: %s", s.convert.OutputFile()),
|
||||||
Progress: 0,
|
Progress: s.convertProgress,
|
||||||
}}, jobs...)
|
}}, jobs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3671,6 +3672,7 @@ func (s *appState) startConvert(status *widget.Label, btn, cancelBtn *widget.But
|
||||||
|
|
||||||
logging.Debug(logging.CatFFMPEG, "convert command: ffmpeg %s", strings.Join(args, " "))
|
logging.Debug(logging.CatFFMPEG, "convert command: ffmpeg %s", strings.Join(args, " "))
|
||||||
s.convertBusy = true
|
s.convertBusy = true
|
||||||
|
s.convertProgress = 0
|
||||||
setStatus("Preparing conversion…")
|
setStatus("Preparing conversion…")
|
||||||
// Widget states will be updated by the UI refresh ticker
|
// Widget states will be updated by the UI refresh ticker
|
||||||
|
|
||||||
|
|
@ -3739,6 +3741,7 @@ func (s *appState) startConvert(status *widget.Label, btn, cancelBtn *widget.But
|
||||||
}
|
}
|
||||||
lbl := fmt.Sprintf("Converting… %.0f%% | elapsed %s | ETA %s | %.2fx", pct, formatShortDuration(elapsedWall), etaOrDash(eta), speed)
|
lbl := fmt.Sprintf("Converting… %.0f%% | elapsed %s | ETA %s | %.2fx", pct, formatShortDuration(elapsedWall), etaOrDash(eta), speed)
|
||||||
fyne.CurrentApp().Driver().DoFromGoroutine(func() {
|
fyne.CurrentApp().Driver().DoFromGoroutine(func() {
|
||||||
|
s.convertProgress = pct
|
||||||
setStatus(lbl)
|
setStatus(lbl)
|
||||||
}, false)
|
}, false)
|
||||||
}
|
}
|
||||||
|
|
@ -3754,6 +3757,7 @@ func (s *appState) startConvert(status *widget.Label, btn, cancelBtn *widget.But
|
||||||
fyne.CurrentApp().Driver().DoFromGoroutine(func() {
|
fyne.CurrentApp().Driver().DoFromGoroutine(func() {
|
||||||
s.showErrorWithCopy("Conversion Failed", fmt.Errorf("convert failed: %w", err))
|
s.showErrorWithCopy("Conversion Failed", fmt.Errorf("convert failed: %w", err))
|
||||||
s.convertBusy = false
|
s.convertBusy = false
|
||||||
|
s.convertProgress = 0
|
||||||
setStatus("Failed")
|
setStatus("Failed")
|
||||||
}, false)
|
}, false)
|
||||||
s.convertCancel = nil
|
s.convertCancel = nil
|
||||||
|
|
@ -3767,6 +3771,7 @@ func (s *appState) startConvert(status *widget.Label, btn, cancelBtn *widget.But
|
||||||
logging.Debug(logging.CatFFMPEG, "convert cancelled")
|
logging.Debug(logging.CatFFMPEG, "convert cancelled")
|
||||||
fyne.CurrentApp().Driver().DoFromGoroutine(func() {
|
fyne.CurrentApp().Driver().DoFromGoroutine(func() {
|
||||||
s.convertBusy = false
|
s.convertBusy = false
|
||||||
|
s.convertProgress = 0
|
||||||
setStatus("Cancelled")
|
setStatus("Cancelled")
|
||||||
}, false)
|
}, false)
|
||||||
s.convertCancel = nil
|
s.convertCancel = nil
|
||||||
|
|
@ -3776,6 +3781,7 @@ func (s *appState) startConvert(status *widget.Label, btn, cancelBtn *widget.But
|
||||||
fyne.CurrentApp().Driver().DoFromGoroutine(func() {
|
fyne.CurrentApp().Driver().DoFromGoroutine(func() {
|
||||||
s.showErrorWithCopy("Conversion Failed", fmt.Errorf("convert failed: %w", err))
|
s.showErrorWithCopy("Conversion Failed", fmt.Errorf("convert failed: %w", err))
|
||||||
s.convertBusy = false
|
s.convertBusy = false
|
||||||
|
s.convertProgress = 0
|
||||||
setStatus("Failed")
|
setStatus("Failed")
|
||||||
}, false)
|
}, false)
|
||||||
s.convertCancel = nil
|
s.convertCancel = nil
|
||||||
|
|
@ -3789,6 +3795,7 @@ func (s *appState) startConvert(status *widget.Label, btn, cancelBtn *widget.But
|
||||||
fyne.CurrentApp().Driver().DoFromGoroutine(func() {
|
fyne.CurrentApp().Driver().DoFromGoroutine(func() {
|
||||||
s.showErrorWithCopy("Conversion Failed", fmt.Errorf("conversion output is invalid: %w", probeErr))
|
s.showErrorWithCopy("Conversion Failed", fmt.Errorf("conversion output is invalid: %w", probeErr))
|
||||||
s.convertBusy = false
|
s.convertBusy = false
|
||||||
|
s.convertProgress = 0
|
||||||
setStatus("Failed")
|
setStatus("Failed")
|
||||||
}, false)
|
}, false)
|
||||||
s.convertCancel = nil
|
s.convertCancel = nil
|
||||||
|
|
@ -3798,6 +3805,7 @@ func (s *appState) startConvert(status *widget.Label, btn, cancelBtn *widget.But
|
||||||
fyne.CurrentApp().Driver().DoFromGoroutine(func() {
|
fyne.CurrentApp().Driver().DoFromGoroutine(func() {
|
||||||
dialog.ShowInformation("Convert", fmt.Sprintf("Saved %s", outPath), s.window)
|
dialog.ShowInformation("Convert", fmt.Sprintf("Saved %s", outPath), s.window)
|
||||||
s.convertBusy = false
|
s.convertBusy = false
|
||||||
|
s.convertProgress = 100
|
||||||
setStatus("Done")
|
setStatus("Done")
|
||||||
}, false)
|
}, false)
|
||||||
s.convertCancel = nil
|
s.convertCancel = nil
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user