How to Capture a live stream from Windows Media Server 2008
Posted
by Hummad Hassan
on Stack Overflow
See other posts from Stack Overflow
or by Hummad Hassan
Published on 2010-05-22T06:16:20Z
Indexed on
2010/05/22
6:30 UTC
Read the original article
Hit count: 328
I want to capture the live stream from windows media server to filesystem on my pc I have tried with my own media server with the following code. but when i have checked the out put file i have found this in it.
FileStream fs = null;
try
{
HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://mywmsserver/test");
CookieContainer ci = new CookieContainer(1000);
req.Timeout = 60000;
req.Method = "Get";
req.KeepAlive = true;
req.MaximumAutomaticRedirections = 99;
req.UseDefaultCredentials = true;
req.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3";
req.ReadWriteTimeout = 90000000;
req.CookieContainer = ci;
//req.MediaType = "video/x-ms-asf";
req.AllowWriteStreamBuffering = true;
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
Stream resps = resp.GetResponseStream();
fs = new FileStream("d:\\dump.wmv", FileMode.Create, FileAccess.ReadWrite);
byte[] buffer = new byte[1024];
int bytesRead = 0;
while ((bytesRead = resps.Read(buffer, 0, buffer.Length)) > 0)
{
fs.Write(buffer, 0, bytesRead);
}
}
catch (Exception ex)
{
}
finally
{
if (fs != null)
fs.Close();
}
© Stack Overflow or respective owner