audio_concat: Concatenate Audio Files with Exact Silence Gaps

View source: R/audio_concat.R

audio_concatR Documentation

Concatenate Audio Files with Exact Silence Gaps

Description

Joins inputs in order into one audio file, inserting gap seconds of silence between consecutive inputs and tail seconds after the last. Every input is resampled and remixed to a common format first, so inputs need not match. One encode, chosen by the output extension.

Usage

audio_concat(inputs, output, gap = 0, tail = 0, sample_rate = NULL,
             channels = NULL, bitrate = NULL, overwrite = TRUE, dry_run = FALSE)

Arguments

inputs

Character vector of audio file paths, in order.

output

Path for the output audio file; extension selects the format.

gap

Silence in seconds between consecutive inputs (default 0).

tail

Silence in seconds appended after the last input (default 0).

sample_rate

Output sample rate in Hz, or NULL (default) to use the first input's rate.

channels

Output channel count (1 = mono, 2 = stereo), or NULL (default) to use the first input's count.

bitrate

Output audio bitrate (e.g. "192k"), or NULL for the encoder default. Ignored by lossless formats such as WAV.

overwrite

If TRUE (default), overwrite the output file.

dry_run

If TRUE, return the FFmpeg command without executing.

Value

Invisibly returns the output path. If dry_run, returns the command string.

Examples

## Not run: 
audio_concat(c("slide01.wav", "slide02.wav"), "audio.mp3",
             gap = 0.35, tail = 0.5)

## End(Not run)


compost documentation built on Aug. 4, 2026, 5:11 p.m.