diff --git a/ffmpeg/parse/parser.go b/ffmpeg/parse/parser.go index c4d131b2..6f533875 100644 --- a/ffmpeg/parse/parser.go +++ b/ffmpeg/parse/parser.go @@ -660,6 +660,13 @@ func (p *parser) Progress() Progress { return progress } +func (p *parser) IsRunning() bool { + p.lock.progress.RLock() + defer p.lock.progress.RUnlock() + + return p.stats.initialized +} + func (p *parser) Prelude() []string { p.lock.prelude.RLock() if p.prelude.data == nil { diff --git a/ffmpeg/probe/prober.go b/ffmpeg/probe/prober.go index 3ddb8ec2..01a799fb 100644 --- a/ffmpeg/probe/prober.go +++ b/ffmpeg/probe/prober.go @@ -141,3 +141,7 @@ func (p *prober) ResetLog() { p.data = []process.Line{} p.inputs = []probeIO{} } + +func (p *prober) IsRunning() bool { + return true +} diff --git a/process/parser.go b/process/parser.go index 122b0e62..1eeeb1b6 100644 --- a/process/parser.go +++ b/process/parser.go @@ -26,8 +26,11 @@ type Parser interface { // before the process starts. ResetLog() - // Log returns a slice of collected log lines + // Log returns a slice of collected log lines. Log() []Line + + // IsRunning returns whether the process is producing output. + IsRunning() bool } // Line represents a line from the output with its timestamp. The @@ -52,6 +55,7 @@ func (p *nullParser) Stop(string, Usage) {} func (p *nullParser) ResetStats() {} func (p *nullParser) ResetLog() {} func (p *nullParser) Log() []Line { return []Line{} } +func (p *nullParser) IsRunning() bool { return true } type bufferParser struct { log []Line @@ -77,4 +81,5 @@ func (p *bufferParser) ResetStats() {} func (p *bufferParser) ResetLog() { p.log = []Line{} } -func (p *bufferParser) Log() []Line { return p.log } +func (p *bufferParser) Log() []Line { return p.log } +func (p *bufferParser) IsRunning() bool { return true } diff --git a/process/process.go b/process/process.go index c6290d34..44e66516 100644 --- a/process/process.go +++ b/process/process.go @@ -454,6 +454,10 @@ func (p *process) Status() Status { states := p.state.states p.state.lock.Unlock() + if state == stateRunning && !p.parser.IsRunning() { + state = stateStarting + } + order := p.getOrder() s := Status{