Convert audio between multiple formats.
The following parameters may be set for audio conversion operation:
Parameter | Description | Values | Default |
---|---|---|---|
File type | Audio file contrainer type | MPEG-4 , Core Audio , WAV , AIFF , AIFC , Adaptive Multirate |
MPEG-4 |
Audio codec | Audio codec used by encoder | AAC , Opus , FLAC , Linear PCM , Apple Lossless Audio Codec |
Source audio codec |
Audio bitrate | Audio bitrate, used by AAC and Opus codecs only |
Auto - set internally by AVAssetWriterCustom(Int) - custom bitrate value in bps |
Auto |
Audio quality | Audio quality, AAC and FLAC only |
Low , Medium , High |
Unset |
Sample Rate | Sample rate in Hz | Int |
Source sample rate |
Usage
CompressionAudioSettings(
codec: .flac,
bitrate: .value(96_000),
quality: .high,
sampleRate: 44100
)
Cut the audio based on time interval. Time specified in seconds. If none of other audio settings is modified, the cutting is lossless (no audio re-encoding applied - original quality).
Usage
AudioTool.convert(
...
edit: [
.cut(from: 0.5, to: 7.5)
]
)
Extract audio info without compression.
Usage
let info = try await AudioTool.getInfo(source: url)