| normalize_audio_batch | R Documentation |
Normalize the audio loudness of many input files (EBU R128) from a single
jobs tibble. This is the batch (table-driven) form of
normalize_audio(), for when you have more than one file to normalize. Each
row is one input, and the only required column names its source. The function
is a thin wrapper over ffm_batch. It gives one reproducible
compiled command per input. Each row uses the same loudnorm pipeline,
and the same check of each value, as normalize_audio(). Set
two_pass = TRUE for accurate measured/linear normalization across the
whole table (see two_pass). The glossary in
vignette("tidymedia") explains media terms such as LUFS, encoder and
sample rate.
normalize_audio_batch(
jobs,
target_loudness = -23,
true_peak = -1,
loudness_range = 7,
channels = NULL,
sample_rate = NULL,
audio_codec = NULL,
two_pass = FALSE,
audio_stream = NULL,
run = TRUE,
parallel = FALSE,
...
)
jobs |
A data frame with one row per input and (at least) an
|
target_loudness, true_peak, loudness_range |
The EBU R128 loudness targets
applied to every row, unless |
channels |
The output channel count applied to every row, unless
|
sample_rate |
The output sample rate in Hz applied to every row, unless
|
audio_codec |
The output audio encoder applied to every row, unless
|
two_pass |
A logical that selects the normalization mode for
every row. It applies to the whole table and is not a per-row
column. |
audio_stream |
The audio track to normalize, as a number that counts from |
run |
A logical: run each input's command through FFmpeg ( |
parallel |
A logical passed to |
... |
Additional arguments forwarded to |
The function warns once for the whole batch when a row names no
audio_stream and its input carries tracks that the output will not.
The warning names every affected row. Naming a track silences it. Use the
audio_stream argument, or an audio_stream cell on every row.
suppressWarnings(classes = "tidymedia_dropped_audio") silences it
too.
The check costs one FFprobe call per distinct input it has to probe. A repeated input is probed once, and a row that names a track is not probed at all. The warning is given when FFprobe is available and the input can be probed. Otherwise the check is skipped silently. Those probes run one at a time, before any row starts, so parallel does not reach them. A sweep long enough to look like a hang reports its progress. The check never runs under
run = FALSE and never changes any compiled command. It is skipped
entirely when every row names a track. Under two_pass = TRUE, the
warning comes before the analysis pass. So it arrives while adding
audio_stream can still save that pass.
To switch the check off and skip the whole sweep, use options(tidymedia.check_tracks = FALSE) for the session. Use withr::local_options(tidymedia.check_tracks = FALSE) for the rest of one function.
The tibble returned by ffm_batch: jobs with an added command column. When output was derived, it also has the resolved output column. When run = TRUE, it has a success column, plus any columns the forwarded arguments add, such as verified. Under two_pass = TRUE, the result
also carries the five measured columns (measured_I etc.) and a
logical silent column. The command column then holds the
linear correction commands. It is NA for silent rows, which carry
NA measurements and are not normalized. The columns of the two-pass
result do not depend on how many rows are silent. The verified
column (under verify) and the provenance manifest (under
manifest, read with ffm_manifest) are present
whenever requested. That holds even when every row is silent.
Silent rows carry NA for those outputs.
EBU Recommendation R 128 (2014), Loudness normalisation and permitted maximum level of audio signals; ITU-R BS.1770-4.
normalize_audio() for the single-input form.
ffm_batch() for the batch runner and the arguments forwarded through
....
standardize_video_batch() for the table-driven form on the video side.
Other task functions:
anonymize_video(),
anonymize_video_batch(),
compare_videos(),
compare_videos_batch(),
concatenate_videos(),
concatenate_videos_batch(),
convert_audio(),
convert_audio_batch(),
crop_video(),
crop_video_batch(),
extract_audio(),
extract_audio_batch(),
extract_frame(),
extract_frame_batch(),
format_for_web(),
format_for_web_batch(),
normalize_audio(),
picture_in_picture(),
picture_in_picture_batch(),
sample_frames(),
sample_frames_batch(),
segment_video(),
segment_video_batch(),
separate_audio_video(),
separate_audio_video_batch(),
standardize_video(),
standardize_video_batch(),
strip_metadata(),
strip_metadata_batch()
Other audio selection functions:
anonymize_video(),
anonymize_video_batch(),
audio_stream,
compare_videos(),
compare_videos_batch(),
convert_audio(),
convert_audio_batch(),
crop_video(),
crop_video_batch(),
extract_audio(),
extract_audio_batch(),
format_for_web(),
format_for_web_batch(),
normalize_audio(),
picture_in_picture(),
picture_in_picture_batch(),
segment_video(),
segment_video_batch(),
separate_audio_video(),
separate_audio_video_batch(),
standardize_video(),
standardize_video_batch()
video <- system.file("extdata", "sample.mp4", package = "tidymedia")
jobs <- tibble::tibble(
input = c(video, video),
output = c(tempfile(fileext = ".m4a"), tempfile(fileext = ".m4a")),
target_loudness = c(-23, -16)
)
# run = FALSE compiles one command per input without calling FFmpeg
normalize_audio_batch(jobs, run = FALSE)
# Accurate two-pass (measured/linear) normalization across the whole table.
# This one runs FFmpeg to measure each input, so it needs the binary, and it
# re-encodes, so it needs an encoder this build has.
if (nzchar(Sys.which("ffmpeg")) && has_encoder("aac")) {
normalize_audio_batch(jobs, two_pass = TRUE, audio_codec = "aac")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.