From c6784a779b2df99dd859718e6012d898aa7e9b32 Mon Sep 17 00:00:00 2001 From: Dieter Castel Date: Sun, 3 May 2020 15:31:55 +0200 Subject: [PATCH] Added webm support for animations. --- src/Plots.jl | 1 + src/animation.jl | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Plots.jl b/src/Plots.jl index 7ec451f1..7c8b0d1e 100644 --- a/src/Plots.jl +++ b/src/Plots.jl @@ -108,6 +108,7 @@ export gif, mov, mp4, + webm, animate, @animate, @gif, diff --git a/src/animation.jl b/src/animation.jl index f83880a0..610bc558 100644 --- a/src/animation.jl +++ b/src/animation.jl @@ -24,6 +24,7 @@ end giffn() = (isijulia() ? "tmp.gif" : tempname()*".gif") movfn() = (isijulia() ? "tmp.mov" : tempname()*".mov") mp4fn() = (isijulia() ? "tmp.mp4" : tempname()*".mp4") +webmfn() = (isijulia() ? "tmp.webm" : tempname()*".webm") mutable struct FrameIterator itr @@ -63,6 +64,7 @@ file_extension(fn) = Base.Filesystem.splitext(fn)[2][2:end] gif(anim::Animation, fn = giffn(); kw...) = buildanimation(anim, fn; kw...) mov(anim::Animation, fn = movfn(); kw...) = buildanimation(anim, fn, false; kw...) mp4(anim::Animation, fn = mp4fn(); kw...) = buildanimation(anim, fn, false; kw...) +webm(anim::Animation, fn = webmfn(); kw...) = buildanimation(anim, fn, false; kw...) ffmpeg_framerate(fps) = "$fps" ffmpeg_framerate(fps::Rational) = "$(fps.num)/$(fps.den)" @@ -110,8 +112,8 @@ function Base.show(io::IO, ::MIME"text/html", agif::AnimatedGif) ext = file_extension(agif.filename) if ext == "gif" html = "" - elseif ext in ("mov", "mp4") - mimetype = ext == "mov" ? "video/quicktime" : "video/mp4" + elseif ext in ("mov", "mp4","webm") + mimetype = ext == "mov" ? "video/quicktime" : "video/$ext" html = ""