videor is an R package for video analysis based on the package 'imager'.
You can install videor from GitHub.
Note that you need to install FFmpeg and FFprobe.
Run the following R code to install videor.
devtools::install_github("ShotaOchi/videor")
videor has only two functions now.
- info_video
- load_video
info_video returns a list containg video information.
load_video returns a cimg object that is specified frames of video.
load_video works with avi, gif, mp4, webm, and wmv.
library(videor)
video <- system.file("extdata", "counts.gif", package = "videor")
# get video information
info_video(video)
# load first frame of video
load_video(video, 1)
# load a part of video (from 4th frame to 8th frame)
load_video(video, c(4, 8))
# load a part of video (from 4th frame to 8th frame, every 2 frames)
load_video(video, c(4, 8), step = 2)
load_video uses info_video to get the number of frames.
However, info_video is slow except when video is mp4 file.
That's why load_video has the argument nb_frames, which enables us to tell the number of frames to load_video.
nb_frames <- info_video(video)$frames
load_video(video, c(10, 20), nb_frames)
I'm going to add functions in the future, but not soon.
a <- load_video(video, c(1, 3))
# extract first frame
frame(a,1) %>% plot
a <- load_video(video, c(1, 3))
# apply isoblur function to all frames
iiply(a, "z", isoblur, sigma = 5) %>% play(delay = 300, loop = TRUE)
a1 <- load_video(video, 1)
a2 <- load_video(video, 2)
a3 <- load_video(video, 3)
imappend(ci(a1, a2, a3), "z") %>% play(delay = 300, loop = TRUE)
You're welcome to create issues for any bug report or suggestion on the issues page.
You can also fork this repository and send me a pull request for bug fixes or additional features.