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!)

 

15 comments for “Streaming from the #RaspberryPi to Windows 7 64-bit

  1. bingo
    10 August 2013 at 3:30 pm

    I have the same issue, MPlayer not launched
    I discribed step by step my test at
    http://www.raspberrypi.org/phpBB3/viewtopic.php?f=43&t=52401&p=402571#p402571

  2. flyingtitan
    4 January 2014 at 1:28 pm

    Thanks, it works great. But is there a way to not stream to a specific IP address so that any PC on the LAN can see it?

  3. Thiago Moreira
    4 August 2014 at 6:18 pm

    Hi! Thanks for the tutorial! But it doesnt work for me 🙁 The cache just doesn’t fill up. it stays on “Cache fill: 0.00% (0 bytes)” forever…. I’m on Windows 8 and I took all the steps exactly as you explained. Do you have any idea?

    • 4 August 2014 at 9:44 pm

      Sounds like something specific to Windows 8… which isn’t good.

      • Thiago Moreira
        19 August 2014 at 2:31 pm

        When you refer the file “netcat-win32-1.12nc64.exe”
        doesnt you mean “netcat-win32-1.12/nc64.exe”??

        • recantha
          19 August 2014 at 3:05 pm

          Ahhhh. Yes. I believe so, Thiago.

          • Thiago Moreira
            19 August 2014 at 3:25 pm

            Thanks! That worked perfecty now!!

  4. Thiago Moreira
    16 September 2014 at 5:44 pm

    Hi Recantha, its me again.

    Do you know how to watch the stream and save it simultaneously?

    • recantha
      16 September 2014 at 5:47 pm

      Hi there. I don’t I’m afraid. I’m sure there’s some way of doing it so that you save the stream and then stream off of it, but I don’t know the commands. Try asking on the Raspberry Pi forums. Sorry! 🙁

  5. Thiago Moreira
    16 September 2014 at 5:55 pm

    Its ok. Thanks Anyway!

  6. Aayush Mahat
    20 July 2016 at 4:46 am

    How can I do it with USB camera?

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.