recantha
Posts: 209
Joined: Mon Jun 25, 2012 10:41 am

Webcam / ffmpeg on Raspbian

Fri Aug 10, 2012 2:37 pm

Hi.
Has anyone been able to get live video from a camera working on the Pi with the latest Raspbian build?
I'm getting Illegal Instruction errors when using ffserver and trying to compile ffmpeg on the Pi itself gives me a lot of errors during the Make.

--
Mike
My Raspberry Pi blog with all my latest projects and links to articles
http://raspberrypipod.blogspot.com. +++ Current project: PiPodTricorder - lots of sensors, lots of mini-displays, breadboarding, bit of programming.

User avatar
jasonclark
Posts: 59
Joined: Sun May 13, 2012 3:51 pm
Location: Hertfordshire, UK

Re: Webcam / ffmpeg on Raspbian

Sat Aug 11, 2012 1:09 pm

I've been looking into this for the last few days. I've got a Logitech C270 Cam, running the current Raspbian, cam is connected via Powered USB Hub.

I can get UVCCAPTURE running, slowly (2 or 3fps).
I've been trying to get OpenCV working via Python, but just get a black screen. The exact same (very simple) script runs ok on my Ubuntu box.

Sadly, my Linux skils are pretty low, so I'm learning as I go. I've tried to follow the instructions to compile opencv on the 'PI, but its now failing the compile.

I think my next step will be to try Arch Linux as I hear some people have WebCams working with that.
Once I've got something working, I'll post.

SirLagz
Posts: 1705
Joined: Mon Feb 20, 2012 8:53 am
Location: Perth, Australia

Re: Webcam / ffmpeg on Raspbian

Sat Aug 11, 2012 2:48 pm

You shouldn't be getting illegal instruction if you installed ffmpeg from the Raspbian repos.
What's in your /etc/apt/sources.list file ?

Also - check this. This is how I got ffmpeg working on Raspbian.
http://sirlagz.net/?p=493
My Blog - http://www.sirlagz.net
Visit my blog for Tips, Tricks, Guides and More !
WiFi Issues ? Have a look at this post ! http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=44044

recantha
Posts: 209
Joined: Mon Jun 25, 2012 10:41 am

Re: Webcam / ffmpeg on Raspbian

Sat Aug 11, 2012 3:12 pm

Yeah, it was your guide I was following ;-)
It's okay - I'm going to start from scratch with a fresh install anyway
What should I have for sources.list?
My Raspberry Pi blog with all my latest projects and links to articles
http://raspberrypipod.blogspot.com. +++ Current project: PiPodTricorder - lots of sensors, lots of mini-displays, breadboarding, bit of programming.

SirLagz
Posts: 1705
Joined: Mon Feb 20, 2012 8:53 am
Location: Perth, Australia

Re: Webcam / ffmpeg on Raspbian

Sun Aug 12, 2012 2:38 am

Ah righto lol.

You should have only mirrordirector.rasbian.net (or something like that - my pi is dead atm lol)

paste up your sources.list
My Blog - http://www.sirlagz.net
Visit my blog for Tips, Tricks, Guides and More !
WiFi Issues ? Have a look at this post ! http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=44044

recantha
Posts: 209
Joined: Mon Jun 25, 2012 10:41 am

Re: Webcam / ffmpeg on Raspbian

Sun Aug 12, 2012 5:36 am

Ahhhh. It compiled this time :-) Followed your guide.
Still not got it streaming, but I think that's my camera :-)
My Raspberry Pi blog with all my latest projects and links to articles
http://raspberrypipod.blogspot.com. +++ Current project: PiPodTricorder - lots of sensors, lots of mini-displays, breadboarding, bit of programming.

SirLagz
Posts: 1705
Joined: Mon Feb 20, 2012 8:53 am
Location: Perth, Australia

Re: Webcam / ffmpeg on Raspbian

Sun Aug 12, 2012 7:34 am

Some cameras seem to be hit and miss still.
If you get it working, leave the solution in a comment on my blog if you could. Would help others who are trying the same thing :)
My Blog - http://www.sirlagz.net
Visit my blog for Tips, Tricks, Guides and More !
WiFi Issues ? Have a look at this post ! http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=44044

naplam
Posts: 43
Joined: Tue Aug 14, 2012 11:04 pm

Re: Webcam / ffmpeg on Raspbian

Sat Aug 18, 2012 11:26 am

UVC cameras should work in general. However, I've found these problems:
- ffmpeg is buggy and basically doesn't work at all for streaming. Solution: compile from source
- Resolution, frame rate and pixel format are not set properly by ffmpeg. Solution: use v4l2-ctl and set it before using ffmpeg.

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

Re: Webcam / ffmpeg on Raspbian

Fri Aug 24, 2012 6:43 pm

SirLagz wrote:This is how I got ffmpeg working on Raspbian.
http://sirlagz.net/?p=493
I've followed your guide and compiled ffmpeg on the Pi.
I'm using the latest respian build:

Code: Select all

Linux raspberrypi 3.2.27+ #60 PREEMPT Thu Aug 23 15:33:51 BST 2012 armv6l GNU/Linux
However when I try and run the webcam.sh using a Logitech C910 webcam at 640x480 using the webcam.sh script I see the following:

Code: Select all

ffserver version 0.11.1 Copyright (c) 2000-2012 the FFmpeg developers
 built on Aug 22 2012 19:36:43 with gcc 4.6.3
 configuration: --enable-libv4l2
 libavutil 51. 54.100 / 51. 54.100
 libavcodec 54. 23.100 / 54. 23.100
 libavformat 54. 6.100 / 54. 6.100
 libavdevice 54. 0.100 / 54. 0.100
 libavfilter 2. 77.100 / 2. 77.100
 libswscale 2. 1.100 / 2. 1.100
 libswresample 0. 15.100 / 0. 15.100
