vid.to.images.Rd
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,
...
)
character; path of video file to be processed.
character; directory path in which to store images.
character; image format such as "png" or "jpg"; must be available from av_encoders
.
character; a string defining an ffmpeg filter, the -vf
argument in the ffmpeg command line utility. Passed to av_encode_video
logical; should images in path described by 'out.dir' be overwritten if they exists.
other arguments to be passed to av_encode_video
.
Extracts all the images of the video and saves them to an "images" directory with appended number sequence.
#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)