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 byffm_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
startandendare 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, asetptsfilter is added after the trim.
References
https://ffmpeg.org/ffmpeg-filters.html#trim
https://ffmpeg.org/ffmpeg-utils.html#time-duration-syntax
See also
ffm_seek(), the faster cut by seeking, which can use stream copy.
ffm_trim() is the filter that cuts on exact frames.
Other pipeline functions:
ffm_batch(),
ffm_codec(),
ffm_compile(),
ffm_concat(),
ffm_copy(),
ffm_crop(),
ffm_drawbox(),
ffm_drop(),
ffm_files(),
ffm_fps(),
ffm_hstack(),
ffm_jobs(),
ffm_loudnorm(),
ffm_map(),
ffm_output_options(),
ffm_overlay(),
ffm_pixel_format(),
ffm_run(),
ffm_scale(),
ffm_seek(),
ffm_vstack(),
print.tidymedia_ffm()
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\""