Page 1 of 1

[SOLVED] [Ubuntu, vlcj] Multiple camera streams fails (v4l2)

Posted: 29 Nov 2011 12:37
by vale4674
I am using vlcj library for my project and finished developing on Windows. Now I am upgrading it for Linux usage. And now I see that libvlc is acting better on Windows that on Linux.

Eg. On windows I can run multiple cameras at once and stream into files (dshow://). Now on Linux I use v4l2:// and only one camera can be streamed at once.
Can I fix this somehow? Is it libvlc issue or Linux issue?
Here is the output that I think comes from VLC:

[0x9a13d8c] v4l2 demux error: VIDIOC_STREAMON failed
[0x9a13d8c] v4l2 demux error: cannot set input (Device or resource busy)
[0x9a9a86c] v4l2 access error: VIDIOC_STREAMON failed
[0x9a9a86c] v4l2 access error: cannot set input (Device or resource busy)
[0x9a584bc] main input error: open of `v4l2:///dev/video1' failed: (null)
[0x9a584bc] main input error: Your input can't be opened
[0x9a584bc] main input error: VLC is unable to open the MRL 'v4l2:///dev/video1'. Check the log for

Re: [Ubuntu, vlcj] Multiple camera streams fails (v4l2)

Posted: 29 Nov 2011 14:36
by Rémi Denis-Courmont
"Device or resource busy" is an error from the Linux kernel that the device is already being streamed by another program.
Most probably you're trying to stream the same camera multiple times. This is never going to work.

Re: [Ubuntu, vlcj] Multiple camera streams fails (v4l2)

Posted: 29 Nov 2011 15:12
by vale4674
"Device or resource busy" is an error from the Linux kernel that the device is already being streamed by another program.
Most probably you're trying to stream the same camera multiple times. This is never going to work.
Hey.
This sure is not the problem because I tried all of this with VLC player application.

I open one VLC instance and Open Capture Device and give to it /dev/video0 and the green light on that camera turns on (indicating that it is opened) and I see stream from that camera in VLC window.

Then I open another VLC instance and give to it /dev/video1 and then on that second camera green light turns on (and stays on until I close that VLC instance) but I don't see anything in VLC window and this messages prints in messages window:

Code: Select all

v4l2 error: cannot set input (Device or resource busy) v4l2 error: cannot set input (Device or resource busy) v4l2 error: cannot set input (Device or resource busy) v4l2 error: cannot set input (Device or resource busy) main error: open of `v4l2:///dev/video1' failed: (null)
If I first start /dev/video1 in one VLC instance and then /dev/video0 in second VLC instance the same thing happens (only the first started camera is streaming).

What could be the cause of this problem? This looks like it is v4l2 problem but I don't think it should be.

Re: [Ubuntu, vlcj] Multiple camera streams fails (v4l2)

Posted: 29 Nov 2011 15:52
by Rémi Denis-Courmont
If you don't like my explanation, you're free to invent your own. The fact remains that the kernel returns EBUSY and VLC cannot do anything about that.

Re: [Ubuntu, vlcj] Multiple camera streams fails (v4l2)

Posted: 29 Nov 2011 16:11
by vale4674
If you don't like my explanation, you're free to invent your own. The fact remains that the kernel returns EBUSY and VLC cannot do anything about that.
It's not that I don't like yours explanation but for a while I've been on this forum and although I got here very useful informations, every time I felt negative vibe from admin/developers on their answers. I understand that when someone asks some question which requires 2min of googleing, but when the problem is deeper (like mine) and specific then it shouldn't be so.

I explained my scenario step-by-step and basically got the answer, "It doesn't work". I know that myself.

I asked if this is VLC issue or v4l2 issue so I could better diagnose the cause of the problem.

Re: [Ubuntu, vlcj] Multiple camera streams fails (v4l2)

Posted: 29 Nov 2011 16:52
by Rémi Denis-Courmont
STREAMON returning EBUSY means another program is already streaming the same video device. You can read the V4L2 documentation for yourself.

And I have no problem opening video0 and video1 simultaneously with VLC 1.1.12 nor HEAD.

Re: [SOLVED] [Ubuntu, vlcj] Multiple camera streams fails (v

Posted: 29 Nov 2011 23:14
by vale4674
Solved this, everything is in this post viewtopic.php?f=13&t=74077#p270135.

Who would've known...