ffmpeg version 0.11.1 Copyright (c) 2000-2012 the FFmpeg developers
 built on Aug 22 2012 19:36:43 with gcc 4.6.3
 configuration: --enable-libv4l2
 libavutil 51. 54.100 / 51. 54.100
 libavcodec 54. 23.100 / 54. 23.100
 libavformat 54. 6.100 / 54. 6.100
 libavdevice 54. 0.100 / 54. 0.100
 libavfilter 2. 77.100 / 2. 77.100
 libswscale 2. 1.100 / 2. 1.100
 libswresample 0. 15.100 / 0. 15.100
[video4linux2,v4l2 @ 0x2c73550] [3]Capabilities: 5000001
libv4l2: error allocating conversion buffer
[video4linux2,v4l2 @ 0x2c73550] mmap: Cannot allocate memory
/dev/video0: Cannot allocate memory
Any thoughts on how to solve this?

I've tried using different memory splits but none of them solve the issue.

SirLagz
Posts: 1705
Joined: Mon Feb 20, 2012 8:53 am
Location: Perth, Australia

Re: Webcam / ffmpeg on Raspbian

Sat Aug 25, 2012 1:03 am

tried a lower resolution ?
My Blog - http://www.sirlagz.net
Visit my blog for Tips, Tricks, Guides and More !
WiFi Issues ? Have a look at this post ! http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=44044

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

Re: Webcam / ffmpeg on Raspbian

Sat Aug 25, 2012 6:07 am

SirLagz wrote:tried a lower resolution ?
Yeah, Exactly the same message, even at 176x144

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

Re: Webcam / ffmpeg on Raspbian

Sat Aug 25, 2012 6:22 am

fbutler wrote:
SirLagz wrote:tried a lower resolution ?
Yeah, Exactly the same message, even at 176x144
Doh! Found the issue. I had compiled with a --enable-libv4l2 configuration option in an effort to get around other error messages and I forgot to do the final sudo make install after the 3 hour compilation. All working now

tekmanro
Posts: 14
Joined: Tue Jul 17, 2012 9:57 pm

Re: Webcam / ffmpeg on Raspbian

Sun Aug 26, 2012 4:34 am

What resolution / framerate are you getting now?

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

Re: Webcam / ffmpeg on Raspbian

Sun Aug 26, 2012 5:52 am

tekmanro wrote:What resolution / framerate are you getting now?
At 320x240 I see between 6-7fps but with loads of duplicate frames, and the picture is very choppy viewing with VLC. I've stopped testing for now until I can try with an MPEG2 license to see what difference that makes.

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

Re: Webcam / ffmpeg on Raspbian

Sun Aug 26, 2012 9:05 am

SirLagz wrote:You shouldn't be getting illegal instruction if you installed ffmpeg from the Raspbian repos.
What's in your /etc/apt/sources.list file ?

Also - check this. This is how I got ffmpeg working on Raspbian.
http://sirlagz.net/?p=493
From some more testing it looks like these instructions don't include alsa for sound in the ffmpeg build. I believe that you need to do a

sudo apt-get install libasound2-dev

before doing a ./configure as the configure automatically checks for alsa header files and doesn't compile ffmpeg with alsa unless these are present. I'm recompiling now to check this.

SirLagz
Posts: 1705
Joined: Mon Feb 20, 2012 8:53 am
Location: Perth, Australia

Re: Webcam / ffmpeg on Raspbian

Sun Aug 26, 2012 11:26 am

indeed it doesn't as I did not have a need of sound at the time. if what you do works, I'll update my blog :)
My Blog - http://www.sirlagz.net
Visit my blog for Tips, Tricks, Guides and More !
WiFi Issues ? Have a look at this post ! http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=44044

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

Re: Webcam / ffmpeg on Raspbian

Sun Aug 26, 2012 11:45 am

SirLagz wrote:indeed it doesn't as I did not have a need of sound at the time. if what you do works, I'll update my blog :)
I guessed as much. I can confirm that it now recognises alsa. :)

Code: Select all

[alsa @ 0x155a390] Estimating duration from bitrate, this may be inaccurate
Guessed Channel Layout for  Input Stream #1.0 : stereo
Input #1, alsa, from 'hw:1,0':
  Duration: N/A, start: 1345981083.761076, bitrate: 768 kb/s
    Stream #1:0: Audio: pcm_s16le, 24000 Hz, stereo, s16, 768 kb/s
Now to try and get the rest of the correct audio parameters figured out :)

SirLagz
Posts: 1705
Joined: Mon Feb 20, 2012 8:53 am
Location: Perth, Australia

Re: Webcam / ffmpeg on Raspbian

Sun Aug 26, 2012 1:15 pm

Thanks for the effort !
I'll update my blog :)
My Blog - http://www.sirlagz.net
Visit my blog for Tips, Tricks, Guides and More !
WiFi Issues ? Have a look at this post ! http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=44044

andrewdbyrne
Posts: 2
Joined: Wed Apr 29, 2015 2:21 pm

Re: Webcam / ffmpeg on Raspbian

Thu May 07, 2015 3:45 pm

Hi Sir Lagz

I am compiling FFMPEG from your guide on my raspberry pi and it seems like it is compiling for a very long time, almost over 30 mins just constantly saying CC libavcpdec/<whatever library>

Should it take this long ? I plan on streaming from my raspberry pi using HTML5 and Nodjs websockets. Looked around and it seems to be quite a good FPS and quality.

What do you think of this ?

Cheers

Return to “Graphics, sound and multimedia”