Streaming from the #RaspberryPi to Windows 7 64-bit

After trying the instructions here to use netcat and mplayer to stream from the Raspberry Pi camera module to Windows, I found that although the cache filled on the Windows machine, indicating that data was being received, mplayer never launched. I searched around a bit and came to the conclusion that it was something to do with either Windows 7, or having a 64-bit machine. I settled for the 64-bit issue as it’s not uncommon for the 64-bit architecture to create problems.

I eventually found a combination of netcat and mplayer that worked! Here’s a tutorial on how to do it.

How to do it

Download netcat 1.12 from here.

Download the AMD64 version of mplayer r36169 from here.

Unzip them on a Windows machine into a folder so you have, amongst other files::

    MPlayer-x86_64-r36169+g2844ea8mplayer.exe
    netcat-win32-1.12nc64.exe

Created a batch file (called Wait-for-stream.bat) with the following command in it:

netcat-win32-1.12/nc64.exe -L -p 5001 | "MPlayer-x86_64-r36169+g2844ea8mplayer.exe" -vo direct3d -fps 31 -cache 1024 -

Note: I had to specify the -vo direct3d option as otherwise all I got was a black screen. No idea why this was needed, but I guess it’s something to do with my laptop specifically, so you may find you don’t need it.

On the Raspberry Pi, create a script (stream-to-netcat.sh) and add the following line to it:

raspivid -t 999999 --hflip -o - | nc 192.168.1.64 5001

An explanation:

  • -t 999999 means that the camera will keep capturing for that number of milliseconds. Increase if you need to.
  • -hflip Currently, the camera flips its output horizontally. This is something to do with the camera being ‘front facing’. This is being reviewed to see if it can be changed (which I know it can because it used to work the correct way around)
  • -o –  This means ‘output the data to standard out’ – effectively dump the output to the console.
  • | nc – This means send the output from the camera through a ‘pipe’ into netcat (which does the actual broadcast)
  • The IP address is the address of my Windows 7 64-bit laptop.

On the Windows, run the batch script Wait-for-stream.bat to start the ‘listener’. You should get:

MPlayer sherpya-r36169+g2844ea8-4.6 (C) 2000-2013 MPlayer Team
Playing -.
Reading from stdin...
Cache fill: 0.00% (0 bytes)

On the Pi, run the stream-to-netcat.sh script. Nothing should appear on the Pi.

On the Windows machine, the Cache will start to fill up, a bit of Codec debug will appear and the video should show on-screen.

And that’s it! A lot of fiddling about, but worth it so I can run Windows on Saturday at the Cambridge Jam! (And just to prove I could!)