Javis.jl
Javis.jl copied to clipboard
[BUG] Gif not matching spec'd framerate
Describe the bug
For certain combinations for number of frames and framerate, a resulting gif will not have the correct framerate. It is correct sometimes. I cannot seem to find a pattern of why.
To Reproduce
- Julia Version (i.e. output of
julia -v
): v1.5.3 - Operating system (Mac, Linux, Windows): MacOS 10.15
- Javis version (i.e output of
] status Javis
in the REPL) 0.3.3 - Minimum working code example that led to bug:
using Javis
function ground(args...)
background("black")
sethue("white")
end
function printframe(v,o,f)
fontsize(100)
Javis.text("$f",0,0, valign=:center, halign=:center)
end
function makegif(nframes, framerate)
video = Video(400,400)
Background(1:nframes, ground)
frame = Object(1:nframes, printframe)
Javis.render(video; pathname = "$(nframes)frames_$(framerate)framerate.gif", framerate = framerate)
end
makegif(10, 1) #correct
makegif(1000, 1) #correct
makegif(1000, 100) #wrong, should only take 10s, seems like 100s
Expected Behavior and Actual Behavior
Last gif created should be 10 s long. 1000 frames / 100 fps. It is 100s long.
Hey @agerlach - thanks for opening this issue. At first look, this has to do with FFMPEG.jl which is what we use to create renders. I did some googling and it seems like one has to do some interesting trickery with FFMPEG to get the functionality you want: https://unix.stackexchange.com/questions/562869/ffmpeg-video-at-100-fps-with-300-images-gives-13-seconds
I will take a deeper look at this soon. Thanks for providing the code and the example - I was able to replicate exactly the same issue you ran into.
to get the functionality you want
I'm a bit confused by this. Is this not the functionality you would expect?
@agerlach - oh no, this is definitely a bug as I was expecting the same process you thought to work as well: e.g. 1000 frames at a framerate of 100 should result in a 10s gif. Instead, it is not. I have never run into this as typically, most gifs I create are at a framerate of 30 and below. Curiously, if I use an mp4 instead of a gif, the expected behavior does work:
using Javis
function ground(args...)
background("black")
sethue("white")
end
function printframe(v,o,f)
fontsize(100)
Javis.text("$f",0,0, valign=:center, halign=:center)
end
function makemp4(nframes, framerate)
video = Video(400,400)
Background(1:nframes, ground)
frame = Object(1:nframes, printframe)
Javis.render(video; pathname = "$(nframes)frames_$(framerate)framerate.mp4", framerate = framerate)
end
makemp4(1000, 100) # Takes 10s as expected
I'll keep exploring why gifs do not render to the expected time.
Bump @TheCedarPrince any news on this?
Haven't had time to investigate @Wikunia - it is still standing bug for Javis. Nothing wrong with FFMPEG.jl but rather I have to dig deeper into FFMPEG as there is a way around this based on my earlier message's link. Just not sure how to best address it yet.
I am getting the same bug. seems to work up to 50 fps.