buildanimation: mov and mp4
This commit is contained in:
parent
07f7fd3c7a
commit
aa929ec24f
@ -80,6 +80,8 @@ export
|
|||||||
Animation,
|
Animation,
|
||||||
frame,
|
frame,
|
||||||
gif,
|
gif,
|
||||||
|
mov,
|
||||||
|
mp4,
|
||||||
animate,
|
animate,
|
||||||
@animate,
|
@animate,
|
||||||
@gif,
|
@gif,
|
||||||
|
|||||||
@ -17,6 +17,8 @@ function frame{P<:AbstractPlot}(anim::Animation, plt::P=current())
|
|||||||
end
|
end
|
||||||
|
|
||||||
giffn() = (isijulia() ? "tmp.gif" : tempname()*".gif")
|
giffn() = (isijulia() ? "tmp.gif" : tempname()*".gif")
|
||||||
|
movfn() = (isijulia() ? "tmp.mov" : tempname()*".mov")
|
||||||
|
mp4fn() = (isijulia() ? "tmp.mp4" : tempname()*".mp4")
|
||||||
|
|
||||||
type FrameIterator
|
type FrameIterator
|
||||||
itr
|
itr
|
||||||
@ -51,11 +53,14 @@ immutable AnimatedGif
|
|||||||
filename::String
|
filename::String
|
||||||
end
|
end
|
||||||
|
|
||||||
function gif(anim::Animation, fn = giffn(); fps::Integer = 20, loop::Integer = 0)
|
gif(anim::Animation, fn = giffn(); kw...) = buildanimation(anim.dir, fn; kw...)
|
||||||
|
mov(anim::Animation, fn = movfn(); kw...) = buildanimation(anim.dir, fn; kw...)
|
||||||
|
mp4(anim::Animation, fn = mp4fn(); kw...) = buildanimation(anim.dir, fn; kw...)
|
||||||
|
|
||||||
|
function buildanimation(animdir::AbstractString, fn::AbstractString;
|
||||||
|
fps::Integer = 20, loop::Integer = 0)
|
||||||
fn = abspath(fn)
|
fn = abspath(fn)
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|
||||||
# high quality
|
# high quality
|
||||||
speed = round(Int, 100 / fps)
|
speed = round(Int, 100 / fps)
|
||||||
file = joinpath(Pkg.dir("ImageMagick"), "deps","deps.jl")
|
file = joinpath(Pkg.dir("ImageMagick"), "deps","deps.jl")
|
||||||
@ -63,7 +68,7 @@ function gif(anim::Animation, fn = giffn(); fps::Integer = 20, loop::Integer = 0
|
|||||||
include(file)
|
include(file)
|
||||||
end
|
end
|
||||||
# prefix = get(ENV, "MAGICK_CONFIGURE_PATH", "")
|
# prefix = get(ENV, "MAGICK_CONFIGURE_PATH", "")
|
||||||
run(`convert -delay $speed -loop $loop $(joinpath(anim.dir, "*.png")) -alpha off $fn`)
|
run(`convert -delay $speed -loop $loop $(joinpath(animdir, "*.png")) -alpha off $fn`)
|
||||||
|
|
||||||
catch err
|
catch err
|
||||||
warn("""Tried to create gif using convert (ImageMagick), but got error: $err
|
warn("""Tried to create gif using convert (ImageMagick), but got error: $err
|
||||||
@ -71,7 +76,7 @@ function gif(anim::Animation, fn = giffn(); fps::Integer = 20, loop::Integer = 0
|
|||||||
Will try ffmpeg, but it's lower quality...)""")
|
Will try ffmpeg, but it's lower quality...)""")
|
||||||
|
|
||||||
# low quality
|
# low quality
|
||||||
run(`ffmpeg -v 0 -framerate $fps -loop $loop -i $(anim.dir)/%06d.png -y $fn`)
|
run(`ffmpeg -v 0 -framerate $fps -loop $loop -i $(animdir)/%06d.png -y $fn`)
|
||||||
# run(`ffmpeg -v warning -i "fps=$fps,scale=320:-1:flags=lanczos"`)
|
# run(`ffmpeg -v warning -i "fps=$fps,scale=320:-1:flags=lanczos"`)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user