Stack videos side by side for many outputs from a single jobs tibble. This is
the batch (table-driven) form of compare_videos(), for when you have
more than one comparison to produce. Each row carries an inputs
list-column (each cell two or more video paths) plus an output column.
This is a thin wrapper over ffm_batch: one reproducible stacking
command per row, sharing the pipeline with compare_videos(). The glossary
in vignette("tidymedia") explains media terms such as codec, encoder
and stream copy.
Arguments
- jobs
A data frame with one row per output and (at least) an
inputslist-column and anoutputcolumn (destination path). Eachinputscell is a character vector of two or more video paths. Optionaldirection,resize,audio_input,video_codec, andaudio_codeccolumns override the like-named arguments per row (a row omitting one falls back to the argument). In anaudio_inputcolumn,NAmeans "drop audio", the column's way of writing the scalar'sNULL. In avideo_codecoraudio_codeccolumn, it means "leave the codec unset". A numericqualitycolumn overrides thequalityargument per row (seequality). Two rows given the sameoutputpath are refused before any row runs; other columns are ignored.- direction, resize
Defaults applied to every row lacking the corresponding column.
directionis"horizontal"(the default) or"vertical"; adirectioncolumn is held to the same two values, per row. Seecompare_videos()for their fuller meaning.- audio_input
The input file whose audio to keep, as a number that counts from
0.0is the first file you pass and1is the second. This counts the function's inputs, not the audio tracks of one input. So it is a different index fromaudio_streamon the functions that take one input.NULL(default) selects no audio at all, so the output is silent. This differs fromaudio_stream = NULL, which still selects audio. An input number the call does not have gives an R error, before FFmpeg runs. Without anaudio_inputcolumn, the argument applies to every row. AnNAcell in that column meansNULLfor that row, so that output has no audio. Each row's value is validated against that row's input count. Seeaudio_stream. (default =NULL)- video_codec
A string naming the output video codec, applied to every row lacking a
video_codeccolumn.NULL(default) leaves it unset, so each output keeps its container's default encoder.- audio_codec
A string naming the codec for the carried audio track, applied to every row lacking an
audio_codeccolumn."copy"(default) stream-copies it. Name an encoder to re-encode it, orNULLto leave the codec unset. A row carrying no audio emits no-codec:a, and naming an encoder on such a row is an error.- hardware, fallback
The encoder backend and its fallback behavior, applied to the whole batch. They are a property of the machine, not of a row, so neither is read as a
jobscolumn. Seecompare_videos(). Resolving a hardware backend asks this FFmpeg build which encoders it has. So the first such call that re-encodes the video runs FFmpeg while the command is built, even underrun = FALSE. The answer is remembered for the rest of the R session. Seerefresh_ffmpeg_capabilitiesto discard it. This function checks that the encoder is available before any row runs. So an unavailable encoder aborts naming this function, not the internal step that runs the rows. A call can also contradict itself by naming anaudio_codecwith no audio carried into the output. Such a call is refused for the contradiction first, whether or not this machine has the encoder. A per-row value error likewise reports ahead of the encoder check. Examples are anaudio_inputindex past that row's input count, and adirectionoutside the two accepted values. A value error and a contradiction resolve the same way whether the value arrived as an argument or in ajobscolumn. The contradiction reports first.- quality
A number, or
NULL(default), applied to each row unlessjobscarries a numericqualitycolumn. In that column,NAleaves that row's encoder default in place, whatever the argument says. The value is the encoder's own rate-control value, passed through unchanged. Each cell is checked against the encoder its own row resolves to. A wrong cell is refused before any row runs, and the error names this function and the row. Seecompare_videos()for the encoders, their flags and ranges, and the values it refuses.- run
A logical: run each command through FFmpeg (
TRUE, default) or only compile them for inspection (FALSE).- parallel
A logical: process the jobs in parallel with furrr (
TRUE) or one at a time (FALSE, default). Seeffm_batchfor the future plan requirement.- ...
Additional arguments forwarded to
ffm_batch(e.g.verify,manifest,progress).
Value
The jobs tibble with an added command column. When run = TRUE, it also has a success column, plus verified or a provenance manifest, each when requested through .... See ffm_batch.
See also
compare_videos(), the one-output function it wraps; ffm_batch(),
the batch runner; has_hardware_encoder() for the hardware
argument. concatenate_videos_batch() and picture_in_picture_batch(),
the other batch functions that take several inputs per row.
Other task functions:
anonymize_video(),
anonymize_video_batch(),
compare_videos(),
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(),
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(),
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(),
separate_audio_video_batch(),
standardize_video(),
standardize_video_batch()
Examples
video <- system.file("extdata", "sample.mp4", package = "tidymedia")
jobs <- tibble::tibble(inputs = list(c(video, video)), output = "compare.mp4")
compare_videos_batch(jobs, run = FALSE)
#> # A tibble: 1 × 3
#> inputs output command
#> <list> <chr> <chr>
#> 1 <chr [2]> compare.mp4 "-y -i \"/home/runner/work/_temp/Library/tidymedia/extd…