Webcam streaming with ffmpeg and ffserver

This forum is for topics specific to the Raspberry Pi and Arch Linux ARM

Webcam streaming with ffmpeg and ffserver

Postby manwichmakesameal » Sun Dec 02, 2012 4:41 pm

Ok, I'm trying to stream a webcam with Arch on my Pi, but I keep getting this:
$this->bbcode_second_pass_code('', '[video4linux2,v4l2 @ 0x126620] [3]Capabilities: 5000001
[video4linux2,v4l2 @ 0x126620] The driver changed the time per frame from 1/5 to 1/30
libv4l2: error allocating conversion buffer
[video4linux2,v4l2 @ 0x126620] mmap: Cannot allocate memory
/dev/video0: Cannot allocate memory')

Here is my ffserver.conf:
$this->bbcode_second_pass_code('', 'Port 80
BindAddress 0.0.0.0
MaxClients 4
MaxBandwidth 10000
NoDaemon

<Feed webcam.ffm>
File /tmp/webcam.ffm
FileMaxSize 5M
</Feed>

<Stream status.html>
Format status
# Only allow local people to get the status
ACL allow localhost
ACL allow 192.168.0.0 192.168.255.255
</Stream>

<Stream webcam.mjpeg>
Feed webcam.ffm
Format mjpeg
VideoSize 640x480
VideoFrameRate 30
VideoBitRate 10000
VideoQMin 1
VideoQMax 10
</Stream>
')

And here is how I run ffmpeg:
$this->bbcode_second_pass_code('', 'ffmpeg -v verbose -r 5 -s 640x480 -f video4linux2 -i /dev/video0 http://localhost/webcam.ffm')

I've searched and seen all kinds of posts with this error, but no resolution. Any help would be awesome.
manwichmakesameal
 
Posts: 5
Joined: Sun Dec 02, 2012 4:36 pm

Re: Webcam streaming with ffmpeg and ffserver

Postby xenoxaos » Sun Dec 02, 2012 4:52 pm

what about mjpeg-streamer or motion/motion-noffmpeg (lighter dependencies as ffmpeg isnt built into motion)
Arch Linux ARM exists and continues to grow through community support, please donate today!
xenoxaos
Developer
 
Posts: 323
Joined: Thu Jan 06, 2011 1:45 am

Re: Webcam streaming with ffmpeg and ffserver

Postby manwichmakesameal » Sun Dec 02, 2012 5:38 pm

I tried to use motion, but not motion-noffmpeg. The quality of the video wasn't very good. I tried this exact setup on a different machine and it worked perfectly. I'm just trying to figure out why I'm getting the allocate memory error. I tried adjusting the gpu_mem option in /boot/config.txt too. I gave the gpu 128, not sure if that helps or not.

edit: I tried to use motion-noffmpeg and got much better image results. Only now it stops responding after a couple of minutes. I can't reach the camera feed or the control page.
manwichmakesameal
 
Posts: 5
Joined: Sun Dec 02, 2012 4:36 pm

Re: Webcam streaming with ffmpeg and ffserver

Postby xenoxaos » Sun Dec 02, 2012 6:39 pm

Interesting that you would get better quality with -noffmpeg as it's the EXACT same thing. As for it dropping out after a few minutes, check dmesg to see if you're having usb problems.
Arch Linux ARM exists and continues to grow through community support, please donate today!
xenoxaos
Developer
 
Posts: 323
Joined: Thu Jan 06, 2011 1:45 am

Re: Webcam streaming with ffmpeg and ffserver

Postby manwichmakesameal » Sun Dec 02, 2012 6:45 pm

Turns out that the video quality was bad due to running motion in setup mode. I tried both and ran with a config file and both give better image results. There is nothing in dmesg showing usb problems when it drops. Back to the problem at hand though, I still get the memory allocation error even when changing the gpu_mem to 32 in /boot/config.txt.
manwichmakesameal
 
Posts: 5
Joined: Sun Dec 02, 2012 4:36 pm

Re: Webcam streaming with ffmpeg and ffserver

Postby xenoxaos » Sun Dec 02, 2012 7:08 pm

How many /dev/videoX devices do you have? ls /dev/video*

also try running $this->bbcode_second_pass_code('', 'ffmpeg -v verbose -list_formats all -f video4linux2 -i /dev/video0')
Arch Linux ARM exists and continues to grow through community support, please donate today!
xenoxaos
Developer
 
Posts: 323
Joined: Thu Jan 06, 2011 1:45 am

Re: Webcam streaming with ffmpeg and ffserver

Postby manwichmakesameal » Sun Dec 02, 2012 7:13 pm

I only have video0. I tried using mjpeg-streamer too. No luck with that either. When I try:$this->bbcode_second_pass_code('', 'mjpg_streamer -i "input_uvc.so -d /dev/video1" -o "output_http.so"') I get:$this->bbcode_second_pass_code('', 'MJPG Streamer Version.: 2.0
i: Using V4L2 device.: /dev/video1
i: Desired Resolution: 640 x 480
i: Frames Per Second.: 5
i: Format............: MJPEG
ERROR opening V4L interface: No such file or directory
Init v4L2 failed !! exit fatal
i: init_VideoIn failed')

edit: I had the wrong device with the mjpg_streamer command above. This is the error I get when using the right device:
$this->bbcode_second_pass_code('', 'MJPG Streamer Version.: 2.0
i: Using V4L2 device.: /dev/video0
i: Desired Resolution: 640 x 480
i: Frames Per Second.: 5
i: Format............: MJPEG
Unable to set format: Invalid argument
Init v4L2 failed !! exit fatal
i: init_VideoIn failed')

edit2: Here is the output from the ffmpeg command:
$this->bbcode_second_pass_code('', 'ffmpeg version 1.0 Copyright (c) 2000-2012 the FFmpeg developers
built on Nov 17 2012 20:46:29 with gcc 4.7.2 (GCC)
configuration: --prefix=/usr --enable-libmp3lame --enable-libvorbis --enable-libxvid --enable-libx264 --enable-libvpx --enable-libtheora --enable-libgsm --enable-libspeex --enable-postproc --enable-shared --enable-x11grab --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libschroedinger --enable-libopenjpeg --enable-librtmp --enable-libpulse --enable-libv4l2 --enable-gpl --enable-version3 --enable-runtime-cpudetect --disable-debug --disable-static
libavutil 51. 73.101 / 51. 73.101
libavcodec 54. 59.100 / 54. 59.100
libavformat 54. 29.104 / 54. 29.104
libavdevice 54. 2.101 / 54. 2.101
libavfilter 3. 17.100 / 3. 17.100
libswscale 2. 1.101 / 2. 1.101
libswresample 0. 15.100 / 0. 15.100
libpostproc 52. 0.100 / 52. 0.100
[video4linux2,v4l2 @ 0x21a5f0] [3]Capabilities: 5000001
[video4linux2,v4l2 @ 0x21a5f0] R : yuyv422 : YUV 4:2:2 (YUYV) : 640x480 352x288 320x240 176x144 160x120
/dev/video0: Immediate exit requested')
manwichmakesameal
 
Posts: 5
Joined: Sun Dec 02, 2012 4:36 pm

Re: Webcam streaming with ffmpeg and ffserver

Postby xenoxaos » Sun Dec 02, 2012 7:24 pm

mjpg-streamer won't work because your camera doesn't support MJPEG directly, just raw video.
Arch Linux ARM exists and continues to grow through community support, please donate today!
xenoxaos
Developer
 
Posts: 323
Joined: Thu Jan 06, 2011 1:45 am

Re: Webcam streaming with ffmpeg and ffserver

Postby manwichmakesameal » Sun Dec 02, 2012 8:03 pm

Well, I got mjpg-streamer to run with:$this->bbcode_second_pass_code('', 'mjpg_streamer -i "input_uvc.so -d /dev/video0 -q 100" -o "output_http.so -w /srv/www -p 80"') It just doesn't show anything with vlc or firefox.
manwichmakesameal
 
Posts: 5
Joined: Sun Dec 02, 2012 4:36 pm


Return to Raspberry Pi

Who is online

Users browsing this forum: No registered users and 33 guests