1
0
mirror of https://github.com/spl0k/supysonic.git synced 2024-09-19 19:01:03 +00:00

Add default_transcode_target option

This commit is contained in:
mvn23 2019-10-18 13:49:46 +02:00
parent 2e320cc312
commit f0525dc23a
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")