ffm_crop: Crop Frames in an FFmpeg Pipeline

View source: R/ffm.R

ffm_cropR Documentation

Crop Frames in an FFmpeg Pipeline

Description

Make the video's frames smaller by cropping them.

Usage

ffm_crop(object, width, height, x = "(in_w-out_w)/2", y = "(in_h-out_h)/2")

Arguments

object

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

width

The width of the output video, in pixels. Give a positive real number or a string that contains an FFmpeg expression.

height

The height of the output video, in pixels. Give a positive real number or a string that contains an FFmpeg expression.

x

The horizontal position of the left edge of the output video, in pixels of the input video. Give a positive real number or a string that contains an FFmpeg expression. The default is "(in_w-out_w)/2".

y

The vertical position of the top edge of the output video, in pixels of the input video. Give a positive real number or a string that contains an FFmpeg expression. The default is "(in_h-out_h)/2".

Value

object with an added instruction to crop the frames.

References

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

See Also

ffm_scale() to resize instead of crop. crop_video() and format_for_web() are the task functions built on ffm_crop().

Other pipeline functions: ffm_batch(), ffm_codec(), ffm_compile(), ffm_concat(), ffm_copy(), 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_trim(), ffm_vstack(), print.tidymedia_ffm()

Examples

video <- system.file("extdata", "sample.mp4", package = "tidymedia")
# Crop to a centered 160x120 region
ffm_files(video, "output.mp4") |>
  ffm_crop(width = 160, height = 120) |>
  ffm_compile()

tidymedia documentation built on Oct. 11, 2026, 5:08 p.m.