video: Video record animated telemetry objects.

View source: R/animate.R

videoR Documentation

Video record animated telemetry objects.

Description

Produces an MP4 video file by animating telemetry objects.

Usage

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(),...)

Arguments

x

telemetry object or list of telemetry objects.

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 c(width,height) for rectangular videos.

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 telemetry points.

par.list

List of additional arguments passed to par within animate that do not work outside of animate, like mar.

...

Additional options passed to plot.telemetry.

Details

This function does not interpolate locations to make smooth animations. For that, please use predict or simulate outputs instead of a raw tracking data.

Value

Saves an MP4 file named file to the working directory.

Note

Further animation and ffmpeg options can be set via ani.options.

Author(s)

C. H. Fleming.

See Also

plot, plot.telemetry, ani.options

Examples


# 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)

ctmm-initiative/ctmm documentation built on April 18, 2024, 9:39 a.m.