Use USB Camera on Android application-ThrowExceptions

Exception or error:

I need to display a video transmitted by an USB Camera connected to my tablet on Android 3.2.

How can I do this?

I can’t use the tablet’s camera, because my tablet is fixed on board.

How to solve:

(I wrote this in 2012 when there was no support for USB camera. I am not working on Android anymore.. so I cannot explain how to do it with the API of latest Android. If you know any better solution please post it here.)

The discussion holds true only if the sensor inside USB camera is UVC compliant(most of todays’ cameras are compliant).

As of the date of this post(March 1 2012), there are no default Android API’s available for working on external camera. So if you are serious about the project, the work you do would involve writing a firmware that talks to the kernel drivers and then displaying the data on the Android application layer.

When you insert a USB camera, There are few things that you need to check first.

1) Is your camera getting power from USB port?(For this to happen your USB port should have USB-OTG support- USB port can act both as target and host, Check whether the lights on camera(if any) are glowing or not?)

2) Is node getting created in /dev directory?(Only in case the kernel has v4l2 and UVC support enabled,node will be created). If node is getting created, now you have access to the real hardware that is USB camera and your job is going to be easy from here on. to check do ls -l /dev/v* inside the android file system and check whether video0 or video1 is being created.

4) If node is created, you need to write a firmware(UVC) and acquire a frame from the real hardware. It(UVC) supports different ioctl calls that talk to the v4l2 layer in the kernel and will fetch you the frames.

These frames would be mostly of format YUYV422 or YUYV420 format.

Once you receive the frames, convert into RGB or Jpeg (Android has support to convert ) and display on the canvas or imageview whichever you like.

For recording you might have to use ffmpeg for encoding. This will convert the images into video.


One thing worth checking before you get started is whether your USB cable works with a mouse, keyboard, and USB Drive (you will need to StickMount app on some devices to get the USB drive working).

I am also looking to get a USB webcam working on Android and am trying to reproduce what was done at Lastly I heard that Bluetooth webcams work out of the box.


Now (2017) there are android apps supporting USB video input:

Probably a “Y-shaped” OTG cable is required (“Y-shaped” OTG cables allow powering the external device)

Leave a Reply

Your email address will not be published. Required fields are marked *