video.Rd
Produces an MP4 video file by animating telemetry objects.
telemetry
object or list of telemetry
objects.
Plot extent for all frames.
Frames per viewed second.
Tracked time per frame (not per viewed second). By default, the median timestep will be used.
Timescale over which image retention (ghosting) decays.
Display timestamps on title.
File name for MP4 file to save. The full path can also be specified. Otherwise the working directory will be used.
Pixel resolution for square videos or pixel c(width,height)
for rectangular videos.
Color option for telemetry data. Can be an array or list of arrays.
Plotting symbol. Can be an array or list of arrays.
Relative size of plotting symbols. Only used when errors are missing.
Line widths of telemetry
points.
List of additional arguments passed to par
within animate
that do not work outside of animate
, like mar
.
Additional options passed to plot.telemetry
.
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
.
# \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)
#>
|
| | 0%
#>
|
| | 1%
#>
|
|= | 1%
#>
|
|= | 2%
#>
|
|== | 2%
#>
|
|== | 3%
#>
|
|=== | 4%
#>
|
|=== | 5%
#>
|
|==== | 6%
#>
|
|===== | 7%
#>
|
|====== | 8%
#>
|
|====== | 9%
#>
|
|======= | 10%
#>
|
|======== | 11%
#>
|
|======== | 12%
#>
|
|========= | 12%
#>
|
|========= | 13%
#>
|
|========== | 14%
#>
|
|========== | 15%
#>
|
|=========== | 15%
#>
|
|=========== | 16%
#>
|
|============ | 17%
#>
|
|============= | 18%
#>
|
|============= | 19%
#>
|
|============== | 20%
#>
|
|=============== | 21%
#>
|
|=============== | 22%
#>
|
|================ | 22%
#>
|
|================ | 23%
#>
|
|================= | 24%
#>
|
|================= | 25%
#>
|
|================== | 25%
#>
|
|================== | 26%
#>
|
|=================== | 27%
#>
|
|=================== | 28%
#>
|
|==================== | 28%
#>
|
|==================== | 29%
#>
|
|===================== | 30%
#>
|
|====================== | 31%
#>
|
|====================== | 32%
#>
|
|======================= | 33%
#>
|
|======================== | 34%
#>
|
|======================== | 35%
#>
|
|========================= | 35%
#>
|
|========================= | 36%
#>
|
|========================== | 37%
#>
|
|========================== | 38%
#>
|
|=========================== | 38%
#>
|
|=========================== | 39%
#>
|
|============================ | 40%
#>
|
|============================= | 41%
#>
|
|============================= | 42%
#>
|
|============================== | 43%
#>
|
|=============================== | 44%
#>
|
|================================ | 45%
#>
|
|================================ | 46%
#>
|
|================================= | 47%
#>
|
|================================= | 48%
#>
|
|================================== | 48%
#>
|
|================================== | 49%
#>
|
|=================================== | 49%
#>
|
|=================================== | 50%
#>
|
|=================================== | 51%
#>
|
|==================================== | 51%
#>
|
|==================================== | 52%
#>
|
|===================================== | 52%
#>
|
|===================================== | 53%
#>
|
|====================================== | 54%
#>
|
|====================================== | 55%
#>
|
|======================================= | 56%
#>
|
|======================================== | 57%
#>
|
|========================================= | 58%
#>
|
|========================================= | 59%
#>
|
|========================================== | 60%
#>
|
|=========================================== | 61%
#>
|
|=========================================== | 62%
#>
|
|============================================ | 62%
#>
|
|============================================ | 63%
#>
|
|============================================= | 64%
#>
|
|============================================= | 65%
#>
|
|============================================== | 65%
#>
|
|============================================== | 66%
#>
|
|=============================================== | 67%
#>
|
|================================================ | 68%
#>
|
|================================================ | 69%
#>
|
|================================================= | 70%
#>
|
|================================================== | 71%
#>
|
|================================================== | 72%
#>
|
|=================================================== | 72%
#>
|
|=================================================== | 73%
#>
|
|==================================================== | 74%
#>
|
|==================================================== | 75%
#>
|
|===================================================== | 75%
#>
|
|===================================================== | 76%
#>
|
|====================================================== | 77%
#>
|
|====================================================== | 78%
#>
|
|======================================================= | 78%
#>
|
|======================================================= | 79%
#>
|
|======================================================== | 80%
#>
|
|========================================================= | 81%
#>
|
|========================================================= | 82%
#>
|
|========================================================== | 83%
#>
|
|=========================================================== | 84%
#>
|
|=========================================================== | 85%
#>
|
|============================================================ | 85%
#>
|
|============================================================ | 86%
#>
|
|============================================================= | 87%
#>
|
|============================================================= | 88%
#>
|
|============================================================== | 88%
#>
|
|============================================================== | 89%
#>
|
|=============================================================== | 90%
#>
|
|================================================================ | 91%
#>
|
|================================================================ | 92%
#>
|
|================================================================= | 93%
#>
|
|================================================================== | 94%
#>
|
|=================================================================== | 95%
#>
|
|=================================================================== | 96%
#>
|
|==================================================================== | 97%
#>
|
|==================================================================== | 98%
#>
|
|===================================================================== | 98%
#>
|
|===================================================================== | 99%
#>
|
|======================================================================| 99%
#>
|
|======================================================================| 100%
#> Executing: 'ffmpeg' -y -framerate 60 -i Rplot%d.png -pix_fmt yuv420p ctmm172635b6ee08.mp4
#>
#>
#> Video has been created at: /tmp/RtmpWKdDQj/ctmm172635b6ee08.mp4
# prediction (distribution)
video(PRED,error=3,file=FILE)
#>
|
| | 0%
#>
|
| | 1%
#>
|
|= | 1%
#>
|
|= | 2%
#>
|
|== | 2%
#>
|
|== | 3%
#>
|
|=== | 4%
#>
|
|=== | 5%
#>
|
|==== | 6%
#>
|
|===== | 7%
#>
|
|====== | 8%
#>
|
|====== | 9%
#>
|
|======= | 10%
#>
|
|======== | 11%
#>
|
|======== | 12%
#>
|
|========= | 12%
#>
|
|========= | 13%
#>
|
|========== | 14%
#>
|
|========== | 15%
#>
|
|=========== | 15%
#>
|
|=========== | 16%
#>
|
|============ | 17%
#>
|
|============= | 18%
#>
|
|============= | 19%
#>
|
|============== | 20%
#>
|
|=============== | 21%
#>
|
|=============== | 22%
#>
|
|================ | 22%
#>
|
|================ | 23%
#>
|
|================= | 24%
#>
|
|================= | 25%
#>
|
|================== | 25%
#>
|
|================== | 26%
#>
|
|=================== | 27%
#>
|
|=================== | 28%
#>
|
|==================== | 28%
#>
|
|==================== | 29%
#>
|
|===================== | 30%
#>
|
|====================== | 31%
#>
|
|====================== | 32%
#>
|
|======================= | 33%
#>
|
|======================== | 34%
#>
|
|======================== | 35%
#>
|
|========================= | 35%
#>
|
|========================= | 36%
#>
|
|========================== | 37%
#>
|
|========================== | 38%
#>
|
|=========================== | 38%
#>
|
|=========================== | 39%
#>
|
|============================ | 40%
#>
|
|============================= | 41%
#>
|
|============================= | 42%
#>
|
|============================== | 43%
#>
|
|=============================== | 44%
#>
|
|================================ | 45%
#>
|
|================================ | 46%
#>
|
|================================= | 47%
#>
|
|================================= | 48%
#>
|
|================================== | 48%
#>
|
|================================== | 49%
#>
|
|=================================== | 49%
#>
|
|=================================== | 50%
#>
|
|=================================== | 51%
#>
|
|==================================== | 51%
#>
|
|==================================== | 52%
#>
|
|===================================== | 52%
#>
|
|===================================== | 53%
#>
|
|====================================== | 54%
#>
|
|====================================== | 55%
#>
|
|======================================= | 56%
#>
|
|======================================== | 57%
#>
|
|========================================= | 58%
#>
|
|========================================= | 59%
#>
|
|========================================== | 60%
#>
|
|=========================================== | 61%
#>
|
|=========================================== | 62%
#>
|
|============================================ | 62%
#>
|
|============================================ | 63%
#>
|
|============================================= | 64%
#>
|
|============================================= | 65%
#>
|
|============================================== | 65%
#>
|
|============================================== | 66%
#>
|
|=============================================== | 67%
#>
|
|================================================ | 68%
#>
|
|================================================ | 69%
#>
|
|================================================= | 70%
#>
|
|================================================== | 71%
#>
|
|================================================== | 72%
#>
|
|=================================================== | 72%
#>
|
|=================================================== | 73%
#>
|
|==================================================== | 74%
#>
|
|==================================================== | 75%
#>
|
|===================================================== | 75%
#>
|
|===================================================== | 76%
#>
|
|====================================================== | 77%
#>
|
|====================================================== | 78%
#>
|
|======================================================= | 78%
#>
|
|======================================================= | 79%
#>
|
|======================================================== | 80%
#>
|
|========================================================= | 81%
#>
|
|========================================================= | 82%
#>
|
|========================================================== | 83%
#>
|
|=========================================================== | 84%
#>
|
|=========================================================== | 85%
#>
|
|============================================================ | 85%
#>
|
|============================================================ | 86%
#>
|
|============================================================= | 87%
#>
|
|============================================================= | 88%
#>
|
|============================================================== | 88%
#>
|
|============================================================== | 89%
#>
|
|=============================================================== | 90%
#>
|
|================================================================ | 91%
#>
|
|================================================================ | 92%
#>
|
|================================================================= | 93%
#>
|
|================================================================== | 94%
#>
|
|=================================================================== | 95%
#>
|
|=================================================================== | 96%
#>
|
|==================================================================== | 97%
#>
|
|==================================================================== | 98%
#>
|
|===================================================================== | 98%
#>
|
|===================================================================== | 99%
#>
|
|======================================================================| 99%
#>
|
|======================================================================| 100%
#> Executing: 'ffmpeg' -y -framerate 60 -i Rplot%d.png -pix_fmt yuv420p ctmm172635b6ee08.mp4
#>
#>
#> Video has been created at: /tmp/RtmpWKdDQj/ctmm172635b6ee08.mp4
# conditional simulations
SIMS <- lapply(1:6,function(i){simulate(coati[[2]],FIT,t=t)})
# random paths
video(SIMS,pch=16,ghost=ghost,file=FILE)
#>
|
| | 0%
#>
|
| | 1%
#>
|
|= | 1%
#>
|
|= | 2%
#>
|
|== | 2%
#>
|
|== | 3%
#>
|
|=== | 4%
#>
|
|=== | 5%
#>
|
|==== | 6%
#>
|
|===== | 7%
#>
|
|====== | 8%
#>
|
|====== | 9%
#>
|
|======= | 10%
#>
|
|======== | 11%
#>
|
|======== | 12%
#>
|
|========= | 12%
#>
|
|========= | 13%
#>
|
|========== | 14%
#>
|
|========== | 15%
#>
|
|=========== | 15%
#>
|
|=========== | 16%
#>
|
|============ | 17%
#>
|
|============= | 18%
#>
|
|============= | 19%
#>
|
|============== | 20%
#>
|
|=============== | 21%
#>
|
|=============== | 22%
#>
|
|================ | 22%
#>
|
|================ | 23%
#>
|
|================= | 24%
#>
|
|================= | 25%
#>
|
|================== | 25%
#>
|
|================== | 26%
#>
|
|=================== | 27%
#>
|
|=================== | 28%
#>
|
|==================== | 28%
#>
|
|==================== | 29%
#>
|
|===================== | 30%
#>
|
|====================== | 31%
#>
|
|====================== | 32%
#>
|
|======================= | 33%
#>
|
|======================== | 34%
#>
|
|======================== | 35%
#>
|
|========================= | 35%
#>
|
|========================= | 36%
#>
|
|========================== | 37%
#>
|
|========================== | 38%
#>
|
|=========================== | 38%
#>
|
|=========================== | 39%
#>
|
|============================ | 40%
#>
|
|============================= | 41%
#>
|
|============================= | 42%
#>
|
|============================== | 43%
#>
|
|=============================== | 44%
#>
|
|================================ | 45%
#>
|
|================================ | 46%
#>
|
|================================= | 47%
#>
|
|================================= | 48%
#>
|
|================================== | 48%
#>
|
|================================== | 49%
#>
|
|=================================== | 49%
#>
|
|=================================== | 50%
#>
|
|=================================== | 51%
#>
|
|==================================== | 51%
#>
|
|==================================== | 52%
#>
|
|===================================== | 52%
#>
|
|===================================== | 53%
#>
|
|====================================== | 54%
#>
|
|====================================== | 55%
#>
|
|======================================= | 56%
#>
|
|======================================== | 57%
#>
|
|========================================= | 58%
#>
|
|========================================= | 59%
#>
|
|========================================== | 60%
#>
|
|=========================================== | 61%
#>
|
|=========================================== | 62%
#>
|
|============================================ | 62%
#>
|
|============================================ | 63%
#>
|
|============================================= | 64%
#>
|
|============================================= | 65%
#>
|
|============================================== | 65%
#>
|
|============================================== | 66%
#>
|
|=============================================== | 67%
#>
|
|================================================ | 68%
#>
|
|================================================ | 69%
#>
|
|================================================= | 70%
#>
|
|================================================== | 71%
#>
|
|================================================== | 72%
#>
|
|=================================================== | 72%
#>
|
|=================================================== | 73%
#>
|
|==================================================== | 74%
#>
|
|==================================================== | 75%
#>
|
|===================================================== | 75%
#>
|
|===================================================== | 76%
#>
|
|====================================================== | 77%
#>
|
|====================================================== | 78%
#>
|
|======================================================= | 78%
#>
|
|======================================================= | 79%
#>
|
|======================================================== | 80%
#>
|
|========================================================= | 81%
#>
|
|========================================================= | 82%
#>
|
|========================================================== | 83%
#>
|
|=========================================================== | 84%
#>
|
|=========================================================== | 85%
#>
|
|============================================================ | 85%
#>
|
|============================================================ | 86%
#>
|
|============================================================= | 87%
#>
|
|============================================================= | 88%
#>
|
|============================================================== | 88%
#>
|
|============================================================== | 89%
#>
|
|=============================================================== | 90%
#>
|
|================================================================ | 91%
#>
|
|================================================================ | 92%
#>
|
|================================================================= | 93%
#>
|
|================================================================== | 94%
#>
|
|=================================================================== | 95%
#>
|
|=================================================================== | 96%
#>
|
|==================================================================== | 97%
#>
|
|==================================================================== | 98%
#>
|
|===================================================================== | 98%
#>
|
|===================================================================== | 99%
#>
|
|======================================================================| 99%
#>
|
|======================================================================| 100%
#> Executing: 'ffmpeg' -y -framerate 60 -i Rplot%d.png -pix_fmt yuv420p ctmm172635b6ee08.mp4
#>
#>
#> Video has been created at: /tmp/RtmpWKdDQj/ctmm172635b6ee08.mp4
# }