Take the 2-minute tour ×
Raspberry Pi Stack Exchange is a question and answer site for users and developers of hardware and software for Raspberry Pi. It's 100% free, no registration required.

I have a logitech C920 webcam. It has the ability to directly encode the video in H264.

I want to reproduce what was done with a Beaglebone, but using a Raspberry Pi: send a H264 stream to the network. The Raspberry Pi is then only here to packetize the stream in RTP, the video compression is done by the webcam itself. The H264 mode is enforced using video4linux.

So far, and if I use a common computer with the latest version of Ubuntu, it works using VLC as a server or GStreamer. For instance, if I launch on Raspberry Pi a VLC server using the command:

cvlc --sout=#rtp{sdp=rtsp://:8554/test} 'v4l2:///dev/video0:chroma=H264:width=800:height=600:fps=30'

... and then if I read the stream with VLC on another computer, all is right.

However, if I use the raspberry Pi to send the video stream, the result is quite poor. Lots of garbage in the image as soon as something moves. Image keys are well received every 10 seconds, but in the meanwhile, it is not good enough as compared with the stream from a common computer.

I also tried the method described for the beaglebone with the provided "capture" utility: ok if I stream from a real computer, same garbage problem if I stream from a Raspberry Pi.

It is not a network problem: I did some network checks with Wireshark and the statistics of VLC, I have no packet loss. I tried with Raspbian, and Arch Linux for Raspi (gstreamer 0.10 in raspbian, gstreamer 1.0 in Arch Linux).

I do not know if it is relevant or not, but I also tested with the soft float support version of Raspbian. An update must be done first to use a 3.2 kernel ; but same problem, the video has some garbage.

Any idea on what I could do to enhance the video quality?

share|improve this question
    
Try reducing the frame rate. The CPU of the rPi is very poor, so I guess transmitting a 800x600 image at 30FPS is too much. Only the new rPI camera board which is connected via the MIPI/CIS connector (instead of USB) streams 1080p at 15-30 FPS. –  Matthias Jun 19 '13 at 9:32
    
Its not FPS. The Pi can handle HD at 60FPS with no problem using the Pi Camera module. If the Logitech camera send H264 video its already encoded and the Pi needs to re boradcast the packets.. which it is entirely capable of. In fact it can rebroadcast up 6 HD@25FPS streams before it maxes out. It must be the V4L driver corrupting packets –  ppumkin Sep 19 '13 at 20:55

4 Answers 4

You can try and use FFMPEG. But the problem is not to use the repositories version because it is outdatted. There is a forked version that works really well.

You will have to compile it which takes 5 or so hours or download a precompiled binary.

You can then pipe the data from the V4L driver to FFMPEG with these settings. Where the -i "fifo" should just be -i to caputre the piped stream and the -f you will need to double check how to output it H264. the FLV repackages it into FLV that can be played with HTML players.

ffmpeg -y \  
  -f h264 \  
  -i "$fifo" \  
  -c:v copy \  
  -map 0:0 \  
  -f flv "$urllocal"   

or an exmaple I found that targets V4L directly but oyu have to have the camera present in /dev/video* where * is 1 or more...

ffmpeg -f video4linux2 -r 25 -s 640x480 -i /dev/video0 out.avi

the -f denotes the format to output in. It does not mean it will transcode it like H264 to FLV just gets wrapped in the FLV format. then change the address to your clients VLC player. for example -f mpegts udp:192.168.1.19:1234

VLC does not seem to work too well on the Pi. I had very little success pushing the Pi cmaera module to my PC using UDP. It worked but it was not stable.

You may also look at install nginx with rtmp module that works a treat. Look at this guide but you will need to tweak the settings a bit. You then connect your VLC player to the nginx-rtmp stream and it will work like a charm.

share|improve this answer
    
Which forked version is the one that works well? –  Brian Feb 22 at 20:42

If I understood your situation well, you want Raspberry to transcode video to H264? I think that is why you get bad performance, because VLC is using software encoding and Raspberryis not powerful for that task.

I would suggest to to try with Gstreamer and gst-omx plugins. There is element for hardware video encoding that would make good server from your Raspberry.

share|improve this answer
    
As he said, the Logitech camera provides H.264 already. So the rPi is only transporting frames but not doing any encoding. –  Matthias Jun 19 '13 at 9:25
    
He is not transcoding. Just rebroadcasting the data. As in it uses stream directly. –  ppumkin Sep 19 '13 at 20:56

Try with larger buffer on the client displaying the video. For me there is dramatic difference between 1000ms buffer and 200ms buffer. 5000ms buffer looks better than 1000ms buffer.

:network-caching=2000

share|improve this answer
    
It should work with 0 caching with the odd jittering on LAN.I got the Pi camera module to work like that with no problem. –  ppumkin Sep 19 '13 at 20:57

I had the same problem, found this thread when searching for a hardware encoder, not for c920 issues.

Nevertheless, execute a firmware update for the raspberry pi and the garbage should be gone

$> sudo rpi-update

I myself found the solution here: http://wiki.matthiasbock.net/index.php/Logitech_C920,_streaming_H.264#Raspberry_Pi

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.