diff --git a/assets/assets_gen.go b/assets/assets_gen.go index 5377d94..b529aa8 100644 --- a/assets/assets_gen.go +++ b/assets/assets_gen.go @@ -1,8 +1,6 @@ // file generated with embed tool // do not edit - // - package assets import "time" type EmbeddedAsset struct { diff --git a/server/encode/encode.go b/server/encode/encode.go index 67b3aea..7410891 100644 --- a/server/encode/encode.go +++ b/server/encode/encode.go @@ -52,12 +52,10 @@ func writeCmdOutput(out, cache io.Writer, pipeReader io.ReadCloser) { break } data := buffer[0:n] - _, err = out.Write(data) - if err != nil { + if _, err := out.Write(data); err != nil { log.Printf("error while writing HTTP response: %s\n", err) } - _, err = cache.Write(data) - if err != nil { + if _, err := cache.Write(data); err != nil { log.Printf("error while writing cache file: %s\n", err) } if f, ok := out.(http.Flusher); ok { @@ -72,13 +70,16 @@ func writeCmdOutput(out, cache io.Writer, pipeReader io.ReadCloser) { // pre-format the ffmpeg command with needed options func ffmpegCommand(filePath string, profile *Profile, bitrate string) *exec.Cmd { - ffmpegArgs := []string{ - "-v", "0", "-i", filePath, "-map", "0:0", - "-vn", "-b:a", bitrate, + args := []string{ + "-v", "0", + "-i", filePath, + "-map", "0:0", + "-vn", + "-b:a", bitrate, } - ffmpegArgs = append(ffmpegArgs, profile.ffmpegOptions...) + args = append(args, profile.ffmpegOptions...) if profile.forceRG { - ffmpegArgs = append(ffmpegArgs, + args = append(args, // set up replaygain processing "-af", "volume=replaygain=track:replaygain_preamp=6dB:replaygain_noclip=0, alimiter=level=disabled", // drop redundant replaygain tags @@ -88,8 +89,8 @@ func ffmpegCommand(filePath string, profile *Profile, bitrate string) *exec.Cmd "-metadata", "replaygain_track_peak=", ) } - ffmpegArgs = append(ffmpegArgs, "-f", profile.Format, "-") - return exec.Command("/usr/bin/ffmpeg", ffmpegArgs...) + args = append(args, "-f", profile.Format, "-") + return exec.Command("/usr/bin/ffmpeg", args...) } func Encode(out io.Writer, trackPath, cachePath string, profile *Profile, bitrate string) error { @@ -108,7 +109,6 @@ func Encode(out io.Writer, trackPath, cachePath string, profile *Profile, bitrat // -- @spijet // // start up writers for cache file and http response - // go copyCmdOutput(w, cacheFile, pipeReader) go writeCmdOutput(out, cacheFile, pipeReader) // run ffmpeg if err := cmd.Run(); err != nil {