Kirika/README.md
2022-04-23 20:41:14 +02:00

38 KiB

Kirika

Collection of audio utilities for decoding/encoding files and streams.

  • Not based on ffmpeg/libav/libavcodec/libavformat and alike
  • Channel-based audio consumption/filter chain
  • Raw sample analyzer channels
  • AnalyzerChannel channels / mergers / splitters / trimmers
  • Audio resampler
  • Audio downmixing to stereo/mono
  • Multi-codec decoder and encoder
  • Multi-format packetizers
  • ReplayGain 2.0 track/album calculator

Codecs supported

Codec Containers Decoder Analyzer Encoder Notes
FLAC FLAC, Ogg Adjustable encoding compression level and block size.
Decoding/encoding by libFLAC via goflac.
TTA TTA Decoding/encoding via go-tta.
MP3 MP3 - Adjustable encoding bitrate and mode.
Decoding via minimp3, encoding by LAME via go-lame.
Opus Ogg - Adjustable encoding bitrate.
Decoding/encoding by libopus via go-pus.
Vorbis Ogg - Decoding by jfreymuth/vorbis via jfreymuth/oggvorbis.
AAC ADTS, ADIF*, MP4** - Adjustable encoding bitrate and mode (LC, HEv2).
Decoding/encoding by FDK-AAC via go-fdkaac.
If go-fdkaac codec is disabled, VisualOn AAC encoder will be used for limited encoding support.
*ADIF only supported on encoding.
**MP4 encoding only supported on fragmented MP4 currently.
ALAC MP4* Decoding/encoding by libalac via go-alac.
Disabled by default.
*MP4 encoding only supported on fragmented MP4 currently.

Container packetizers supported

Container Packetizer Keep Mode Sample Numbers Notes
FLAC Uses mewkiz/flac for parsing streams.
TTA - -
MP3 Uses sssgun/mp3 as a frame parser.
Ogg * *Sample numbers (absolute granule position in Ogg) depend on underlying codec implementing it.
Has been tested as working for Opus
ADTS Uses edgeware/mp4ff for its ADTS frame parser.
MP4 - -
ADIF - -

Dependencies

Go >= 1.18

libFLAC (required by goflac)

sudo apt install libflac-dev

libopus and libopusfile (required by go-pus)

sudo apt install libopus-dev libopusfile-dev

libopusenc (required by go-pus)

git clone --depth 1 https://gitlab.xiph.org/xiph/libopusenc.git
cd libopusenc
./autogen.sh
./configure --prefix /usr
make
sudo make install

FDK AAC Codec Library (required by go-fdkaac)

sudo apt install libfdk-aac-dev

Alternatively if package cannot be found under your distribution:

git clone --depth 1 https://github.com/mstorsjo/fdk-aac.git
cd fdk-aac
./autogen.sh
./configure --prefix /usr
make -j$(nproc)
sudo make install

libalac (required by go-alac)

git clone --depth 1 https://git.gammaspectra.live/S.O.N.G/alac.git
cd alac
autoreconf -fi
./configure --prefix /usr
make -j$(nproc)
sudo make install

LAME (required by go-lame)

sudo apt install libmp3lame-dev

libsamplerate (required by gosamplerate)

sudo apt install libsamplerate0-dev

libebur128 (required by go-ebur128)

sudo apt install libebur128-dev

Build tags

Several Golang build tags exist to change which features are included in the project.

disable_format_[format]

This tag disables support for the specified format/codec. This does not affect packetizers.

Current implemented [format]: aac, alac, flac, mp3, opus, tta, vorbis. Disabling flac will break tests.

disable_codec_libfdk-aac

This tag disables the libfdk-aac support for decoding/encoding AAC. This is available for specific problems with the FDK license that conflicts with your needs or policy.

If this tag is enabled, yet aac support remains enabled, an AAC encoder (but not decoder) will be built with the VisualOn AAC encoder bindings, which are vastly worse.

disable_codec_lame

This tag disables the LAME support for encoding MP3. This is available for specific problems with the LGPL v2 license that conflicts with your needs or policy.

MP3 decoding is not affected by this tag.

disable_codec_tta

This tag disables the TTA support for decoding/encoding TTA. This is available for specific problems with the LGPL v3 license that conflicts with your needs or policy.

This is equivalent to disable_format_tta.

enable_codec_libalac

This tag enables the libalac support for decoding/encoding ALAC.

This library has vast security issues, enable on your own risk. An alternate codec for decoding might be added in the future.

Licenses

Kirika

Copyright (c) 2022 Kirika Contributors All rights reserved.

Redistribution and use in source and binary forms, with or without modification,are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Dependencies

Subdependencies that are not cgo-based are denoted in cursive.

Dependency Language License Notes
S.O.N.G/go-alac Go BSD 2-Clause
S.O.N.G/alac C++/C Apache 2.0 Can be linked by cgo as a shared library.
S.O.N.G/go-ebur128 Go BSD 2-Clause
jiixyj/libebur128 C MIT Can be linked by cgo as a shared library.
S.O.N.G/go-fdkaac Go MIT
mstorsjo/fdk-aac C++/C FDK License, BSD-like Does not include patent grants.
Considered free by Red hat, Fedora, GNU, FSF; and non-free by Debian.
Can be linked by cgo as a shared library.
S.O.N.G/go-pus Go MIT
xiph/opus C BSD 3-Clause Read extra license details on the official site.
Can be linked by cgo as a shared library.
xiph/opusfile C BSD 3-Clause Can be linked by cgo as a shared library.
xiph/ogg C BSD 3-Clause Can be linked by cgo as a shared library.
xiph/libopusenc C BSD 3-Clause Can be linked by cgo as a shared library.
S.O.N.G/go-tta Go LGPL v3
S.O.N.G/goflac Go BSD 3-Clause
xiph/flac C BSD 3-Clause Read extra license details on the official site.
Can be linked by cgo as a shared library.
dh1tw/gosamplerate Go BSD 2-Clause
libsndfile/libsamplerate C BSD 2-Clause Can be linked by cgo as a shared library.
edgeware/mp4ff Go MIT
gen2brain/aac-go Go Apache 2.0
mstorsjo/vo-aacenc C Apache 2.0 Subdependency and included as part of gen2brain/aac-go.
jfreymuth/oggvorbis Go MIT
jfreymuth/vorbis Go MIT Subdependency of jfreymuth/oggvorbis.
kvark128/minimp3 Go MIT
lieff/minimp3 C CC0 1.0 Subdependency and included as part of lieff/minimp3.
mewkiz/flac Go The Unlicense
go-audio/audio Go Apache 2.0 Subdependency of mewkiz/flac. Only used on tests there.
go-audio/wav Go Apache 2.0 Subdependency of mewkiz/flac. Only used on tests there.
go-audio/riff Go Apache 2.0 Subdependency of go-audio/wav. Only used on tests there.
icza/bitio Go Apache 2.0 or LGPL v2.1 Subdependency of mewkiz/flac.
sssgun/mp3 Go MIT
viert/go-lame Go MIT
LAME C LGPL v2 Can be linked by cgo as a shared library.