Skip to contents

Resample the video to a constant frame rate with FFmpeg's fps filter. The filter duplicates or drops frames as needed. It is added to the end of the video filters, like the other filters that take one input. The glossary in vignette("tidymedia") explains media terms such as frame rate.

Usage

ffm_fps(object, fps)

Arguments

object

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

fps

The target frame rate. Give a positive double (an R number such as 30) of frames per second, or a string, such as an FFmpeg frame rate expression. For example, "30000/1001" is the NTSC rate. An integer such as 30L is refused, and so is NA. Any other string is not checked, and it goes into the FFmpeg command as written.

Value

object with an added instruction to resample the frame rate.

Examples

video <- system.file("extdata", "sample.mp4", package = "tidymedia")
ffm_files(video, "output.mp4") |>
  ffm_fps(fps = 30) |>
  ffm_compile()
#> [1] "-y -i \"/home/runner/work/_temp/Library/tidymedia/extdata/sample.mp4\" -vf \"fps=30\" \"output.mp4\""