diff --git a/server/ctrlsubsonic/handlers_raw.go b/server/ctrlsubsonic/handlers_raw.go index 16b89a8..37cb8d2 100644 --- a/server/ctrlsubsonic/handlers_raw.go +++ b/server/ctrlsubsonic/handlers_raw.go @@ -330,7 +330,7 @@ func (c *Controller) ServeStream(w http.ResponseWriter, r *http.Request) *spec.R log.Printf("trancoding to %q with max bitrate %dk", profile.MIME(), profile.BitRate()) w.Header().Set("Content-Type", profile.MIME()) - if err := c.Transcoder.Transcode(r.Context(), profile, audioPath, w); err != nil { + if err := c.Transcoder.Transcode(r.Context(), profile, audioPath, w); err != nil && !errors.Is(err, transcode.ErrFFmpegKilled) { return spec.NewError(0, "error transcoding: %v", err) } diff --git a/transcode/transcoder_ffmpeg.go b/transcode/transcoder_ffmpeg.go index c1cc52f..f0a471b 100644 --- a/transcode/transcoder_ffmpeg.go +++ b/transcode/transcoder_ffmpeg.go @@ -16,6 +16,7 @@ func NewFFmpegTranscoder() *FFmpegTranscoder { return &FFmpegTranscoder{} } +var ErrFFmpegKilled = fmt.Errorf("ffmpeg was killed early") var ErrFFmpegExit = fmt.Errorf("ffmpeg exited with non 0 status code") func (*FFmpegTranscoder) Transcode(ctx context.Context, profile Profile, in string, out io.Writer) error { @@ -32,7 +33,11 @@ func (*FFmpegTranscoder) Transcode(ctx context.Context, profile Profile, in stri } var exitErr *exec.ExitError - if err := cmd.Wait(); err != nil && !errors.As(err, &exitErr) { + + switch err := cmd.Wait(); { + case errors.As(err, &exitErr): + return fmt.Errorf("waiting cmd: %v: %w", err, ErrFFmpegKilled) + case err != nil: return fmt.Errorf("waiting cmd: %w", err) } if code := cmd.ProcessState.ExitCode(); code > 1 {