mandag den 4. juni 2012

Live c# video streaming webcam server and client

I wanted to capture live video from a webcam and stream it directly to a client application. This was thought to be for a robot which would stream video from its webcam eyes and allow me to see what the robot sees, but really it would be possible to build a cheap DIY home surveillance network around this.

The VS 2010 c# solution holds two projects, one commandline project for the server and one windows forms project for the client.

The server stream not video, but rather a series of captures images, but in presenting these images in a rapid fashion the end result will seem like a naturally flowing video stream. The images  made available to a connecting client IP by an initialized WCF service, namely via a tcp/ip binding. The images capture is done by utilizing the AForge framework to access an available webcam. The images are saved to disk and not to memory, as I wanted to retain the option of going through them again at a later point. The last captured image is always kept in memory, to be delivered to the calling client as the WCF's 'getWebCamImage()' method is invoked.

I set the web cam framerate to 15 frames per second, which is fine enough to moving images. The maximum number of images the human eye can distinguish is 30 per second, so I'm told, so 15 images per second makes for a comfortably video experience.

The client creates an instance of the WCF service. A timer is set to call the service and return an image-stream, which is placed into a standard winforms picturebox. In the example code the timer is set at 100 milliseconds, which will yield only 10 images per second - thus not the 15 frames which are actually captured, I did this to perserve bandwidth but in reality it should be perfectly possible to call the timer 15 times per second. The viewing experience is nice enough just the same.

Check out the source code below if you're in need of something like this. Please bear with all the references to 'robot this' and 'robot that', the functionality was meant for a robot control project. The WCF service runs localhost, but you would of course in due time seperate the client from the server and allow the service to run via an external IP, firewall-configured to the port of your choice and not my standard port no 8733.

Link to solution source code

Let me know if there's anything I can do to help you in implementing the project, if it gives you any trouble.

Hope this helps you!

Buy me a coffeeBuy me a coffee

22 kommentarer:

  1. Hi, how do i get this to work? i am pretty new at this ~ can you please help me? i downloaded and opened it in visual studio 2010, but have no idea how to change the port as stated. Please help me thanks!

    SvarSlet
    Svar
    1. Technical Stuff, Hopefully Useful To Some: Live C Video Streaming Webcam Server And Client >>>>> Download Now

      >>>>> Download Full

      Technical Stuff, Hopefully Useful To Some: Live C Video Streaming Webcam Server And Client >>>>> Download LINK

      >>>>> Download Now

      Technical Stuff, Hopefully Useful To Some: Live C Video Streaming Webcam Server And Client >>>>> Download Full

      >>>>> Download LINK Ta

      Slet
  2. Hi harley~ I really need you help ! I downloaded but don't know how to run the program, can you please explain to me what should i do? I am new to this and i need this for my project~, cheers!

    SvarSlet
  3. Hi Joel,

    sure I'll try and help you out. Send me an e-mail at morten the-a-with-the-circle-thingy mortennorgaard.dk and let's take it from there.

    Best,
    Morten

    SvarSlet
  4. Hi Morten,
    We try to run it, but alas...Could you please assist us.What is your email?
    Thanks
    Maya

    SvarSlet
  5. Hi Maya,

    sure I'll try and help you out. Send me an e-mail at morten the-a-with-the-circle-thingy mortennorgaard.dk and let's take it from there.

    Best,
    Morten

    SvarSlet
  6. sir, i have same problem like joel tanm can u send me a turtorial or explain to how to aply it??thx, this my email wisnu.jrj@gmail.com

    SvarSlet
  7. Hello, dear author.
    Can you give me some help about this project? I downoaded it but i can't use the program.

    I run the server and client in separated visual studio but nothing happend.
    For server i got an blank console with |server running text|
    for the client i got an c# form with an image inside a picturebox.

    Please help me [ nagy.ervin890[@]gmail.com ]

    Thank you advance.

    SvarSlet
  8. Denne kommentar er fjernet af forfatteren.

    SvarSlet
  9. sir can you please explain how to use it? my email id - dhruvjain.1027@gmail.com

    SvarSlet
  10. can you also explain how to use it? my email is biibbao@gmail.com

    SvarSlet
  11. Hello, Currently I use the trial version of this camera SDK to implement live streaming: http://www.camera-sdk.com/p_24-how-to-display-ip-camera-stream-on-a-website-in-c-onvif.html. But you made me curious about your solution. Only one question: Can your solution be used for IP cameras as well? Thanks

    SvarSlet
  12. Hello baumhard,
    There are no technical barrier for using the code with IP cameras. Indeed, the image capture and data transport is virtually the same.

    SvarSlet
  13. Hello,
    My name is Nick and I would like to thank you very much for your great post, I was looking for something like that and I was able to run it and test it. But I have one missing issue which is the audio, how can I transfer the audio to the client?

    SvarSlet
  14. hi, i am currently working on a project in which i have to do live trasmission through autonomous aerial vehicle, can u explain me how to integrate it with arduino using XBEE coz m using webcam for live trasmission.

    SvarSlet
  15. sir, i have a problem "Could not find default endpoint element that references contract 'WebCamService.IWebCamService' in the ServiceModel client configuration section.", this my email amaqs83@live.com

    SvarSlet
  16. Hello, i have a problem "Could not find default endpoint element that references contract 'WebCamService.IWebCamService' in the ServiceModel client configuration section.", this my email kroeber101@hotmail.com

    I am working on a project, where I need to stream video from a robot (server) to a control PC (client) if you could provide some help on what you have done that would be great. Thank you.

    SvarSlet
  17. Live streaming is the latest fad on social media so make sure to get live with your audience from time to time.
    Live streaming would give you a more intimate space with your viewers and encourage them to interact with you more often. It would allow more personal interaction with your audience in real time.
    You can also share your live videos later, so that those who have missed out the live streaming can view them again. A tour of your business, a demonstration of your products or an interview with the creators are some of the possible content which can be created with a live video.
    Make sure to make the most out of the apps which allows you to go live directly from the blog.

    SvarSlet
  18. Live streaming is the latest fad on social media so make sure to get live with your audience from time to time.
    Live streaming would give you a more intimate space with your viewers and encourage them to interact with you more often. It would allow more personal interaction with your audience in real time.
    You can also share your live videos later, so that those who have missed out the live streaming can view them again. A tour of your business, a demonstration of your products or an interview with the creators are some of the possible content which can be created with a live video.
    Make sure to make the most out of the apps which allows you to go live directly from the blog.

    SvarSlet
  19. Live streaming is the latest fad on social media so make sure to get live with your audience from time to time.
    Live streaming would give you a more intimate space with your viewers and encourage them to interact with you more often. It would allow more personal interaction with your audience in real time.
    You can also share your live videos later, so that those who have missed out the live streaming can view them again. A tour of your business, a demonstration of your products or an interview with the creators are some of the possible content which can be created with a live video.
    Make sure to make the most out of the apps which allows you to go live directly from the blog.

    SvarSlet
  20. I believe that a social media consultant must be attuned to the company goals and aspirations if he or she is to represent them on their social media channels. I also think that outsourcing social media marketing is a good idea for a company looking to specialize in their core business. In any case, most businesses outsource marketing and advertising and I don’t see why social media marketing should be any different. You just need to be actively involved to ensure that you are represented in the way that you want

    SvarSlet