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

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.

Author

C. H. Fleming.

Note

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

See also

Examples

# \donttest{ # 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)
#> animation option 'nmax' changed: 50 --> 162
#> Error in system(paste(ffmpeg, "-version"), intern = TRUE) : #> error in running command
#> Warning: The command "'ffmpeg'" is not available in your system. Please install FFmpeg or avconv first: http://ffmpeg.org/download.html
#> animation option 'nmax' changed: 162 --> 50
#> NULL
# prediction (distribution) video(PRED,error=3,file=FILE)
#> animation option 'nmax' changed: 50 --> 162
#> Error in system(paste(ffmpeg, "-version"), intern = TRUE) : #> error in running command
#> Warning: The command "'ffmpeg'" is not available in your system. Please install FFmpeg or avconv first: http://ffmpeg.org/download.html
#> animation option 'nmax' changed: 162 --> 50
#> NULL
# conditional simulations SIMS <- lapply(1:6,function(i){simulate(coati[[2]],FIT,t=t)}) # random paths video(SIMS,pch=16,ghost=ghost,file=FILE)
#> animation option 'nmax' changed: 50 --> 162
#> Error in system(paste(ffmpeg, "-version"), intern = TRUE) : #> error in running command
#> Warning: The command "'ffmpeg'" is not available in your system. Please install FFmpeg or avconv first: http://ffmpeg.org/download.html
#> animation option 'nmax' changed: 162 --> 50
#> NULL
# }