Kirika/README.md

191 lines
39 KiB
Markdown
Raw Normal View History

2022-02-22 09:24:49 +00:00
# [![](resources/kirikas.png)](resources/kirika.png) Kirika
Collection of audio utilities for decoding/encoding files and streams.
2022-03-01 17:10:01 +00:00
* Not based on ffmpeg/libav/libavcodec/libavformat and alike
* Channel-based audio consumption/filter chain
* Raw sample analyzer channels
* AnalyzerChannel channels / mergers / splitters / trimmers
2022-02-22 09:24:49 +00:00
* Audio resampler
* Audio downmixing to stereo/mono
2022-03-01 17:10:01 +00:00
* Multi-codec decoder and encoder
* Multi-format packetizers
* ReplayGain 2.0 track/album calculator
2022-02-28 14:47:50 +00:00
2022-03-01 17:10:01 +00:00
## Codecs supported
2022-02-28 14:47:50 +00:00
2022-05-15 15:53:28 +00:00
| Codec | Containers | Decoder | Analyzer | Encoder | Notes |
|:----------:|:----------------------------------------------------------------------------------------:|:-------:|:--------:|:-------:|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
2022-05-19 15:00:06 +00:00
| **FLAC** | [FLAC](https://xiph.org/flac/format.html), [Ogg](https://xiph.org/flac/ogg_mapping.html) | ✅ | ✅ | ✅ | Adjustable encoding compression level and block size.<br/>Decoding/encoding by [libFLAC](https://github.com/xiph/flac) via [goflac](https://git.gammaspectra.live/S.O.N.G/goflac).<br/>If [goflac](https://git.gammaspectra.live/S.O.N.G/goflac) codec is disabled, [mewkiz/flac](https://github.com/mewkiz/flac) decoder will be used. |
2022-05-15 15:53:28 +00:00
| **TTA** | [TTA](https://www.tausoft.org/en/true_audio_codec_format/) | ✅ | ✅ | ✅ | Decoding/encoding via [go-tta](https://git.gammaspectra.live/S.O.N.G/go-tta). |
| **MP3** | [MP3](http://mpgedit.org/mpgedit/mpeg_format/MP3Format.html) | ✅ | - | ✅ | Adjustable encoding bitrate and mode.<br/>Decoding via [minimp3](https://github.com/kvark128/minimp3), encoding by [LAME](https://lame.sourceforge.io/) via [go-lame](https://github.com/viert/go-lame). |
| **Opus** | [Ogg](https://www.xiph.org/ogg/doc/framing.html) | ✅ | - | ✅ | Adjustable encoding bitrate.<br/>Decoding/encoding by [libopus](https://github.com/xiph/opus) via [go-pus](https://git.gammaspectra.live/S.O.N.G/go-pus). |
| **Vorbis** | [Ogg](https://www.xiph.org/ogg/doc/framing.html) | ✅ | - | ❌ | Decoding by [jfreymuth/vorbis](https://github.com/jfreymuth/vorbis) via [jfreymuth/oggvorbis](https://github.com/jfreymuth/oggvorbis). |
| **AAC** | [ADTS](https://wiki.multimedia.cx/index.php/ADTS), ADIF*, MP4** | ✅ | - | ✅ | Adjustable encoding bitrate and mode (LC, HEv1, HEv2).<br/>Decoding/encoding by [FDK-AAC](https://github.com/mstorsjo/fdk-aac) via [go-fdkaac](https://git.gammaspectra.live/S.O.N.G/go-fdkaac).<br/>If [go-fdkaac](https://git.gammaspectra.live/S.O.N.G/go-fdkaac) codec is disabled, [VisualOn AAC encoder](https://github.com/gen2brain/aac-go) will be used for limited encoding support.<br/>*ADIF only supported on encoding.<br/>**MP4 only supported on encoding, and fragmented MP4 currently. |
| **ALAC** | MP4* | ✅ | ✅ | ✅ | Decoding/encoding by [libalac](https://git.gammaspectra.live/S.O.N.G/alac) via [go-alac](https://git.gammaspectra.live/S.O.N.G/go-alac).<br/>Disabled by default.<br/>*MP4 encoding only supported on fragmented MP4 currently. |
2022-02-22 09:24:49 +00:00
2022-03-01 17:10:01 +00:00
## Container packetizers supported
2022-04-17 18:27:29 +00:00
2022-05-15 19:47:40 +00:00
| Container | Packetizer | Keep Mode | Sample Numbers | Offset | Notes |
|:---------:|:----------:|:---------:|:--------------:|:------:|:---------------------------------------------------------------------------------------------------------------------------------------|
| **FLAC** | ✅ | ✅ | ✅ | ❌ | Uses [mewkiz/flac](https://github.com/mewkiz/flac) for parsing streams. |
| **TTA** | ❌ | - | - | - | |
| **MP3** | ✅ | ✅ | ✅ | ✅ | Uses [sssgun/mp3](https://github.com/sssgun/mp3) as a frame parser. |
| **Ogg** | ✅ | ✅ | ✅* | ✅ | *Sample numbers (absolute granule position in Ogg) depend on underlying codec implementing it.<br/>Has been tested as working for Opus |
| **ADTS** | ✅ | ✅ | ✅ | ✅ | Uses [edgeware/mp4ff](https://github.com/edgeware/mp4ff) for its ADTS frame parser. |
| **MP4** | ❌ | - | - | - | |
| **ADIF** | ❌ | - | - | - | |
2022-03-01 17:10:01 +00:00
2022-02-22 09:24:49 +00:00
## Dependencies
### Go >= 1.18
2022-04-21 16:53:33 +00:00
### [libFLAC](https://gitlab.xiph.org/xiph/flac) (required by [goflac](https://git.gammaspectra.live/S.O.N.G/goflac))
2022-02-22 09:24:49 +00:00
```shell
sudo apt install libflac-dev
```
2022-04-21 16:53:33 +00:00
### [libopus](https://gitlab.xiph.org/xiph/opus) and [libopusfile](https://gitlab.xiph.org/xiph/opusfile) (required by [go-pus](https://git.gammaspectra.live/S.O.N.G/go-pus))
2022-02-22 09:24:49 +00:00
```shell
sudo apt install libopus-dev libopusfile-dev
```
2022-04-21 16:53:33 +00:00
### [libopusenc](https://gitlab.xiph.org/xiph/libopusenc) (required by [go-pus](https://git.gammaspectra.live/S.O.N.G/go-pus))
2022-02-27 18:44:04 +00:00
```shell
2022-04-21 16:53:33 +00:00
git clone --depth 1 https://gitlab.xiph.org/xiph/libopusenc.git
2022-02-27 18:44:04 +00:00
cd libopusenc
./autogen.sh
./configure --prefix /usr
make
sudo make install
```
2022-02-28 13:38:23 +00:00
### [FDK AAC Codec Library](https://github.com/mstorsjo/fdk-aac) (required by [go-fdkaac](https://git.gammaspectra.live/S.O.N.G/go-fdkaac))
2022-02-28 12:54:17 +00:00
```shell
2022-04-21 16:53:33 +00:00
sudo apt install libfdk-aac-dev
```
Alternatively if package cannot be found under your distribution:
```shell
2022-02-28 12:54:17 +00:00
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
```
2022-04-21 16:53:33 +00:00
### [libalac](https://git.gammaspectra.live/S.O.N.G/alac) (required by [go-alac](https://git.gammaspectra.live/S.O.N.G/go-alac))
```shell
2022-04-21 11:56:36 +00:00
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
```
2022-02-28 13:38:23 +00:00
### [LAME](https://lame.sourceforge.io/) (required by [go-lame](https://github.com/viert/go-lame))
2022-02-27 15:43:50 +00:00
```shell
sudo apt install libmp3lame-dev
```
2022-02-22 09:24:49 +00:00
### [libsamplerate](https://github.com/libsndfile/libsamplerate) (required by [gosamplerate](https://github.com/dh1tw/gosamplerate))
```shell
sudo apt install libsamplerate0-dev
```
### [libebur128](https://github.com/jiixyj/libebur128) (required by [go-ebur128](https://git.gammaspectra.live/S.O.N.G/go-ebur128))
```shell
sudo apt install libebur128-dev
2022-04-17 22:22:59 +00:00
```
## 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](https://git.gammaspectra.live/S.O.N.G/go-fdkaac) 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](https://github.com/gen2brain/aac-go) bindings, which are vastly worse.
2022-05-19 15:00:06 +00:00
### disable_codec_libflac
This tag disables the [libFLAC](https://gitlab.xiph.org/xiph/flac) support for decoding/encoding FLAC.
If this tag is enabled, yet `flac` support remains enabled, [mewkiz/flac](https://github.com/mewkiz/flac) FLAC decoder (but not encoder) will be used.
### disable_codec_lame
This tag disables the [LAME](https://github.com/viert/go-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](https://git.gammaspectra.live/S.O.N.G/go-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](https://git.gammaspectra.live/S.O.N.G/go-alac) 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.
2022-04-17 22:22:59 +00:00
## 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](https://git.gammaspectra.live/S.O.N.G/go-alac) | Go | [BSD 2-Clause](https://git.gammaspectra.live/S.O.N.G/go-alac/src/branch/master/LICENSE) | |
| [S.O.N.G/alac](https://git.gammaspectra.live/S.O.N.G/alac) | C++/C | [Apache 2.0](https://git.gammaspectra.live/S.O.N.G/alac/src/branch/master/LICENSE) | Can be linked by cgo as a shared library. |
| [S.O.N.G/go-ebur128](https://git.gammaspectra.live/S.O.N.G/go-ebur128) | Go | [BSD 2-Clause](https://git.gammaspectra.live/S.O.N.G/go-ebur128/src/branch/master/LICENSE) | |
| [jiixyj/libebur128](https://github.com/jiixyj/libebur128) | C | [MIT](https://github.com/jiixyj/libebur128/blob/master/COPYING) | Can be linked by cgo as a shared library. |
| [S.O.N.G/go-fdkaac](https://git.gammaspectra.live/S.O.N.G/go-fdkaac) | Go | | [MIT](https://git.gammaspectra.live/S.O.N.G/go-fdkaac/src/branch/master/LICENSE) | |
| [mstorsjo/fdk-aac](https://github.com/mstorsjo/fdk-aac) | C++/C | [FDK License, BSD-like](https://github.com/mstorsjo/fdk-aac/blob/master/NOTICE) | Does not include patent grants.<br/>Considered free by [Red hat](https://bugzilla.redhat.com/show_bug.cgi?id=1501522), [Fedora](https://fedoraproject.org/wiki/Licensing/FDK-AAC), [GNU](https://www.gnu.org/licenses/license-list.html#fdk), [FSF](https://www.fsf.org/blogs/licensing/recent-licensing-updates#:~:text=maintain%20free%20versions.-,The%20Fraunhofer%20FDK%20AAC%20license,-We%20recently%20added); and non-free by [Debian](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=694257).<br/>Can be linked by cgo as a shared library. |
| [S.O.N.G/go-pus](https://git.gammaspectra.live/S.O.N.G/go-pus) | Go | [MIT](https://git.gammaspectra.live/S.O.N.G/go-pus/src/branch/v2/LICENSE) | |
| [xiph/opus](https://gitlab.xiph.org/xiph/opus) | C | [BSD 3-Clause](https://gitlab.xiph.org/xiph/opus/-/blob/master/COPYING) | Read extra license details on the [official site](https://opus-codec.org/license/).<br/>Can be linked by cgo as a shared library. |
| [xiph/opusfile](https://gitlab.xiph.org/xiph/opusfile) | C | [BSD 3-Clause](https://gitlab.xiph.org/xiph/opusfile/-/blob/master/COPYINGG) | Can be linked by cgo as a shared library. |
| [xiph/ogg](https://gitlab.xiph.org/xiph/ogg) | C | [BSD 3-Clause](https://gitlab.xiph.org/xiph/ogg/-/blob/master/COPYING) | Can be linked by cgo as a shared library. |
| [xiph/libopusenc](https://gitlab.xiph.org/xiph/libopusenc) | C | [BSD 3-Clause](https://gitlab.xiph.org/xiph/libopusenc/-/blob/master/COPYING) | Can be linked by cgo as a shared library. |
| [S.O.N.G/go-tta](https://git.gammaspectra.live/S.O.N.G/go-tta) | Go | [LGPL v3](https://git.gammaspectra.live/S.O.N.G/go-tta/src/branch/master/LICENSE) | |
| [S.O.N.G/goflac](https://git.gammaspectra.live/S.O.N.G/goflac) | Go | [BSD 3-Clause](https://git.gammaspectra.live/S.O.N.G/goflac/src/branch/master/LICENSE) | |
| [xiph/flac](https://gitlab.xiph.org/xiph/flac) | C | [BSD 3-Clause](https://gitlab.xiph.org/xiph/flac/-/blob/master/COPYING.Xiph) | Read extra license details on the [official site](https://xiph.org/flac/license.html).<br/>Can be linked by cgo as a shared library. |
| [dh1tw/gosamplerate](https://github.com/dh1tw/gosamplerate) | Go | [BSD 2-Clause](https://github.com/dh1tw/gosamplerate/blob/master/LICENSE) | |
| [libsndfile/libsamplerate](https://github.com/libsndfile/libsamplerate) | C | [BSD 2-Clause](https://github.com/libsndfile/libsamplerate/blob/master/COPYING) | Can be linked by cgo as a shared library. |
| [edgeware/mp4ff](https://github.com/edgeware/mp4ff) | Go | [MIT](https://github.com/edgeware/mp4ff/blob/master/LICENSE.md) | |
| [gen2brain/aac-go](https://github.com/gen2brain/aac-go) | Go | [Apache 2.0](https://github.com/gen2brain/aac-go/blob/master/COPYING) | |
| [mstorsjo/vo-aacenc](https://github.com/mstorsjo/vo-aacenc) | C | [Apache 2.0](https://github.com/mstorsjo/vo-aacenc/blob/master/COPYING) | Subdependency and included as part of _gen2brain/aac-go_. |
| [jfreymuth/oggvorbis](https://github.com/jfreymuth/oggvorbis) | Go | [MIT](https://github.com/jfreymuth/oggvorbis/blob/master/LICENSE) | | |
| _[jfreymuth/vorbis](https://github.com/jfreymuth/vorbis)_ | Go | [MIT](https://github.com/jfreymuth/vorbis/blob/master/LICENSE) | Subdependency of _jfreymuth/oggvorbis_. | |
| [kvark128/minimp3](https://github.com/kvark128/minimp3) | Go | [MIT](https://github.com/kvark128/minimp3/blob/master/LICENSE.txt) | | |
| [lieff/minimp3](https://github.com/lieff/minimp3) | C | [CC0 1.0](https://github.com/lieff/minimp3/blob/master/LICENSE) | Subdependency and included as part of _lieff/minimp3_. |
| [mewkiz/flac](https://github.com/mewkiz/flac) | Go | [The Unlicense](https://github.com/mewkiz/flac/blob/master/LICENSE) | |
| _[go-audio/audio](https://github.com/go-audio/audio)_ | Go | [Apache 2.0](https://github.com/go-audio/audio/blob/master/LICENSE) | Subdependency of _mewkiz/flac_. Only used on tests there. |
| _[go-audio/wav](https://github.com/go-audio/wav)_ | Go | [Apache 2.0](https://github.com/go-audio/wav/blob/master/LICENSE) | Subdependency of _mewkiz/flac_. Only used on tests there. |
| _[go-audio/riff](https://github.com/go-audio/riff)_ | Go | [Apache 2.0](https://github.com/go-audio/riff/blob/master/LICENSE) | Subdependency of _go-audio/wav_. Only used on tests there. |
| _[icza/bitio](https://github.com/icza/bitio)_ | Go | [Apache 2.0](https://github.com/icza/bitio/blob/master/LICENSE-APACHE) or [LGPL v2.1](https://github.com/icza/bitio/blob/master/LICENSE-LGPL-v2.1) | Subdependency of _mewkiz/flac_. |
| [sssgun/mp3](https://github.com/sssgun/mp3) | Go | [MIT](https://github.com/sssgun/mp3/blob/master/LICENSE) | |
| [viert/go-lame](https://github.com/viert/go-lame) | Go | [MIT](https://github.com/viert/go-lame/blob/master/LICENSE) | |
| [LAME](https://lame.sourceforge.io/) | C | [LGPL v2](https://sourceforge.net/p/lame/svn/HEAD/tree/trunk/lame/COPYING) | Can be linked by cgo as a shared library. |