1
0
mirror of https://github.com/spl0k/supysonic.git synced 2024-12-22 08:56:17 +00:00

Merge remote-tracking branch 'mvn23/default_transcode_target'

This commit is contained in:
Alban Féron 2019-10-26 16:22:39 +02:00
commit e9d4de6f1a
No known key found for this signature in database
GPG Key ID: 8CE0313646D16165
2 changed files with 9 additions and 1 deletions

View File

@ -28,6 +28,7 @@ All these are defined by the following variables:
* `trancoder`
* `decoder`
* `encoder`
* `default_transcode_target`
where `EXT` is the lowercase file extension of the matching audio format.
`transcoder`s variables have two extensions: the first one is the source
@ -61,6 +62,9 @@ One final note: the original file should be provided as an argument of
transcoders and decoders. All transcoders, decoders and encoders should write
to standard output, and encoders should read from standard input.
The value of `default_transcode_target` will be used as output format when a
client requests a bitrate lower than the original file and no specific format.
## Suggested configuration
Here are some example configuration that you could use. This is provided as-is,
@ -75,5 +79,6 @@ decoder_ogg = oggdec -o %srcpath
decoder_flac = flac -d -c -s %srcpath
encoder_mp3 = lame --quiet -b %outrate - -
encoder_ogg = oggenc2 -q -M %outrate -
default_transcode_target = mp3
```

View File

@ -83,6 +83,8 @@ def stream_media():
dst_bitrate = res.bitrate
dst_mimetype = res.mimetype
config = current_app.config["TRANSCODING"]
prefs = request.client
if prefs.format:
dst_suffix = prefs.format
@ -94,6 +96,8 @@ def stream_media():
if dst_bitrate > maxBitRate and maxBitRate != 0:
dst_bitrate = maxBitRate
if not format:
format = config.get("default_transcode_target")
if format and format != "raw" and format != src_suffix:
dst_suffix = format
@ -112,7 +116,6 @@ def stream_media():
cache.get(cache_key), mimetype=dst_mimetype, conditional=True
)
except CacheMiss:
config = current_app.config["TRANSCODING"]
transcoder = config.get("transcoder_{}_{}".format(src_suffix, dst_suffix))
decoder = config.get("decoder_" + src_suffix) or config.get("decoder")
encoder = config.get("encoder_" + dst_suffix) or config.get("encoder")