Last post Jun 05, 2018 07:27 AM by nguyenhuyen020589
Apr 01, 2018 04:49 PM|TheLogan|LINK
Heya folks, I'm building a website in asp.net for fun and I'd like to try my hands at hosting a webcam stream on the website, but I can't really figure out how to get started.
I know that there's software like OBS (open broadcaster software) that can stream to a link, but I don't know how I would have the website accept and display that.
Pretty much all tutorials I found seemed to be geared towards the kind of streaming that youtube does (a video is hosted on the server and is streamed to the user), but I assume that for a live stream this would be a different setup?
Can anyone point me in the right direction?
Apr 02, 2018 08:07 AM|VitaliyMF|LINK
You can use ffmpeg for this purpose: it can use your web cam as input (even if this is local web cam that is accessible as DirectShow device), and stream it to streaming server - this can be youtube or your local ffserver.
Or, if you're only website visitor that can see your webcam, you can transcode webcam stream to HTML5 video format on-the-fly (in this case live streaming server is not needed).
In C# FFMpeg can be executed with System.Diagnostics.Process, or you can use
existing .NET wrapper.
Apr 02, 2018 08:45 AM|Deepak Panchal|LINK
I try to find some example codes suitable for your requirement may help you to solve your issue.
public class VideoStream
private readonly string _filename;
public VideoStream(string filename, string ext)
_filename = @"C:UsersFilipDownloads" + filename + "."+ext;
public async void WriteToStream(Stream outputStream, HttpContent content, TransportContext context)
var buffer = new byte;
using (var video = File.Open(_filename, FileMode.Open, FileAccess.Read))
var length = (int)video.Length;
var bytesRead = 1;
while (length > 0 && bytesRead > 0)
bytesRead = video.Read(buffer, 0, Math.Min(length, buffer.Length));
await outputStream.WriteAsync(buffer, 0, bytesRead);
length -= bytesRead;
catch (HttpException ex)
public class VideosController : ApiController
public HttpResponseMessage Get(string filename, string ext)
var video = new VideoStream(filename, ext);
var response = Request.CreateResponse();
response.Content = new PushStreamContent(video.WriteToStream, new MediaTypeHeaderValue("video/"+ext));
Asynchronously streaming video with ASP.NET Web API
Asynchronous Video Live Streaming with ASP.NET Web APIs 2.0
Jun 05, 2018 07:27 AM|nguyenhuyen020589|LINK
Thanks for the help