Add a video filter that draws a colored rectangle on the input video.
Usage
ffm_drawbox(
object,
x = 0,
y = 0,
width = "in_w",
height = "in_h",
color = "black",
thickness = "fill"
)Arguments
- object
An FFmpeg pipeline (
ffm) object created byffm_files().- x
The horizontal position of the left edge of the box, in pixels of the input video. Give a nonnegative real number or a string that contains an FFmpeg expression. The default is
0.- y
The vertical position of the top edge of the box, in pixels of the input video. Give a nonnegative real number or a string that contains an FFmpeg expression. The default is
0.- width
The width of the box, in pixels. Give a positive real number or a string that contains an FFmpeg expression. The default is
"in_w".- height
The height of the box, in pixels. Give a positive real number or a string that contains an FFmpeg expression. The default is
"in_h".- color
A string with the color of the box, in FFmpeg color syntax. The reference link below explains that syntax. With the special value
"invert", the box has the color of the video with inverted luma. The default is"black".- thickness
The thickness of the box edge, in pixels. The value
"fill"draws a filled box. The default is"fill".
References
https://ffmpeg.org/ffmpeg-filters.html#drawbox
https://ffmpeg.org/ffmpeg-utils.html#color-syntax
See also
anonymize_video(), the task function that uses
ffm_drawbox() to fill regions.
Other pipeline functions:
ffm_batch(),
ffm_codec(),
ffm_compile(),
ffm_concat(),
ffm_copy(),
ffm_crop(),
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")
# Draw a filled red box covering the top-left quarter of the frame
ffm_files(video, "output.mp4") |>
ffm_drawbox(width = "in_w/2", height = "in_h/2", color = "red") |>
ffm_compile()
#> [1] "-y -i \"/home/runner/work/_temp/Library/tidymedia/extdata/sample.mp4\" -vf \"drawbox=x=0:y=0:w=in_w/2:h=in_h/2:c=red:t=fill\" \"output.mp4\""