JuliaIO / VideoIO.jl

Reading and writing of video files in Julia via ffmpeg
https://juliaio.github.io/VideoIO.jl/stable
Other
125 stars 53 forks source link

read camera without delay causes `Could not scale frame` on MacOS #343

Open Sixzero opened 2 years ago

Sixzero commented 2 years ago

The code:

import VideoIO

cam = VideoIO.opencamera()
while true
    img = read(cam)
end

Throws the error:

ERROR: LoadError: Could not scale frame
Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:33
 [2] exec!(s::VideoIO.SwsTransform)
   @ VideoIO ~/.julia/packages/VideoIO/EsW3Z/src/frame_graph.jl:115
 [3] execute_graph!
   @ ~/.julia/packages/VideoIO/EsW3Z/src/avio.jl:456 [inlined]
 [4] _retrieve!(r::VideoIO.VideoReader{true, VideoIO.SwsTransform, String}, buf::PermutedDimsArray{ColorTypes.RGB{FixedPointNumbers.N0f8}, 2, (2, 1), (2, 1), Matrix{ColorTypes.RGB{FixedPointNumbers.N0f8}}})
   @ VideoIO ~/.julia/packages/VideoIO/EsW3Z/src/avio.jl:467
 [5] retrieve(r::VideoIO.VideoReader{true, VideoIO.SwsTransform, String})
   @ VideoIO ~/.julia/packages/VideoIO/EsW3Z/src/avio.jl:506
 [6] read(::VideoIO.VideoReader{true, VideoIO.SwsTransform, String})
   @ VideoIO ~/.julia/packages/VideoIO/EsW3Z/src/avio.jl:610
 [7] top-level scope
   @ ~/repo/julia-awesomeness/camera.test.jl:84
in expression starting at /Users/macpro/repo/julia-awesomeness/Boilerplate.jl/rtsp.test.jl:83

The issue is interesting in that sense read does run 10-20 times before in always just returns this error.

I tried to dig into the issue, but I didn't really know how I could debug the sws_scale function. Thank you in advance.

Sixzero commented 2 years ago

As for now, I guess the issue was because I used read too often. Probably its limited by the camera FPS?

We could get what causes the limit, and maybe state it in the error code.

Sixzero commented 2 years ago

If its not worth the pain, then I am closing the issue. :)

IanButterworth commented 2 years ago

I can reproduce this.

It does seem like a bug. IMO reading in a loop like this is a reasonable thing to do

ashwani-rathee commented 11 months ago

Any ideas on what might be causing this, and is this platform specific(is it a issue on linux too or not)? I face it on windows despite sleep times of 2 sec