GLMakie Method error (Makie.image!)

That was most helpful. I now have something that does not eat memory! The only thing currently missing is a foolproof way to get the framerate from the file. In the past it would have been f.framerate according to the demo code on the github VideoIO page but that seems not to work anymore. I have a workaround that works in some cases.
My current code is:

using GLMakie
using VideoIO
using Printf

#filename = "MOV_20210607_1540323.mp4"
#f = VideoIO.openvideo(filename)
io = VideoIO.testvideo("annie_oakley") # for testing purposes
f = VideoIO.openvideo(io)

framerate = 0.0
try
    framerate = VideoIO.get_number_frames(filename) / VideoIO.get_duration(filename)
    println("Using calculated framerate of $framerate")
catch
    framerate = 30.0
    println("Using default framerate of $framerate")
end
@show(framerate)
img = read(f)
fig = Figure()
ax = Axis(fig[1,1], aspect = DataAspect())
hidedecorations!(ax)
node = Node(rotr90(img))

makieimg = image!(node)

i = 0
while !eof(f)
    i += 1
    print("Frame $i\r")
    read!(f, img)
    node[] = rotr90(img)
    save(@sprintf("test_%04d.png", i) , fig.scene)
    sleep(1/framerate)
end


Thank you very much for your help!

Edit: minor correction and added a line to save every frame to a png file.

1 Like