如何从 Windows Media Server 2008 捕获实时流

发布于 2024-09-02 04:14:33 字数 1162 浏览 4 评论 0原文

我想将 Windows Media Server 的实时流捕获到我的电脑上的文件系统 我已尝试使用以下代码使用我自己的媒体服务器。但是当我检查过 输出文件我在其中找到了这个。

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();
}

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();
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

仄言 2024-09-09 04:14:33

我不确定这里是否有问题...但是...这段代码非常方便!

我一直在寻找一种方法来从 WiFi 网络摄像头捕获 ASF 视频流以用于家庭安全应用程序......而这做到了。

您在 C# 代码的开头需要这些...然后编译并运行。

使用 System.IO;
使用 System.Web;
使用System.Net;

感谢您的帖子!

I'm not sure if there is a question here...but... this code is very handy!!

I've been looking for a way to capture the ASF video stream from a WiFi webcam for a home security application... and this does it.

You need these at the start of your C# code.. then compile and run.

using System.IO;
using System.Web;
using System.Net;

Thanks for the post!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文