vid.to.images: Extracts images from a video file with ffmpeg

Description Usage Arguments Value See Also Examples

View source: R/ffmpeg.R

Description

Uses ffmpeg systems calls to extract images from a video.

Usage

1
vid.to.images(vid.path = NULL, out.dir = NULL, overwrite = FALSE, qual = 50)

Arguments

vid.path

Character; path of video file to be processed.

out.dir

character; directory path in which to store images.

overwrite

logical; should path described by 'out.dir' be overwritten if it exhists.

qual

numeric; the quality of the jpeg images to be rendered from 1-100%. Defaults to 50%.

Value

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

See Also

images.to.video

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#make a video with animation package

require(animation)
fun <- function(){
y <- sin(1:50)
x <- 1:50
for(i in 1:50) {
  plot(x[i],y[i],col="red",xlim=c(0,50),ylim=range(y))
  animation::ani.pause()
  }
}
animation::saveVideo(fun(),video.name=paste0(tempdir(),"/wave.mp4"),interval = 0.2)

#create directory in which to store images
dir.create(paste0(tempdir(),"/images"))
vid.to.images(vid.path=paste0(tempdir(),"/wave.mp4"),
out.dir= paste0(tempdir(),"/images"),qual=100)

#see the images in the "images" subdirectory
list.files( paste0(tempdir(),"/images"))

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

trackter documentation built on April 19, 2021, 1:08 a.m.