ropensci / av

Working with Video in R
https://docs.ropensci.org/av
Other
92 stars 10 forks source link

Replacing the demo video #13

Open kocabiyik opened 5 years ago

kocabiyik commented 5 years ago

The new demo video: https://www.youtube.com/watch?v=cZAngjZRYpA

nzgwynn commented 3 years ago

This might be of interest for an example. It animates and sonifies a loess curve for accessibility.

`

This is coding that sonifies and animates a loess

curve

library(lattice) library(ggplot2) library(sonify) library(gganimate) library(broom) library(tidyverse) library(av)

l2 <- loess(NOx ~ E, ethanol) fit <- augment(l2) s <- sonify(l2$x, l2$fitted, duration = 4, play = TRUE) writeWave(s, filename = "audio")

df <- tibble(fit$E, fit$NOx) names(df) <- c("x", "y")

p <- fit %>% arrange(.fitted) %>% ggplot(aes(E, NOx)) + geom_line(aes(y = .fitted), color = "red") + transition_reveal(E, keep_last = TRUE) + geom_point(data = df, aes(x, y))

anim_p <- animate(p, renderer = av_renderer(), duration = 10)

anim_save(filename = "annimation.mp4", animation = anim_p)

av::av_encode_video(input = "annimation.mp4", output = "both.mp4", audio = "audio")`