1

ガニメート使用。ffmpeg の機能に正しくアクセスする方法がわかりません。具体的には、出力しているビデオ ファイルで使用しているコーデックを変更したいと考えています。

# load packages
library(ggplot)
library(animation)
library(gganimate)

# Here's my data.frame
myDf <- data.frame(
    year = c(1962, 1963, 1964, 1965, 1966, 1967, 1968, 1969, 1970, 1971, 1972, 1973, 1974, 1975, 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014), 
    bottom50 = c(0.195, 0.191, 0.187, 0.192, 0.196, 0.205, 0.207, 0.210, 0.209, 0.204, 0.203, 0.204, 0.205, 0.203, 0.202, 0.200, 0.200, 0.201, 0.199, 0.195, 0.190, 0.183, 0.179, 0.179, 0.177, 0.172, 0.169, 0.169, 0.168, 0.166, 0.158, 0.159, 0.158, 0.154, 0.151, 0.148, 0.149, 0.148, 0.146, 0.149, 0.148, 0.145, 0.142, 0.138, 0.135, 0.137, 0.137, 0.136, 0.130, 0.127, 0.123, 0.127, 0.125), top1 = c(0.126, 0.127, 0.129, 0.128, 0.126, 0.123, 0.122, 0.115, 0.110, 0.111, 0.111, 0.109, 0.106, 0.105, 0.105, 0.107, 0.108, 0.111, 0.107, 0.110, 0.112, 0.115, 0.125, 0.125, 0.122, 0.133, 0.149, 0.145, 0.145, 0.139, 0.150, 0.146, 0.147, 0.153, 0.160, 0.166, 0.169, 0.177, 0.183, 0.173, 0.171, 0.172, 0.183, 0.194, 0.201, 0.199, 0.195, 0.185, 0.198, 0.196, 0.208, 0.196, 0.202)
)

#Basic plot
p <- ggplot(myDf, aes(x = year, y = bottom50, frame = year)) + 
    geom_line(color = "dodgerblue") + 
    geom_line(aes(y = top1), color = "darkred")

アニメ化されていないバージョンでは、私が望むものが得られます。

ここに画像の説明を入力

そして、次の方法でアニメーション バージョンをビデオに出力します。

gganimate(p, interval = .1, title_frame = FALSE, "income.mp4")

それは問題ありませんが、出力パラメータをいくつか変更したいと思います。具体的には、寸法、フレーム レートを変更し、別のコーデックを使用します。

# change some of the options
ani.options(ani.height = 1080, ani.width = 1920, 
            interval = 0.04166667, other.opts = "-vcodec qtrle -f mov")
# re-animate
gganimate(p, title_frame = FALSE, "income.mov")

それは私に次のエラーを与えます:

Error in animation_saver(saver, filename) : 
  Don't know how to save animation of type mov

アニメーション コーデックに変更しようとしているので、ファイル拡張子として '.mov' を使用しています (.mp4 ラッパーではなくなりました)。ffmpeg をインストールしたので、これはおそらく構文の問題です。しかし、ドキュメントはここではあまり明確ではありません。gganimate には、コーデックの変更 (または mp4 以外のビデオの出力) に関するドキュメントはありません。また、アニメーション パッケージにも詳細が記載されています。

4

0 に答える 0