To Stream Webcam to an Apache Server on the Raspberry Pi you need to have already:

  • Installed Apache – See this post.
  • Installed the Camera Module – See this post.

After you have done this you are ready to start.

First Step – Install FFmpeg

You should download, compile and install FFmpeg, a cross platform solution for streaming and recording including the codec you will need.

Remove any existing installation:

apt-get remove ffmpeg

Get the git installation link from the FFmpeg git page here.

I have included the link in the following commands:

git clone git://

Once this has completed, move into the directory and compile the source.

cd ffmpeg
make install

This can (and probably will) take hours on the Raspberry Pi so I recommend you put this in a script and run it over night or go watch a film.

Step 2 – Install crtmpserver

This can be done with apt-get.

apt-get install crtmpserver

but you will need to do some configuration, edit the following file:


Add/change the following setings:


And finally restart the service:

service crtmpserver restart

Final Step – Web setup

Install jwplayer on your web server. You can get this at:, once you have downloaded it, extract the files in:


Create an example webpage to display your webcam stream:

    <title>Raspberry Pi Webcam Streaming</title>
    <div id="video-jwplayer_wrapper" style="position: relative; display: block; width: 960px; height: 540px;">
      <object type="application/x-shockwave-flash" data="/jwplayer/jwplayer.flash.swf" width="100%" height="100%" bgcolor="#000000" id="video-jwplayer" name="video-jwplayer" tabindex="0">
        <param name="allowfullscreen" value="true">
        <param name="allowscriptaccess" value="always">
        <param name="seamlesstabbing" value="true">
        <param name="wmode" value="opaque">
      <div id="video-jwplayer_aspect" style="display: none;"></div>
      <div id="video-jwplayer_jwpsrv" style="position: absolute; top: 0px; z-index: 10;"></div>

    <script src="/jwplayer/jwplayer.js"></script>

    <script type="text/javascript">
      , file:"rtmp://" + window.location.hostname + "/flvplayback/flv:myStream.flv"
      , autoStart: true
      , rtmp:{
      , deliveryType: "streaming"
      , width: 960
      , height: 540
      , player: {
        modes: {
          linear: {
                , enabled: false
      , shows: {
        streamTimer: {
          enabled: true
          , tickRate: 100

Now check it works! Make sure you connect to it locally and not remotely. (192.168.* address).

To start the stream run the following command:

raspivid -t 0 -w 960 -h 540 -fps 25 -b 500000 -vf -o - | ffmpeg -i - -vcodec copy -an -f flv -metadata streamName=myStream tcp://

You should see a video stream similar to the image below:

Raspberry Pi Webcam Streaming
Raspberry Pi Webcam Streaming

(Yes, the webcam is pointed at the wall).

If you want to make this webcam stream accessible remotely, you need to port forward port 1935 to the raspberry pi.

Voila, now you can Stream Webcam to Apache Server on the Raspberry Pi.

For more information and references:

Share Button


    • Seems I missed this, use the following command:
      raspivid -t 0 -w 960 -h 540 -fps 25 -b 500000 -vf -o – | ffmpeg -i – -vcodec copy -an -f flv -metadata streamName=myStream tcp://

  1. So far I got it working with the replied command, but the stream I see is turned. I expect that you have to correct this in the index file but I cannot get it. Could you help on this?

  2. I get a connection refused error. I assume I must have something wrong but dont know where! I tried running raspivid with sudo, but didnt make any difference… anyone got any ideas?

    raspivid -t 0 -w 960 -h 540 -fps 25 -b 500000 -vf -o – | ffmpeg -i – -vcodec copy -an -f flv -metadata streamName=myStream tcp://
    ffmpeg version N-59216-g5eeeb4a Copyright (c) 2000-2013 the FFmpeg developers
    built on Dec 20 2013 00:57:42 with gcc 4.6 (Debian 4.6.3-14+rpi1)
    libavutil 52. 58.101 / 52. 58.101
    libavcodec 55. 45.102 / 55. 45.102
    libavformat 55. 22.100 / 55. 22.100
    libavdevice 55. 5.102 / 55. 5.102
    libavfilter 4. 0.100 / 4. 0.100
    libswscale 2. 5.101 / 2. 5.101
    libswresample 0. 17.104 / 0. 17.104
    Input #0, h264, from ‘pipe:’:
    Duration: N/A, bitrate: N/A
    Stream #0:0: Video: h264 (High), yuv420p, 960×540, 25 fps, 25 tbr, 1200k tbn, 50 tbc
    [tcp @ 0x176ca30] Connection to tcp:// failed: Connection refused
    tcp:// Connection refused

    • Sounds like crtmpserver is not running. Try running “service crtmpserver status” and “service crtmpserver restart”.

  3. Bart van de Lisdonk


    I followed all the steps in your tutorial, but when I go to the website page I don’t get a video stream in my firefox browser. When I look via a HDMI monitor a video stream is active.

    I don’t know what I’m doing wrong, can you help me?


  4. Thank you! It works very well (I tried from Safari).
    I see that I can’t stream to IOS devices. Have you tried to do it? Any hint?

  5. Hey you’re install and config guide is pretty good. Thanks

    But I have an understanding problem. You wrote ” If you want to make this webcam stream accessible remotely, you need to port forward port 1935 to the raspberry pi.”

    How does it work? If I try to connect remotely to my pi. I see nothing… But i want to see the Stream on the Webpage.
    Currently I see the stream on the HDMI Port from Pi.

    Thank you for you’re kind help
    best regard’s

    • Yes, for the remote access, I meant from anywhere on the internet. If you just want to access it on your home network, follow the guide and then browse to your raspberry pi’s IP address in a web browser:


      If you want to access it from anywhere, you must work out your IP ( and then allow port forwarding.

      Hope this helps!

  6. Excellent article. Two remarks so far.

    1) I am using nginx, and – out of the box – the jwplayer stuff should be placed in /usr/share/nginx/www.

    2) Running OK on Chrome 31. My Firefox 26 does not like the trailing slash in . After I’ve removed it, it worked fine. Another peculiarity of nginx??

  7. Hi, thanks so much for your tutorial, it is exactly what I was looking for, I have everything running fine, but I want to remote stream the video and I know how to port forward. I’ve my raspberry server running on port 81 (192.168.x.x:81) and I tried to access it after port forward port 81 to my external ip(189.214.x.x), at my Windows PC and it worked fine and I didn’t change the 1935 port but my PC are in the same LAN, so somehow it allows the streaming. And then I tried with an external network and it didn’t work :\ so I can’t figure it out where should I put the 1935. At the tcp:/ command or where should it put it??

    Thank you for your time!
    Best Regards!

  8. I’m just trying your tutorial. But I got a error(./configure: 2931: ./configure: cannot create config. log: Permission denied). I have been googling it, but I didn’t find anything. Please comment the solution. anyway, thanks for your tutorial.

    • Have you tried elevating your permissions with sudo for the configure? Looks like a permissions issue on the folder.


Leave a Reply

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