Uses ffmpeg through the av package to extract images from a video.

vid.to.images(
  vid.path = NULL,
  out.dir = NULL,
  format = "jpg",
  vfilter = NULL,
  overwrite = FALSE,
  ...
)

Arguments

vid.path

character; path of video file to be processed.

out.dir

character; directory path in which to store images.

format

character; image format such as "png" or "jpg"; must be available from av_encoders.

vfilter

character; a string defining an ffmpeg filter, the -vf argument in the ffmpeg command line utility. Passed to av_encode_video

overwrite

logical; should images in path described by 'out.dir' be overwritten if they exists.

...

other arguments to be passed to av_encode_video.

Value

Extracts all the images of the video and saves them to an "images" directory with appended number sequence.

Examples


#access video that loads with package
v <-system.file("extdata/vid", "sunfish_BCF.avi", package = "trackter")

#create directory in which to store images
dir.create(paste0(tempdir(),"/images"))
#> Warning: '/var/folders/5c/s3c2hjfd7blbqwwpl1q10wxm0000gy/T//RtmpNMLlNq/images' already exists

vid.to.images(vid.path=v,out.dir= paste0(tempdir(),"/images"))
#> Extra audio frame dropped from output

#see the images in the "images" subdirectory
list.files( paste0(tempdir(),"/images"))
#> [1] "sunfish001.jpg"         "sunfish_BCF_000001.jpg" "sunfish_BCF_000002.jpg"

#clean up
unlink(paste0(tempdir(),"/images"),recursive=TRUE)