Skip to contents

Trim the input so that the output keeps one continuous part of the input. If start is NULL, the kept section starts at the beginning of the input. If both end and duration are NULL, the kept section ends at the end of the input. The glossary in vignette("tidymedia") explains media terms such as stream copy.

Usage

ffm_trim(
  object,
  start = NULL,
  end = NULL,
  duration = NULL,
  units = c("tds", "pts", "frame"),
  setpts = TRUE
)

Arguments

object

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

start

The time of the start of the kept section, given in units. The frame at this time is the first frame of the output.

end

The time of the first frame that is dropped, given in units. The frame just before it is the last frame of the output.

duration

The maximum duration of the output, given in time duration syntax.

units

A string that says how start and end are given: time duration syntax ("tds"), timebase units ("pts") or frame numbers ("frame"). The default is "tds".

setpts

A logical that says whether the output timestamps change to start at zero. If TRUE, a setpts filter is added after the trim.

Value

object with added instructions to trim the duration.

References

https://ffmpeg.org/ffmpeg-filters.html#trim

https://ffmpeg.org/ffmpeg-utils.html#time-duration-syntax

See also

Examples

video <- system.file("extdata", "sample.mp4", package = "tidymedia")
ffm_files(video, "output.mp4") |>
  ffm_trim(start = 1, end = 5) |>
  ffm_compile()
#> [1] "-y -i \"/home/runner/work/_temp/Library/tidymedia/extdata/sample.mp4\" -vf \"trim=start=1:end=5,setpts=PTS-STARTPTS\" \"output.mp4\""