rotation2dAnimation: Cretaes video by FFmpeg with animation of dataset rotated

View source: R/rotation2dAnimation.r

rotation2dAnimationR Documentation

Cretaes video by FFmpeg with animation of dataset rotated

Description

This function opens a graphics device to record the images produced in the code expr, then uses FFmpeg to convert these images to a video.

Usage

rotation2dAnimation(conf2d,
ani.interval=0.2,
ani.nmax=361,
ani.width=500,
ani.height=500,
ani.video.name="mds_rotate.mp4",
angle.start=-pi,
angle.stop=pi,
angle.step=pi/180)

Arguments

conf2d

two dimensional dataset ot matrix

ani.video.name

the file name of the output video (e.g. ‘animation.mp4’ or ‘animation.avi’)

ani.interval

interval betwwen animation frames

ani.nmax

maximal number of frames

ani.width

width of movie

ani.height

height of movie

angle.start

starting angle for animation

angle.stop

end angle for animation

angle.step

step of animation in radians

Details

This function uses system to call FFmpeg to convert the images to a single video. The command line used in this function is: ffmpeg -y -r <1/interval> -i <img.name>%d.<ani.type> other.opts video.name

where interval comes from ani.options('interval'), and ani.type is from ani.options('ani.type'). For more details on the numerous options of FFmpeg, please see the reference.

Some linux systems may use the alternate software 'avconv' instead of 'ffmpeg'. The package will attempt to determine which command is present and set ani.options('ffmpeg') to an appropriate default value. This can be overridden by passing in the ffmpeg argument.

Value

An integer indicating failure (-1) or success (0) of the converting (refer to system).

Author(s)

Marek Walesiak marek.walesiak@ue.wroc.pl

Department of Econometrics and Computer Science, Wroclaw University of Economics and Business, Poland

Andrzej Dudek andrzej.dudek@ue.wroc.pl

Department of Financial Investments and Risk Management, Wroclaw University of Economics and Business, Poland

References

Walesiak, M. (2016), Visualization of Linear Ordering Results for Metric Data with the Application of Multidimensional Scaling, Ekonometria, 2(52), 9-21. Available at: \Sexpr[results=rd]{tools:::Rd_expr_doi("10.15611/ekt.2016.2.01")}.

Walesiak, M. (2017), The application of multidimensional scaling to measure and assess changes in the level of social cohesion of the Lower Silesia region in the period 2005-2015, Ekonometria, 3(57), 9-25. Available at: \Sexpr[results=rd]{tools:::Rd_expr_doi("10.15611/ekt.2017.3.01")}.

Walesiak, M., Dudek, A. (2017), Selecting the Optimal Multidimensional Scaling Procedure for Metric Data with R Environment, STATISTICS IN TRANSITION new series, September, Vol. 18, No. 3, pp. 521-540. Available at: \Sexpr[results=rd]{tools:::Rd_expr_doi("10.59170/stattrans-2017-027")}.

Walesiak, M., Dehnel, G., Dudek, A. (2025), Visualisation of linear ordering results using multidimensional scaling – problems and an overview of studies, Argumenta Oeconomica, No 1 (54), 187-203. Available at: \Sexpr[results=rd]{tools:::Rd_expr_doi("10.15611/aoe.2025.1.12")}.

Walesiak, M., Dehnel, G. (2026), Assessment of the implementation of SDG 4 goal by EU countries in the light of the 2030 Agenda using a hybrid approach in linear ordering, PLoS ONE 21(6): e0333545. Available at: \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1371/journal.pone.0333545")}.

https://yihui.org/animation/example/savevideo/

https://ffmpeg.org/documentation.html

See Also

Other utilities: im.convert, saveGIF, saveHTML, saveLatex, saveSWF

Examples

  
    library(mdsOpt)
    library(smacof)
    library(animation)
    library(spdep)
    library(clusterSim)
    data(data_lower_silesian)
    z<-data.Normalization(data_lower_silesian, type="n1")
    d<-dist.GDM(z, method="GDM1")
    res<-smacofSym(delta=d,ndim=2,type="interval")
    konf<-as.matrix(res$conf)
    #Uncomment only if ffmpeg is properly installed for animation package 
    #see:  https://yihui.org/animation/example/savevideo/ 
    #oopts = if (.Platform$OS.type == "windows") {
    # ani.options(ffmpeg = "D:/Installer/ffmpeg/bin/ffmpeg.exe")
    #}
    #rotation2dAnimation(conf2d=konf,angle.start=-0,angle.stop=2*pi)
  

mdsOpt documentation built on Oct. 2, 2026, 5:09 p.m.