From 5c31f9d6462204edb3bd9e8f2a44ee4959b25043 Mon Sep 17 00:00:00 2001 From: WeebDataHoarder <57538841+WeebDataHoarder@users.noreply.github.com> Date: Sun, 15 May 2022 19:44:35 +0200 Subject: [PATCH] Update Kirika, support HE AAC, VBR, better mode setting --- example_config.toml | 7 ++++--- go.mod | 6 +++--- go.sum | 12 ++++++------ mount.go | 18 +++++++++++------- 4 files changed, 24 insertions(+), 19 deletions(-) diff --git a/example_config.toml b/example_config.toml index b10cf81..1db5386 100644 --- a/example_config.toml +++ b/example_config.toml @@ -78,12 +78,14 @@ private=false # # mount: the HTTP address to serve the stream from # container: the container format to use (ogg, flac, aac/adts, or mp3). See Kirika's supported format list. -# codec: the audio codec to use (opus, flac, aac, he-aacv2, or mp3) +# codec: the audio codec to use (opus, flac, aac, or mp3) # bitrate: the desired bitrate of the stream in Kb/s, if not specified (or 0) an appropriate # bitrate will be automatically selected based on the container/codec -# MeteorLight extension: bitrate can be a string (for example, v0/v1/v2/v3 on MP3). codec can also be he-aacv2. No vorbis support. +# MeteorLight extension: bitrate can be a string (for example, v0-v9 on MP3). codec can also be he-aacv2. No vorbis support. # Additionally further options can be set on some codecs. # - FLAC supports bitdepth (int), compression_level (int), block_size (int) +# - AAC supports VBR bitrate (vbr1 - vbr5), mode (lc, he, hev2) and afterburner (bool) +# - MP3 supports VBR bitrate (v0 - v9) # - All but Opus support setting samplerate # - All support setting channels to 1 or 2 [[streams]] @@ -98,7 +100,6 @@ bitrate=192 [[streams]] mount="stream128.aac" -# Also supports he-aacv2 codec="aac" container="aac" bitrate=128 diff --git a/go.mod b/go.mod index aaee743..d8a70e9 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module git.gammaspectra.live/S.O.N.G/MeteorLight go 1.18 require ( - git.gammaspectra.live/S.O.N.G/Kirika v0.0.0-20220515150532-713835cd8589 + git.gammaspectra.live/S.O.N.G/Kirika v0.0.0-20220515173039-08d1c52b47c9 github.com/BurntSushi/toml v1.1.0 github.com/dhowden/tag v0.0.0-20201120070457-d52dcb253c63 github.com/enriquebris/goconcurrentqueue v0.6.3 @@ -12,10 +12,10 @@ require ( require ( git.gammaspectra.live/S.O.N.G/go-alac v0.0.0-20220421115623-d0b3bfe57e0f // indirect git.gammaspectra.live/S.O.N.G/go-ebur128 v0.0.0-20220418202343-73a167e76255 // indirect - git.gammaspectra.live/S.O.N.G/go-fdkaac v0.0.0-20220421165127-c4b73b260d94 // indirect + git.gammaspectra.live/S.O.N.G/go-fdkaac v0.0.0-20220515171305-ffb0aafe2a61 // indirect git.gammaspectra.live/S.O.N.G/go-pus v0.0.0-20220227175608-6cc027f24dba // indirect git.gammaspectra.live/S.O.N.G/go-tta v0.2.1-0.20220226150007-096de1072bd6 // indirect - git.gammaspectra.live/S.O.N.G/goflac v0.0.0-20220417181802-3057bde44c07 // indirect + git.gammaspectra.live/S.O.N.G/goflac v0.0.0-20220515172202-6e490998d2a0 // indirect github.com/dh1tw/gosamplerate v0.1.2 // indirect github.com/edgeware/mp4ff v0.28.0 // indirect github.com/gen2brain/aac-go v0.0.0-20180306134136-400c68157565 // indirect diff --git a/go.sum b/go.sum index f10ef79..b7a2db6 100644 --- a/go.sum +++ b/go.sum @@ -1,17 +1,17 @@ -git.gammaspectra.live/S.O.N.G/Kirika v0.0.0-20220515150532-713835cd8589 h1:n2LlSes9EO8xF4wfPgo/C7u697RUFJ/YaW6F6jC/dco= -git.gammaspectra.live/S.O.N.G/Kirika v0.0.0-20220515150532-713835cd8589/go.mod h1:65QohfAwsgMkXS7PZO2cm8VgPEZlhKC+JAeZfJBYpFE= +git.gammaspectra.live/S.O.N.G/Kirika v0.0.0-20220515173039-08d1c52b47c9 h1:fydrHzrQYsgyBDykUWJcLP3k/eI7GW0/y/ypKriMvvU= +git.gammaspectra.live/S.O.N.G/Kirika v0.0.0-20220515173039-08d1c52b47c9/go.mod h1:2o3ylTH2YMWIxV+eRwwkDlUZ18aNSPTf12ShaK13biI= git.gammaspectra.live/S.O.N.G/go-alac v0.0.0-20220421115623-d0b3bfe57e0f h1:CxN7zlk5FdAieyRKQSbwBGBsvQ2cDF8JVCODZpzcRkA= git.gammaspectra.live/S.O.N.G/go-alac v0.0.0-20220421115623-d0b3bfe57e0f/go.mod h1:f1+h7KOnuM9zcEQp7ri4UaVvgX4m1NFFIXgReIyjGMA= git.gammaspectra.live/S.O.N.G/go-ebur128 v0.0.0-20220418202343-73a167e76255 h1:BWRx2ZFyhp5+rsXhdDZtk5Gld+L44lxlN9ASqB9Oj0M= git.gammaspectra.live/S.O.N.G/go-ebur128 v0.0.0-20220418202343-73a167e76255/go.mod h1:5H4eVW9uknpn8REFr+C3ejhvXdncgm/pbGqKGC43gFY= -git.gammaspectra.live/S.O.N.G/go-fdkaac v0.0.0-20220421165127-c4b73b260d94 h1:gD6lOyQwwuyJilwbLC8lAEWpUSZvndJsUGwxxDatCAE= -git.gammaspectra.live/S.O.N.G/go-fdkaac v0.0.0-20220421165127-c4b73b260d94/go.mod h1:pkWt//S9hLVEQaJDPu/cHHPk8vPpo/0+zHy0me4LIP4= +git.gammaspectra.live/S.O.N.G/go-fdkaac v0.0.0-20220515171305-ffb0aafe2a61 h1:YufhSTCS59H5CStqokGMb60RnSsqrp+GoZvzmC29wm4= +git.gammaspectra.live/S.O.N.G/go-fdkaac v0.0.0-20220515171305-ffb0aafe2a61/go.mod h1:pkWt//S9hLVEQaJDPu/cHHPk8vPpo/0+zHy0me4LIP4= git.gammaspectra.live/S.O.N.G/go-pus v0.0.0-20220227175608-6cc027f24dba h1:JEaxCVgdr3XXAuDCPAx7ttLFZaaHzTEzG+oRnVUtUKU= git.gammaspectra.live/S.O.N.G/go-pus v0.0.0-20220227175608-6cc027f24dba/go.mod h1:vkoHSHVM9p6vAUmXAik0gvaLcIfiQYrD6bQqVpOulUk= git.gammaspectra.live/S.O.N.G/go-tta v0.2.1-0.20220226150007-096de1072bd6 h1:ITVVisbHPnUclp3PBkCbXFeBhOCBcOjPdgjJ9wRH3TI= git.gammaspectra.live/S.O.N.G/go-tta v0.2.1-0.20220226150007-096de1072bd6/go.mod h1:cobkT8u8vq/+ngLy+feKS2M2ZT2HoCec5riA/0Cex3Q= -git.gammaspectra.live/S.O.N.G/goflac v0.0.0-20220417181802-3057bde44c07 h1:7YxnU4AY/H5ow8TRkgZEJ5O04oC3hMIuha8GaEXsI0M= -git.gammaspectra.live/S.O.N.G/goflac v0.0.0-20220417181802-3057bde44c07/go.mod h1:/po1QgOh3xynbvi4sxdY6Iw8m5WPJfGGmry2boZD8fs= +git.gammaspectra.live/S.O.N.G/goflac v0.0.0-20220515172202-6e490998d2a0 h1:imcnwHUqaAJzws41B8sCSp/sUmVranNjAX205Jr4Jc0= +git.gammaspectra.live/S.O.N.G/goflac v0.0.0-20220515172202-6e490998d2a0/go.mod h1:/po1QgOh3xynbvi4sxdY6Iw8m5WPJfGGmry2boZD8fs= github.com/BurntSushi/toml v1.1.0 h1:ksErzDEI1khOiGPgpwuI7x2ebx/uXQNw7xJpn9Eq1+I= github.com/BurntSushi/toml v1.1.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/cocoonlife/testify v0.0.0-20160218172820-792cc1faeb64 h1:LjPYdzoFSAJ5Tr/ElL8kzTJghXgpnOjJVbgd1UvZB1o= diff --git a/mount.go b/mount.go index f9b046b..d9a0d3e 100644 --- a/mount.go +++ b/mount.go @@ -96,15 +96,13 @@ func NewStreamMount(source audio.Source, config *StreamConfig) *StreamMount { if bitrate != nil { options["bitrate"] = bitrate } + options["mode"] = config.GetStringOption("mode", "lc") mimeType = "audio/aac;codecs=mp4a.40.2" - packetizerEntry = packetizer.NewAdtsPacketizer(reader) - case "he-aacv2": - encoderFormat = aac.NewFormat() - if bitrate != nil { - options["bitrate"] = bitrate + if options["mode"] == "he" || options["mode"] == "hev1" || options["bitrate"] == "vbr2" { + mimeType = "audio/aac;codecs=mp4a.40.5" + } else if options["mode"] == "hev2" || options["bitrate"] == "vbr1" { + mimeType = "audio/aac;codecs=mp4a.40.29" } - options["mode"] = "hev2" - mimeType = "audio/aac;codecs=mp4a.40.29" packetizerEntry = packetizer.NewAdtsPacketizer(reader) } @@ -139,7 +137,13 @@ func NewStreamMount(source audio.Source, config *StreamConfig) *StreamMount { if bitrate != nil { options["bitrate"] = bitrate } + options["mode"] = config.GetStringOption("mode", "lc") mimeType = "audio/aac;codecs=mp4a.40.2" + if options["mode"] == "he" || options["mode"] == "hev1" || options["bitrate"] == "vbr2" { + mimeType = "audio/aac;codecs=mp4a.40.5" + } else if options["mode"] == "hev2" || options["bitrate"] == "vbr1" { + mimeType = "audio/aac;codecs=mp4a.40.29" + } packetizerEntry = packetizer.NewAdtsPacketizer(reader) } }