images.to.video: Stitches images into a video file

Description Usage Arguments Details Value See Also Examples

View source: R/ffmpeg.R

Description

Stitches images into a video file of type indicated by "vid.ext"

Usage

1
2
3
4
5
6
7
8
9
images.to.video(
  image.dir = NULL,
  out.dir = NULL,
  vid.name = NULL,
  qual = 50,
  frame.rate = 10,
  overwrite = FALSE,
  silent = TRUE
)

Arguments

image.dir

character; directory containing images to stitch.

out.dir

character; directory in which to store video.

vid.name

character; file name given to video including extension. mp4 currently works best.

qual

numeric; the quality of the video rendered from 1-100%. Defaults to 50%.

frame.rate

numeric; video frame rate in fps.

overwrite

logical; should path described by vid.name be overwritten if it exhists.

silent

logical; should output of system call for ffmpeg operation be suppressed.

Details

Assumes images are appended with a numeric sequence.

Value

Outputs a video of name "video.name+vid.ext".

See Also

vid.to.images

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#make some images

dir.create(paste0(tempdir(),"/images")) #make a directory to store images

a <- 2
b <- 3
theta <- seq(0,10*pi,0.01)
r <- a + b*theta
df <- data.frame(x=r*cos(theta), y=r*sin(theta)) # Cartesian coords
every.i <- 30
for(i in seq(1,length(theta),30)) {
  jpeg(paste0(tempdir(),"/images/image_",sprintf("%03d",which(i==seq(1,length(theta),30))),".jpg"))
  with(df[1:i,],plot(x,y,xlim=range(df$x),ylim=range(df$y),col="red"))
  dev.off()
  }

images.to.video(image.dir=paste0(tempdir(),"/images"),
vid.name="spiral.mp4",out.dir=tempdir(),
frame.rate=5,qual=100,silent=TRUE,overwrite=TRUE)

file.exists(paste0(tempdir(),"/spiral.mp4"))

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

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