Using the @gif macro works when explicitly stating the filepath:
_ _ _(_)_ | Documentation: https://docs.julialang.org
(_) | (_) (_) |
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 1.1.0 (2019-01-21)
_/ |\__'_|_|_|\__'_| | Official https://julialang.org/ release
|__/ |
(v1.1) pkg> status
Status `~/.julia/environments/v1.1/Project.toml`
[28b8d3ca] GR v0.41.0
[91a5bcdd] Plots v0.26.0
[d330b81b] PyPlot v2.8.1
julia> using Plots
julia> anim = @animate for i=1:100
plot(rand(10))
end
Animation("/var/folders/3y/wfvpdpbx12j_80dq9y6z202h0000gp/T/tmpn5CVJs", ["000001.png", "000002.png", "000003.png", "000004.png", "000005.png", "000006.png", "000007.png", "000008.png", "000009.png", "000010.png" … "000091.png", "000092.png", "000093.png", "000094.png", "000095.png", "000096.png", "000097.png", "000098.png", "000099.png", "000100.png"])
julia> gif(anim, "/tmp/anim_fps15.gif", fps = 15)
┌ Info: Saved animation to
â”” fn = "/tmp/anim_fps15.gif"
Plots.AnimatedGif("/tmp/anim_fps15.gif")
julia> gif(anim, "anim_fps15.gif", fps = 15)
┌ Info: Saved animation to
â”” fn = "/Users/mcawte/anim_fps15.gif"
Plots.AnimatedGif("/Users/mcawte/anim_fps15.gif")
gif(anim, "/Users/mcawte/anim_fps15.gif", fps = 15)
┌ Info: Saved animation to
â”” fn = "/Users/mcawte/anim_fps15.gif"
Plots.AnimatedGif("/Users/mcawte/anim_fps15.gif")
However, when using ~ as a substitute for the home directory, failure occurs:
julia> gif(anim, "~/anim_fps15.gif", fps = 15)
ERROR: failed process: Process(`/Users/mcawte/.julia/packages/FFMPEG/9JQpZ/deps/usr/bin/ffmpeg -v 0 -framerate 15 -loop 0 -i /var/folders/3y/wfvpdpbx12j_80dq9y6z202h0000gp/T/tmpn5CVJs/%06d.png -i /var/folders/3y/wfvpdpbx12j_80dq9y6z202h0000gp/T/tmpn5CVJs/palette.bmp -lavfi paletteuse=dither=sierra2_4a -y '/Users/mcawte/~/anim_fps15.gif'`, ProcessExited(1)) [1]
Stacktrace:
[1] error(::String, ::Base.Process, ::String, ::Int64, ::String) at ./error.jl:42
[2] pipeline_error at ./process.jl:785 [inlined]
[3] #run#515(::Bool, ::Function, ::Cmd) at ./process.jl:726
[4] run at ./process.jl:724 [inlined]
[5] #4 at /Users/mcawte/.julia/packages/FFMPEG/9JQpZ/src/FFMPEG.jl:128 [inlined]
[6] withenv(::getfield(FFMPEG, Symbol("##4#6")){String,Cmd}, ::Pair{String,String}) at ./env.jl:148
[7] #exe#2 at /Users/mcawte/.julia/packages/FFMPEG/9JQpZ/src/FFMPEG.jl:127 [inlined]
[8] #exe at ./none:0 [inlined]
[9] ffmpeg_exe at /Users/mcawte/.julia/packages/FFMPEG/9JQpZ/src/FFMPEG.jl:139 [inlined]
[10] #buildanimation#249(::Int64, ::Int64, ::Bool, ::Bool, ::Function, ::String, ::String, ::Bool) at /Users/mcawte/.julia/packages/Plots/jWNMG/src/animation.jl:84
[11] #buildanimation at ./none:0 [inlined] (repeats 2 times)
[12] #gif#246 at /Users/mcawte/.julia/packages/Plots/jWNMG/src/animation.jl:63 [inlined]
[13] (::getfield(Plots, Symbol("#kw##gif")))(::NamedTuple{(:fps,),Tuple{Int64}}, ::typeof(gif), ::Animation, ::String) at ./none:0
[14] top-level scope at none:0
Hi Mike, good to see that you are still using Julia.
I can replicate this on my Ubunutu machine, this behavior is unfortunate.
A simple workaround would be: gif(anim, "$(homedir())/anim_fps15.gif", fps = 15)
I don't know much about how directory strings are parsed, but I will look into it if nobody more knowledgeable knows a solution off the top of their head.
Also, make sure to quote macros with backticks, it seems that you have pinged someone called gif.
You could pipe the path to expanduser, or we could look at using something like abspath(expanduser(inputdir)).
I like both of those ideas.
I vote that we use the abspath(expanduser(inputdir)) parsing idea, so that less work is placed on the user. After all, one of the core ideas of Plots is that it does what you want it to do, not just what you tell it.
expanduser only works on unix systems, though:
help?> expanduser
search: expanduser
expanduser(path::AbstractString) -> AbstractString
On Unix systems, replace a tilde character at the start of a path with the current user's home directory.
What is the equivalent of ~ on non unix systems? Ideally we would be able to handle that too.
In any case, the abspath(expanduser(inputdir)) would have a positive effect with no negative effects.
I agree. Is there any situation, where a change to abspath(expanduser(inputdir)) could lead to unexpected behavior for users?
I really can't think of any case where the change would lead to unexpected behavior, famous last words.
I am happy to make the change if no one else plans to do it.
That would be great!