从 R 中的一系列情节创建电影 [英] Creating a Movie from a Series of Plots in R

查看:19
本文介绍了从 R 中的一系列情节创建电影的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种简单的方法可以通过在 R 中将多个情节拼接在一起来创建电影"?

Is there an easy way to create a "movie" by stitching together several plots, within R?

推荐答案

这是我使用 R 帮助找到的一种方法:

Here is one method I found using R help:

要创建单个图像帧:

jpeg("/tmp/foo%02d.jpg")
for (i in 1:5) {
  my.plot(i)
}
dev.off()

要制作电影,请先安装 ImageMagick.然后调用以下函数(它调用convert",我想是 ImageMagick 的一部分):

To make the movie, first install ImageMagick. Then call the following function (which calls "convert", part of ImageMagick I suppose):

make.mov <- function(){
     unlink("plot.mpg")
     system("convert -delay 0.5 plot*.jpg plot.mpg")
}

或者尝试使用此文章 (我发现这可以提供更清晰的结果):ffmpeg -r 25 -qscale 2 -i tmp/foo%02d.jpg output.mp4

Or try using the ffmpeg function as described in this article (I've found this gives cleaner results): ffmpeg -r 25 -qscale 2 -i tmp/foo%02d.jpg output.mp4

可能需要一些修补,但是一旦安装了所有东西,这看起来就很简单了.

May require a bit of tinkering, but this seemed pretty simple once everything was installed.

当然,在任何看到jpg"或jpeg"的地方,您都可以替换为 GIF 或 PNG 以满足您的喜好.

Of course, anywhere you see "jpg" or "jpeg", you can substitute GIF or PNG to suit your fancy.

这篇关于从 R 中的一系列情节创建电影的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