Skip to content

🎧 Your Personal Streaming Service

Don't try to transcode a file if the requested format is the same and the client is not requesting to downsample

Deluan2392060bc1cc
diff --git a/engine/media_streamer.go b/engine/media_streamer.go
index dfcf91bf3..5cc9bed52 100644
--- a/engine/media_streamer.go
+++ b/engine/media_streamer.go
@@ -147,6 +147,10 @@ func selectTranscodingOptions(ctx context.Context, ds model.DataStore, mf *model
if reqFormat == "raw" {
return
}
+ if reqFormat == mf.Suffix && reqBitRate == 0 {
+ bitRate = mf.BitRate
+ return
+ }
trc, hasDefault := ctx.Value("transcoding").(model.Transcoding)
var cFormat string
var cBitRate int
diff --git a/engine/media_streamer_test.go b/engine/media_streamer_test.go
index 755eea8b1..48c30fec3 100644
--- a/engine/media_streamer_test.go
+++ b/engine/media_streamer_test.go
@@ -104,6 +104,13 @@ var _ = Describe("MediaStreamer", func() {
Expect(format).To(Equal("mp3"))
Expect(bitRate).To(Equal(192))
})
+ It("returns raw if requested format is the same as the original, but requested BitRate is 0", func() {
+ mf.Suffix = "mp3"
+ mf.BitRate = 320
+ format, bitRate := selectTranscodingOptions(ctx, ds, mf, "mp3", 0)
+ Expect(format).To(Equal("raw"))
+ Expect(bitRate).To(Equal(320))
+ })
})
Context("player has format configured", func() {