Getting camera stream data to virtual node created using v4l2loopback


#1

Hi

I am using OV5675 CSI camera sensor. My requirement is to get the stream data from camera while any camera app using the camera. I have created virtual dev nodes(/dev/video*) using v4l2loopback. So how can i proceed to get the stream to virtual from camera device. If any other solutions please let me know.

Thanks


#2

Is it possible?? If anyone have any idea please suggest.


#3

if you have loopback devices you should be able to feed your devices with gstreamer.

e.g.

gst-launch-1.0 v4l2src device=/dev/video0 ! tee name=t ! queue ! v4l2sink device=/dev/video1 t. ! queue ! v4l2sink device=/dev/video2

#4

Hi Loic

Thank you so much for your response.
Do i need to build gstreamer for android separately?
or any prebuilt binaries i can get?

Thanks


#5

Actually i have tried with ffmpeg using below command
ffmpeg -i /dev/video0 /dev/video1
But it throws an error as “Device or resource busy”


#6

You can try:

ffmpeg -f v4l2 -i /dev/video0 -f v4l2 /dev/video1

This will feed video1 with video0 as input.
If it shows a resource busy error, that could mean your video0 is already open by an other application.


#7

Hi

Is there any ffmpeg command to start streaming? Means any way to get data into video0 without the help of any camera app. Like roslaunch.


#8

What do you mean by ‘streaming’, is it displaying the video stream ?
If yes, you can use ffplay for that.

e.g.

ffplay /dev/video1

#9

I mean is there any ffmpeg command which initiates camera to start capturing and pushing data to video0? Instead of using any camera app.


#10

Don’t understand, in your original post you want to be able to read camera stream concurrently by two different applications. You can achieve this by creating two v4l2 loopback devices and redirecting the stream from /dev/video0 (camera) to /dev/video1 (loopback) and /dev/video2 (loopback). You can then use /dev/video1 for an application and /dev/video2 for the other.

if /data/video0 is you camera, the stream will be started when a consumer application (gstreamer, ffmpeg, player…) open it and send a particular ioctl (VIDIOC_STREAMON).


#11

Hi Loic

Its working in Linux. But in android its throwing errror as /dev/video0 device or resource busy, even though its not used by any other app.
I haven’t opened the camera by any app, just ran ran ffmpeg -f v4l2 -i /dev/video0 -f v4l2 /dev/video1.
Any idea ?
Thanks


#12

To be sure you can run lsof and see if any program use the device (e.g. lsof | grep video).
Could you attach ouput of ffmpeg command ?
Are you sure video1 is your v4l2loopback device on Android? (v4l2-ctl -D -d /dev/video1)