diff --git a/.gitignore b/.gitignore index b932f2d..388e3fa 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ main.go -build \ No newline at end of file +.idea +build diff --git a/ffmpeg/ffmpeg.go b/ffmpeg/ffmpeg.go index 5d69b54..632ea2f 100644 --- a/ffmpeg/ffmpeg.go +++ b/ffmpeg/ffmpeg.go @@ -104,12 +104,15 @@ func (t *Transcoder) Start(opts transcoder.Options) (<-chan transcoder.Progress, return nil, fmt.Errorf("Failed starting transcoding (%s) with args (%s) with error %s", t.config.FfmpegBinPath, args, err) } - if (t.config.ProgressEnabled && !t.config.Verbose) || (int(t.config.Timeout) > 0) { + if t.config.ProgressEnabled && !t.config.Verbose { + if t.config.ProgressEnabled { go func() { t.progress(stderrIn, out) }() } + } + if int(t.config.Timeout) > 0 { done := make(chan error, 1) go func() { defer close(out) @@ -118,8 +121,13 @@ func (t *Transcoder) Start(opts transcoder.Options) (<-chan transcoder.Progress, }() select { case <-time.After(t.config.Timeout): - cmd.Process.Signal(syscall.SIGTERM) - case <-done: + err = cmd.Process.Signal(syscall.SIGINT) + if err != nil { + return nil, err + } + time.Sleep(30 * time.Second) + + case err := <-done: if err != nil { return nil, err }