Skip to contents

Copy the audio, the video, or both, with stream copy and no re-encoding. It can also map all streams from the input. This is the fast, lossless path when you only need to put the streams in a new container or cut on keyframes. The glossary in vignette("tidymedia") explains media terms such as codec, container, keyframe and stream copy.

Usage

ffm_copy(object, audio = TRUE, video = TRUE, streams = TRUE)

Arguments

object

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

audio

A logical. TRUE (the default) copies the audio codec. See audio_stream for the two things that the name audio means in the pipeline functions, and for the input index audio_input.

video

A logical. TRUE (the default) copies the video codec.

streams

A logical. TRUE (the default) maps all streams from the input. It sets the mapping to the all-streams specifier "0", and does not add to it. So two ffm_copy() calls compile one -map "0", not two. If the pipeline already has a different mapping, ffm_copy() gives an error and does not discard that mapping silently. To keep the mapping you set, pass streams = FALSE. Or call ffm_copy() first, and then narrow the mapping with ffm_map(replace = TRUE).

Value

object with an added instruction to copy codecs, map all streams, or both.

Examples

video <- system.file("extdata", "sample.mp4", package = "tidymedia")
ffm_files(video, "output.mp4") |>
  ffm_copy() |>
  ffm_compile()
#> [1] "-y -i \"/home/runner/work/_temp/Library/tidymedia/extdata/sample.mp4\" -codec:v copy -codec:a copy -map \"0\" \"output.mp4\""