simonb
Posts: 7
Joined: Fri May 24, 2013 6:15 am

Using EasyCap instead of camera

Fri May 31, 2013 9:15 am

I would like to capture from an EasyCap USB video capture stick, encode to H264 and stream to rtmp.

The EasyCap seems to be recognised OK and shows up on /dev/video.

For the camera one would normally use something like raspivid piped into ffmpeg. Unfortunately raspivid is locked to the camera hardware.

I've been looking at trying to recompile a version of raspivid that takes video from whatever is on /dev/video and sends it through the H264 hardware encoder. I have tried to recompile the "userland" tools but it flunks with link errors. I've tried to find the source deb for raspberrypi-firmware, which contains raspivid, but it is not available because the package is binary-only firmware.

So my questions are,

1) Am I on the right track or barking up the wrong tree? Am I making life difficult for myself by re-inventing the wheel and there is an easier way to get access to the hardware H264 encoder?

2) If I am on the right track then how do I get raspivid to recompile? I've found some instructions in the README that led me to set up distcc. However, having done that, the buildme script still uses some hardlinked local compiler. And I get the link errors again.

User avatar
topguy
Posts: 6981
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Using EasyCap instead of camera

Fri May 31, 2013 9:36 am

- Have you verified that you CAN grab video from EasyCap with standard tools ?

You are probably not the first to try to use EasyCap nor try to use the x264 encoder. Have you searched the forum for similar threads ?

simonb
Posts: 7
Joined: Fri May 24, 2013 6:15 am

Re: Using EasyCap instead of camera

Fri May 31, 2013 9:54 am

Yes. I have found a few snippets. Probably the closest one to what I am trying to do is this one...
http://www.raspberrypi.org/phpBB3/viewt ... 38&t=41844

It leads to the GST module, OMX.broadcom.video_encode.

I will look at this but it will take me a while to figure out gstreamer pipes, especially if I want to encode sound too. If anyone can suggest an example gstreamer command that will take a v4L2 and ALSA source and produce an H264 file or stream would help me considerably.

User avatar
fbutler
Posts: 302
Joined: Thu Mar 15, 2012 4:09 pm
Location: Surrey, England

Re: Using EasyCap instead of camera

Fri May 31, 2013 10:01 am

simonb wrote:If anyone can suggest an example gstreamer command that will take a v4L2 and ALSA source and produce an H264 file or stream would help me considerably.
Here is one that I have used. It may need some adjustment for your setup:

Code: Select all

gst-launch-1.0 -t -e -v avimux name=mux ! filesink location=test.avi alsasrc  device=hw:2,0 ! audio/x-raw, format=S16LE, rate=48000, channels=2 ! queue ! mux. v4l2src device=/dev/video0 ! video/x-raw, format='UYVY'! videoconvert ! video/x-raw,format='I420', width=720, height=576, framerate=25/1 ! omxh264enc ! mux.

simonb
Posts: 7
Joined: Fri May 24, 2013 6:15 am

Re: Using EasyCap instead of camera

Fri May 31, 2013 11:12 am

Thanks! Much appreciated.

I had to install gstreamer1.0. This is how I did it (for anyone else who may find this thread useful).

I created a file /etc/apt/sources.list.d/gstreamer1.0.list with the following contents...

Code: Select all

deb http://vontaene.de/raspbian-updates/ . main
I then installed gstreamer1.0 and associated packages...

Code: Select all

sudo apt-get update
sudo apt-get install gstreamer1.0-alsa gstreamer1.0-plugins-bad gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-ugly gstreamer1.0-tools gstreamer1.0-x  gstreamer1.0-omx
The only tweak I had to make to the suggested command line was setting the alsa device to "device=hw:1,0".

I now need to find a real PAL video source and see if this really does capture video.

User avatar
Defiant
Posts: 181
Joined: Tue Oct 30, 2012 6:17 pm
Location: Hamburg, Germany

Re: Using EasyCap instead of camera

Fri May 31, 2013 8:36 pm

The rpi can output PAL ;)

Did you have any success with your easycap device?
If yes, which one is it?

simplesi
Posts: 2327
Joined: Fri Feb 24, 2012 6:19 pm
Location: Euxton, Lancashire, UK
Contact: Website

Re: Using EasyCap instead of camera

Fri May 31, 2013 8:45 pm

If you can get this to work - you'll have opened up the RPi to another whole geek eco-system :)

Simon
Seeking help with Scratch and I/O stuff for Primary age children
http://cymplecy.wordpress.com/ @cymplecy on twitter

flyingbaloon
Posts: 5
Joined: Tue Jan 12, 2016 6:08 am

Re: Using EasyCap instead of camera

Tue Jan 12, 2016 6:18 am

fbutler wrote:
simonb wrote:If anyone can suggest an example gstreamer command that will take a v4L2 and ALSA source and produce an H264 file or stream would help me considerably.
Here is one that I have used. It may need some adjustment for your setup:

Code: Select all

gst-launch-1.0 -t -e -v avimux name=mux ! filesink location=test.avi alsasrc  device=hw:2,0 ! audio/x-raw, format=S16LE, rate=48000, channels=2 ! queue ! mux. v4l2src device=/dev/video0 ! video/x-raw, format='UYVY'! videoconvert ! video/x-raw,format='I420', width=720, height=576, framerate=25/1 ! omxh264enc ! mux.
Hi
Iam trying to play easy cap capture using the gpu . I am unable to get the suggested pipeline to work

Code: Select all

gst-launch-1.0 -t -e -v avimux name=mux ! filesink location=test.avi alsasrc  device=hw:1,0 ! audio/x-raw, format=S16LE, rate=48000, channels=2 ! queue ! mux. v4l2src device=/dev/video0 ! video/x-raw, format='YVYV'! videoconvert ! video/x-raw,format='I420', width=720, height=480, framerate=25/1 ! omxh264enc ! mux.
it gives me error could not link v4l2src0 to videoconvert0 . Please help me out . thanks

Return to “Camera board”