mirror of
https://github.com/spl0k/supysonic.git
synced 2024-11-09 11:42:16 +00:00
Support setting basic metadata in transcoded media
Other small fixes: - Fixed typo in README - Fixed `oggenc2` using `-q` instead of `-Q` to mean "quiet" Fixes #170
This commit is contained in:
parent
2f94089e9c
commit
2f9fa0da6f
@ -19,7 +19,7 @@ _Supysonic_ currently targets the version 1.9.0 of the _Subsonic_ API. For more
|
|||||||
details, go check the [API implementation status][docs-api].
|
details, go check the [API implementation status][docs-api].
|
||||||
|
|
||||||
[subsonic]: http://www.subsonic.org/
|
[subsonic]: http://www.subsonic.org/
|
||||||
[transcoding]: docs/trancoding.md
|
[transcoding]: docs/transcoding.md
|
||||||
[lastfm]: https://last.fm/
|
[lastfm]: https://last.fm/
|
||||||
[docs-api]: docs/api.md
|
[docs-api]: docs/api.md
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ decoder_mp3 = mpg123 --quiet -w - %srcpath
|
|||||||
decoder_ogg = oggdec -o %srcpath
|
decoder_ogg = oggdec -o %srcpath
|
||||||
decoder_flac = flac -d -c -s %srcpath
|
decoder_flac = flac -d -c -s %srcpath
|
||||||
encoder_mp3 = lame --quiet -b %outrate - -
|
encoder_mp3 = lame --quiet -b %outrate - -
|
||||||
encoder_ogg = oggenc2 -q -M %outrate -
|
encoder_ogg = oggenc2 -Q -M %outrate -
|
||||||
|
|
||||||
; Default format, used when a client requests a bitrate lower than the original
|
; Default format, used when a client requests a bitrate lower than the original
|
||||||
; file and no specific format
|
; file and no specific format
|
||||||
|
@ -57,6 +57,14 @@ program. The command-lines can include the following fields:
|
|||||||
* `%srcfmt`: extension of the original file
|
* `%srcfmt`: extension of the original file
|
||||||
* `%outfmt`: extension of the resulting file
|
* `%outfmt`: extension of the resulting file
|
||||||
* `%outrate`: bitrate of the resulting file
|
* `%outrate`: bitrate of the resulting file
|
||||||
|
* `%title`: title of the file to transcode
|
||||||
|
* `%album`: album name of the file to transcode
|
||||||
|
* `%artist`: artist name of the file to transcode
|
||||||
|
* `%tracknumber`: track number of the file to transcode
|
||||||
|
* `%totaltracks`: number of tracks in the album of the file to transcode
|
||||||
|
* `%discnumber`: disc number of the file to transcode
|
||||||
|
* `%genre`: genre of the file to transcode (not always available, defaults to "")
|
||||||
|
* `%year`: year of the file to transcode (not always available, defaults to "")
|
||||||
|
|
||||||
One final note: the original file should be provided as an argument of
|
One final note: the original file should be provided as an argument of
|
||||||
transcoders and decoders. All transcoders, decoders and encoders should write
|
transcoders and decoders. All transcoders, decoders and encoders should write
|
||||||
@ -67,9 +75,10 @@ client requests a bitrate lower than the original file and no specific format.
|
|||||||
|
|
||||||
## Suggested configuration
|
## Suggested configuration
|
||||||
|
|
||||||
Here are some example configuration that you could use. This is provided as-is,
|
Here is an example configuration that you could use. This is provided as-is,
|
||||||
and some configurations haven't been tested.
|
and some configurations haven't been tested.
|
||||||
|
|
||||||
|
Basic configuration:
|
||||||
```ini
|
```ini
|
||||||
[transcoding]
|
[transcoding]
|
||||||
transcoder_mp3_mp3 = lame --quiet --mp3input -b %outrate %srcpath -
|
transcoder_mp3_mp3 = lame --quiet --mp3input -b %outrate %srcpath -
|
||||||
@ -78,7 +87,19 @@ decoder_mp3 = mpg123 --quiet -w - %srcpath
|
|||||||
decoder_ogg = oggdec -o %srcpath
|
decoder_ogg = oggdec -o %srcpath
|
||||||
decoder_flac = flac -d -c -s %srcpath
|
decoder_flac = flac -d -c -s %srcpath
|
||||||
encoder_mp3 = lame --quiet -b %outrate - -
|
encoder_mp3 = lame --quiet -b %outrate - -
|
||||||
encoder_ogg = oggenc2 -q -M %outrate -
|
encoder_ogg = oggenc2 -Q -M %outrate -
|
||||||
default_transcode_target = mp3
|
default_transcode_target = mp3
|
||||||
```
|
```
|
||||||
|
|
||||||
|
To include track metadata in the transcoded stream:
|
||||||
|
```ini
|
||||||
|
[transcoding]
|
||||||
|
transcoder_mp3_mp3 = lame --quiet --mp3input -b %outrate --tt %title --tl %album --ta %artist --tn %tracknumber/%totaltracks --tv TPOS=%discnumber --tg %genre --ty %year --add-id3v2 %srcpath -
|
||||||
|
transcoder = ffmpeg -i %srcpath -ab %outratek -v 0 -metadata title=%title -metadata album=%album -metadata author=%artist -metadata track=%tracknumber/%totaltracks -metadata disc=%discnumber -metadata genre=%genre -metadata date=%year -f %outfmt -
|
||||||
|
decoder_mp3 = mpg123 --quiet -w - %srcpath
|
||||||
|
decoder_ogg = oggdec -o %srcpath
|
||||||
|
decoder_flac = flac -d -c -s %srcpath
|
||||||
|
encoder_mp3 = lame --quiet -b %outrate --tt %title --tl %album --ta %artist --tn %tracknumber/%totaltracks --tv TPOS=%discnumber --tg %genre --ty %year --add-id3v2 - -
|
||||||
|
encoder_ogg = oggenc2 -Q -M %outrate -t %title -l %album -a %artist -N %tracknumber -c TOTALTRACKS=%totaltracks -c DISCNUMBER=%discnumber -G %genre -d %year -
|
||||||
|
default_transcode_target = mp3
|
||||||
|
```
|
||||||
|
@ -48,16 +48,24 @@ logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
def prepare_transcoding_cmdline(
|
def prepare_transcoding_cmdline(
|
||||||
base_cmdline, input_file, input_format, output_format, output_bitrate
|
base_cmdline, res, input_format, output_format, output_bitrate
|
||||||
):
|
):
|
||||||
if not base_cmdline:
|
if not base_cmdline:
|
||||||
return None
|
return None
|
||||||
ret = shlex.split(base_cmdline)
|
ret = shlex.split(base_cmdline)
|
||||||
ret = [
|
ret = [
|
||||||
part.replace("%srcpath", input_file)
|
part.replace("%srcpath", res.path)
|
||||||
.replace("%srcfmt", input_format)
|
.replace("%srcfmt", input_format)
|
||||||
.replace("%outfmt", output_format)
|
.replace("%outfmt", output_format)
|
||||||
.replace("%outrate", str(output_bitrate))
|
.replace("%outrate", str(output_bitrate))
|
||||||
|
.replace("%title", res.title)
|
||||||
|
.replace("%album", res.album.name)
|
||||||
|
.replace("%artist", res.artist.name)
|
||||||
|
.replace("%tracknumber", str(res.number))
|
||||||
|
.replace("%totaltracks", str(res.album.tracks.count()))
|
||||||
|
.replace("%discnumber", str(res.disc))
|
||||||
|
.replace("%genre", res.genre if res.genre else "")
|
||||||
|
.replace("%year", str(res.year) if res.year else "")
|
||||||
for part in ret
|
for part in ret
|
||||||
]
|
]
|
||||||
return ret
|
return ret
|
||||||
@ -128,12 +136,12 @@ def stream_media():
|
|||||||
logger.info(message)
|
logger.info(message)
|
||||||
raise GenericError(message)
|
raise GenericError(message)
|
||||||
|
|
||||||
transcoder, decoder, encoder = map(
|
transcoder, decoder, encoder = [
|
||||||
lambda x: prepare_transcoding_cmdline(
|
prepare_transcoding_cmdline(
|
||||||
x, res.path, src_suffix, dst_suffix, dst_bitrate
|
x, res, src_suffix, dst_suffix, dst_bitrate
|
||||||
),
|
)
|
||||||
[transcoder, decoder, encoder],
|
for x in (transcoder, decoder, encoder)
|
||||||
)
|
]
|
||||||
try:
|
try:
|
||||||
if transcoder:
|
if transcoder:
|
||||||
dec_proc = None
|
dec_proc = None
|
||||||
|
Loading…
Reference in New Issue
Block a user