带有 gganimate 的 knitr,找不到 ffmpeg 命令
knitr with gganimate, cannot find ffmpeg command
我正尝试按照 knitr documentation:
的说明使用 gganimate
制作动画情节
knitr::opts_chunk$set(message = FALSE, warning = FALSE, fig.show = "animate")
# Example from https://github.com/dgrtwo/gganimate
library(ggplot2)
library(gganimate)
# For example, suppose we wanted to create an animation similar to the Gapminder
# world animation, using Jenny Bryan's gapminder package for the data.
library(gapminder)
theme_set(theme_bw())
p <- ggplot(gapminder, aes(gdpPercap, lifeExp, size = pop, color = continent, frame = year)) +
geom_point() +
scale_x_log10()
# Notice we added frame = year and saved the plot as p.
# We then display it as an animation with the gg_animate function:
gg_animate(p)
但是,我收到错误消息:
Error: Could not find ffmpeg command. You should either change the animation.fun hook option or install ffmpeg with libvpx enabled.
我已经按照说明here安装了ffmpeg,在命令行中运行ffmpeg -version
给出:
C:\ffmpeg\bin>ffmpeg -version
ffmpeg version 3.2.2 Copyright (c) 2000-201
built with gcc 5.4.0 (GCC)
configuration: --enable-gpl --enable-versio
nable-nvenc --enable-avisynth --enable-bzli
--enable-gnutls --enable-iconv --enable-li
s2b --enable-libcaca --enable-libfreetype -
le-libilbc --enable-libmodplug --enable-lib
enable-libopencore-amrwb --enable-libopenh2
pus --enable-librtmp --enable-libsnappy --e
ble-libtheora --enable-libtwolame --enable-
enable-libvorbis --enable-libvpx --enable-l
ibx264 --enable-libx265 --enable-libxavs --
ble-lzma --enable-decklink --enable-zlib
libavutil 55. 34.100 / 55. 34.100
libavcodec 57. 64.101 / 57. 64.101
libavformat 57. 56.100 / 57. 56.100
libavdevice 57. 1.100 / 57. 1.100
libavfilter 6. 65.100 / 6. 65.100
libswscale 4. 2.100 / 4. 2.100
libswresample 2. 3.100 / 2. 3.100
libpostproc 54. 1.100 / 54. 1.100
我现在该怎么办?特别是,对'change the animation.fun hook option'是什么意思?
编辑:我刚刚注意到 system('ffmpeg -version')
returns 一个 127 状态代码,但在我的命令行中工作正常。
重新启动 Rstudio
并且可能底层 Rsession
解决了问题。
我正尝试按照 knitr documentation:
的说明使用gganimate
制作动画情节
knitr::opts_chunk$set(message = FALSE, warning = FALSE, fig.show = "animate")
# Example from https://github.com/dgrtwo/gganimate
library(ggplot2)
library(gganimate)
# For example, suppose we wanted to create an animation similar to the Gapminder
# world animation, using Jenny Bryan's gapminder package for the data.
library(gapminder)
theme_set(theme_bw())
p <- ggplot(gapminder, aes(gdpPercap, lifeExp, size = pop, color = continent, frame = year)) +
geom_point() +
scale_x_log10()
# Notice we added frame = year and saved the plot as p.
# We then display it as an animation with the gg_animate function:
gg_animate(p)
但是,我收到错误消息:
Error: Could not find ffmpeg command. You should either change the animation.fun hook option or install ffmpeg with libvpx enabled.
我已经按照说明here安装了ffmpeg,在命令行中运行ffmpeg -version
给出:
C:\ffmpeg\bin>ffmpeg -version
ffmpeg version 3.2.2 Copyright (c) 2000-201
built with gcc 5.4.0 (GCC)
configuration: --enable-gpl --enable-versio
nable-nvenc --enable-avisynth --enable-bzli
--enable-gnutls --enable-iconv --enable-li
s2b --enable-libcaca --enable-libfreetype -
le-libilbc --enable-libmodplug --enable-lib
enable-libopencore-amrwb --enable-libopenh2
pus --enable-librtmp --enable-libsnappy --e
ble-libtheora --enable-libtwolame --enable-
enable-libvorbis --enable-libvpx --enable-l
ibx264 --enable-libx265 --enable-libxavs --
ble-lzma --enable-decklink --enable-zlib
libavutil 55. 34.100 / 55. 34.100
libavcodec 57. 64.101 / 57. 64.101
libavformat 57. 56.100 / 57. 56.100
libavdevice 57. 1.100 / 57. 1.100
libavfilter 6. 65.100 / 6. 65.100
libswscale 4. 2.100 / 4. 2.100
libswresample 2. 3.100 / 2. 3.100
libpostproc 54. 1.100 / 54. 1.100
我现在该怎么办?特别是,对'change the animation.fun hook option'是什么意思?
编辑:我刚刚注意到 system('ffmpeg -version')
returns 一个 127 状态代码,但在我的命令行中工作正常。
重新启动 Rstudio
并且可能底层 Rsession
解决了问题。