JuliaIO / VideoIO.jl

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

Webcam streaming broken in v0.9 #320

Open IanButterworth opened 3 years ago

IanButterworth commented 3 years ago

It seems that v0.9 assumes that if there are no frames remaining, the AVInput stream is finished, which isn't the case for streams that are updating like camera streams.

using VideoIO
cam = VideoIO.opencamera()
while true
    sleep(1/100)
    if eof(cam)
        println("eof")
        continue
    end
    img = read(cam)
    println("new frame")
end

In v0.8

new frame
eof
new frame
new frame
eof
eof
new frame

In v0.9

new frame
new frame
new frame
new frame
new frame
eof
eof
eof
eof
eof
eof
eof
eof
eof
(ad infinitum)

Commenting out this line fixes it https://github.com/JuliaIO/VideoIO.jl/blob/33200c28ad823759f7548ca34c5beaf3524b9761/src/avio.jl#L112

Also I noticed that the framerate returned by framerate(f::VideoReader) for a webcam has changed in v0.9.

v0.8

julia> cam = VideoIO.opencamera()
VideoReader(...)

julia> cam.framerate
1000000//1

v0.9

julia> cam = VideoIO.opencamera()
VideoReader(...)

julia> VideoIO.framerate(cam)
1//0

Perhaps Inf is actually more accurate, but thought I'd check

cc. @galenlynch

IanButterworth commented 3 years ago

There may be different behavior between MacOS and Linux here. On Linux I don't ever seem to hit EOFs on a camera stream