Skip to contents

Add a complex video filter that stacks several videos vertically (one above the other). It can also resize the videos to the same width.

Usage

ffm_vstack(object, shortest = FALSE, resize = FALSE)

Arguments

object

An FFmpeg pipeline (ffm) object created by ffm_files().

shortest

A logical that says whether to trim the duration of all videos to that of the shortest video. The default is FALSE.

resize

A logical that says whether to resize the input videos to the same width. Resizing takes longer, and for now it works only with two inputs. It fits both inputs to the same aspect ratio, so it assumes the inputs share one.

Value

object with an added instruction to stack the videos vertically.

Details

This is the vertical form of ffm_hstack. Both are pipeline functions for several inputs. They force the -filter_complex path and manage their own stream labels internally. The glossary in vignette("tidymedia") explains media terms such as stream.

Examples

video <- system.file("extdata", "sample.mp4", package = "tidymedia")
# Stack two inputs one above the other (pass more than one input to ffm_files())
ffm_files(c(video, video), "output.mp4") |>
  ffm_vstack() |>
  ffm_compile()
#> [1] "-y -i \"/home/runner/work/_temp/Library/tidymedia/extdata/sample.mp4\" -i \"/home/runner/work/_temp/Library/tidymedia/extdata/sample.mp4\" -filter_complex \"[0:v][1:v]vstack=inputs=2:shortest=0[vout]\" -map \"[vout]\" \"output.mp4\""