| separate_audio_video_batch | R Documentation |
Split the audio and video streams of many input files from a single jobs
tibble. This is the batch (table-driven) form of
separate_audio_video(), for when you have more than one file. Each row is
one input that gives two outputs. The input,
audiofile and videofile columns are all required. The function
is a thin wrapper over ffm_batch. It turns every input row into
two single-output jobs, one per stream. So a jobs table of N rows
returns 2N rows, with one reproducible compiled command per stream.
Each stream uses the same map and stream-copy pipeline as
separate_audio_video(). The glossary in vignette("tidymedia")
explains media terms such as codec, container and stream copy.
separate_audio_video_batch(
jobs,
audio_codec = "copy",
video_codec = "copy",
hardware = c("none", "nvenc", "videotoolbox"),
fallback = FALSE,
quality = NULL,
audio_stream = NULL,
run = TRUE,
parallel = FALSE,
...
)
jobs |
A data frame with one row per input. It has at least an
|
audio_codec |
A string that names the encoder for every
|
video_codec |
A string that names the encoder for every
|
hardware, fallback |
The encoder backend for every |
quality |
A number, or |
audio_stream |
The audio track to write to each |
run |
A logical: run each command through FFmpeg ( |
parallel |
A logical: process the jobs in parallel with furrr
( |
... |
Additional arguments forwarded to |
A tibble with two rows per input,
one per stream. It has the reshaped input, a single output
path, a stream marker ("audio" or "video"), and an
added command column. When run = TRUE, it also has a
success column. A run also gives verified and the
provenance manifest, each when requested via .... When jobs supplies
either codec column, a
single codec column carries each row's resolved encoder for its own
stream (NA where none is set). When audio_stream is supplied
as either the argument or a jobs column, an audio_stream
column likewise carries each row's resolved track. That is the selected
index on an audio row. It is NA on every video row, which takes no
audio, and on an audio row that named no track. So NA does not by
itself mark a video row. Read the stream column for that. The
columns match the output of the other _batch functions, plus the
stream marker. See ffm_batch.
A row whose audio command does not finish cleanly is recorded as
success = FALSE, and the batch does not abort. One warning for the
whole batch, emitted once, names such rows. It lists every affected
input row and the ways out.
A row reaches that warning only when all four of these hold:
It named no audio_stream.
The row is recorded success = FALSE.
Its input carries more than one audio track.
The extension of its audiofile is not among the containers
named here as holding several audio streams.
Those containers are .mka, .m4a, .mp4, .mov, .mkv, .webm, .ogg, .opus and .ts. No exit status is among those
conditions, and the difference from separate_audio_video is
deliberate. The batch runner records whether a row succeeded and not
how. So it records a non-zero exit, a hard error and a reached limit the same
way. It treats alike a row put here by any of them. The
nine are an exclusion list and not a survey. FFmpeg
writes several audio streams into other containers too, .avi and
.nut among them. A row that fails on one of those is still named. The
container condition keeps a row off the list when it already does what the
warning advises. Such a row is silently not named. A batch whose failed audio
rows all write to those nine does not warn at all. The
headline count follows the rows actually named.
Each bullet of the warning states what that row did: its track count, and that every track was mapped into one output. It never states why FFmpeg refused. Several causes look alike from here. Examples are a stream copy into a container that will not hold the source codec, an unknown encoder and a missing output directory.
The check runs FFprobe on the failed rows only. So the function emits the
warning when FFprobe is available and the input can be probed, and skips it
silently otherwise. The warning may not appear, and its absence is never
itself a second failure. The check never runs under run = FALSE and
never changes any compiled command. Suppress the warning with
suppressWarnings(classes = "tidymedia_multitrack_separation").
The warning names the same event as the error of
separate_audio_video and answers to the same class. But it
carries no exit status: no tm_status field, and no
tidymedia_ffmpeg_exit class. The batch runner records, per row,
whether the row succeeded, not how FFmpeg exited. The
success column holds that record. So the exit number is gone by the
time this warning is assembled. To catch a specific row's exit status, use
separate_audio_video().
separate_audio_video(), the one-file function it wraps.
ffm_batch(), the batch runner.
has_hardware_encoder() for the hardware argument.
segment_video_batch() for the other batch function where one input file
can give several outputs.
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(),
normalize_audio_batch(),
picture_in_picture(),
picture_in_picture_batch(),
sample_frames(),
sample_frames_batch(),
segment_video(),
segment_video_batch(),
separate_audio_video(),
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(),
normalize_audio_batch(),
picture_in_picture(),
picture_in_picture_batch(),
segment_video(),
segment_video_batch(),
separate_audio_video(),
standardize_video(),
standardize_video_batch()
video <- system.file("extdata", "sample.mp4", package = "tidymedia")
jobs <- tibble::tibble(
input = c(video, video),
audiofile = c("a1.aac", "a2.aac"),
videofile = c("v1.mp4", "v2.mp4")
)
# run = FALSE compiles two commands per input without calling FFmpeg
separate_audio_video_batch(jobs, run = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.