Skip to main content
FFmpeg 6.0 or later is required for all audio operations.
# Linux
sudo apt install ffmpeg

# macOS
brew install ffmpeg

# Verify installation
ffmpeg -version

AudioTranscodeJob

Converts an audio file to a different format or adjusts its encoding parameters. Go method: Client.AudioTranscode(ctx, job)

Parameters

input
string
required
Path to the source audio file.
output
string
required
Path for the transcoded output file.
codec
string
Target audio codec. Accepted values: mp3, aac, opus, vorbis, flac, wav.
bitrate
string
Target bitrate for lossy codecs. Examples: "128k", "192k", "320k".
sample_rate
uint32
Output sample rate in Hz. Common values: 22050, 44100, 48000.
channels
uint32
Number of output audio channels. Use 1 for mono and 2 for stereo.
quality
uint8
Quality level for variable bitrate (VBR) encoding. Range: 010. Higher values produce better quality. Not all codecs support this parameter.
Use opus for podcast and speech content — it delivers excellent intelligibility at low bitrates (as low as 32k). Use aac for music and general-purpose audio where broader device compatibility is needed.

Codec comparison

CodecTypeBest forNotes
mp3LossyGeneral useWidest device and player compatibility
aacLossyMusic, streamingBetter quality than MP3 at the same bitrate
opusLossySpeech, podcastsBest compression for voice; WebRTC standard
vorbisLossyOpen-source projectsRoyalty-free alternative to MP3/AAC
flacLosslessArchiving, masteringNo quality loss; larger file size
wavUncompressedEditing workflowsNo encoding; maximum compatibility

Example

result, err := client.AudioTranscode(ctx, &dpf.AudioTranscodeJob{
    Input:      "audio.wav",
    Output:     "audio.mp3",
    Codec:      "mp3",      // mp3, aac, opus, vorbis, flac, wav
    Bitrate:    "192k",
    SampleRate: func(u uint32) *uint32 { return &u }(48000),
    Channels:   func(u uint32) *uint32 { return &u }(2),
    Quality:    func(u uint8) *uint8 { return &u }(5), // 0-10
})
if err != nil {
    log.Fatal(err)
}
log.Printf("Success in %dms", result.ElapsedMs)

Build docs developers (and LLMs) love