VideoIO.jl icon indicating copy to clipboard operation
VideoIO.jl copied to clipboard

Cant open /dev/video0. Error -22

Open aamini opened this issue 8 years ago • 6 comments

Using Ubuntu 15.04, trying to open builtin webcam with Julia v0.4. avformat_open_input fails with Error -22.

Steps to reproduce:

import VideoIO
f = VideoIO.opencamera()

Error obtained:

ERROR: LoadError: Could not open file /dev/video0 in open_avinput at /home/amini/.julia/v0.4/VideoIO/src/avio.jl:219 in AVInput at /home/amini/.julia/v0.4/VideoIO/src/avio.jl:243 in opencamera at /home/amini/.julia/v0.4/VideoIO/src/avio.jl:667 (repeats 2 times)

Steps to debug:

When doing an FFmpeg search of available devices, I can see /dev/video0: v4l2-ctl --list-devices

Integrated Camera (usb-0000:00:1a.0-1.6): /dev/video0

Finally, I am even able to capture video from FFmpeg with /dev/video0 (and save into a test file) ffmpeg -f v4l2 -framerate 25 -video_size 640x480 -i /dev/video0 output.mkv

I was able to trace the error in VideoIO back to the avformat_open_input function in the avio.jl file. It is returning an Error code of -22, (and is failing since only codes=0 pass.

aamini avatar Sep 25 '16 21:09 aamini

Also, the result of VideoIO.versioninfo() is:

Using ffmpeg
AVCodecs version 56.13.100
AVFormat version 56.15.102
AVUtil version 54.15.100
SWScale version 3.1.101
AVDevice version 55.0.0
AVFilters version 5.2.103

aamini avatar Oct 12 '16 16:10 aamini

Bump!

aamini avatar Nov 15 '16 15:11 aamini

This should be fixed now

IanButterworth avatar Apr 05 '21 03:04 IanButterworth

I just encountered a very similar error:

julia> VideoIO.viewcam()
ERROR: Could not open /dev/video0

I also have a video1 device, is there a way to point this function to a specific device? (can't find anything in the documentation)

VideoIO v0.9.1 Julia v1.6

drrmmng avatar Apr 09 '21 16:04 drrmmng

@fedario you can pass the device as an argument: camdevice = "/dev/video1"; VideoIO.viewcam(camdevice). This is also mentioned in the docstring of VideoIO.viewcam.

As for the actual issue; I run into this error when I didn't close the webcam stream correctly before (by close(cam)). In that case I can fix it by restarting the Julia REPL.

ltjkoomen avatar Apr 27 '21 15:04 ltjkoomen

This is still a problem. In 64-bit Raspbian Lite Bullseye, I get the same -22 error, with current Julia v1.8.5.

By turning on ffmpeg logging, I see more info:

VideoIO.loglevel!(VideoIO.libffmpeg.AV_LOG_VERBOSE)
[video4linux2,v4l2 @ 0x4ab2920] fd:22 capabilities:a5a00001
[video4linux2,v4l2 @ 0x4ab2920] Querying the device for the current frame size
[video4linux2,v4l2 @ 0x4ab2920] Setting frame size to 640x480
[video4linux2,v4l2 @ 0x4ab2920] ioctl(VIDIOC_G_PARM): Inappropriate ioctl for device
[video4linux2,v4l2 @ 0x4ab2920] Time per frame unknown
[video4linux2,v4l2 @ 0x4ab2920] ioctl(VIDIOC_STREAMON): Invalid argument
ERROR: LoadError: Could not open /dev/video0. avformat_open_input error code -22

I will continue poking at this....

bobcassels avatar Jan 18 '23 18:01 bobcassels