video | R Documentation |
Produces an MP4 video file by animating telemetry objects.
video(x,ext=extent(x),fps=60,dt=NULL,ghost=0,timestamp=FALSE,file="ctmm.mp4",res=720,
col="red",pch=1,cex=NULL,lwd=1,par.list=list(),...)
x |
|
ext |
Plot extent for all frames. |
fps |
Frames per viewed second. |
dt |
Tracked time per frame (not per viewed second). By default, the median timestep will be used. |
ghost |
Timescale over which image retention (ghosting) decays. |
timestamp |
Display timestamps on title. |
file |
File name for MP4 file to save. The full path can also be specified. Otherwise the working directory will be used. |
res |
Pixel resolution for square videos or pixel |
col |
Color option for telemetry data. Can be an array or list of arrays. |
pch |
Plotting symbol. Can be an array or list of arrays. |
cex |
Relative size of plotting symbols. Only used when errors are missing. |
lwd |
Line widths of |
par.list |
List of additional arguments passed to |
... |
Additional options passed to |
This function does not interpolate locations to make smooth animations. For that, please use predict
or simulate
outputs instead of a raw tracking data.
Saves an MP4 file named file
to the working directory.
Further animation
and ffmpeg options can be set via ani.options
.
C. H. Fleming.
plot
, plot.telemetry
, ani.options
# Load package and data
library(ctmm)
data(coati)
# temporary file to store videos for CRAN compliance
FILE <- tempfile("ctmm",fileext=".mp4")
# you will likely want to save your video elsewhere
# the working directory is the default location
# create guess object
GUESS <- ctmm.guess(coati[[2]],interactive=FALSE)
# in general, use ctmm.select instead of ctmm.fit
FIT <- ctmm.fit(coati[[2]],GUESS)
# consider a few hours of consecutive sampling, at 1 minute per frame
t <- seq(coati[[2]]$t[19],coati[[2]]$t[27],by=60)
# tau[velocity] is a natural scale to demonstrate persistance of motion
ghost <- FIT$tau[2]
# predicted locations each minute
PRED <- predict(coati[[2]],FIT,t=t)
# most likely path
video(PRED,error=FALSE,pch=16,ghost=ghost,file=FILE)
# prediction (distribution)
video(PRED,error=3,file=FILE)
# conditional simulations
SIMS <- lapply(1:6,function(i){simulate(coati[[2]],FIT,t=t)})
# random paths
video(SIMS,pch=16,ghost=ghost,file=FILE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.