播放内存流中的视频 [英] Playing video from a memory stream

查看:141
本文介绍了播放内存流中的视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨所有

我收到了这样的视频文件



hi all
I got a video file like this

FileStream streamWriter = File.Create(fullPath);
                    int size = 2048;
                    byte[] data = new byte[2048];
                    while (true)
                    {
                        size = s.Read(data, 0, data.Length);
                        if (size > 0)
                        {
                            streamWriter.Write(data, 0, size);
                        }
                        else
                        {
                            break;
                        }
                    }
                    streamWriter.Close();



这里我需要做的是我想从内存流播放视频(axwindowsmediaplayer)

请任何人帮忙我

很多人都会遇到这个问题可以请任何人帮助我

提前谢谢



[已编辑]代码包含在pre标签中[/已编辑]

推荐答案



我我不确定你是否可以使用axwindowsmediaplayer从内存流播放视频以及为什么你应该首先将文件读入内存然后播放?

只需使用此处描述的URL属性:

http://msdn.microsoft.com/en-us/library /dd562470%28v=vs.85%29.aspx [ ^ ]



但是如果你因某些原因需要从内存中播放视频那么我认为你东东d使用DirectShow。



对于DirectShow我也在研究这个问题......我在DirectShowNet论坛上找到了以下老话题:

http://sourceforge.net/projects/directshownet/forums/forum/460697/topic/ 1777460 [ ^ ]



可能GSSF过滤器应该有助于解决这个问题。它可以与DirectShowNet的样本一起下载:

http:// sourceforge。 net / projects / directshownet / files / DirectShowSamples / 2010-February / [ ^ ]

样品\ Misc \ GSSF



我希望这会有所帮助。



-

Timur
Hi,
I'm not sure you can play video from memory stream using axwindowsmediaplayer and why you should read file to memory at first and then play it?
Just use URL property described here:
http://msdn.microsoft.com/en-us/library/dd562470%28v=vs.85%29.aspx[^]

But if you need to play video from memory for some reason then I think you need to use DirectShow.

For DirectShow I'm researching this problem too...I found the following old topic on DirectShowNet forum:
http://sourceforge.net/projects/directshownet/forums/forum/460697/topic/1777460[^]

Probably GSSF filter should help to solve this. It can be downloaded with samples of DirectShowNet:
http://sourceforge.net/projects/directshownet/files/DirectShowSamples/2010-February/[^]
Samples\Misc\GSSF

I hope this will help.

--
Timur


你好伙伴,

不可能是我最讨厌的东西

所以有一个丑陋的解决方案,但实际上有效:

通过TCP流媒体文件流并在此后通过嵌入式播放器接收

Hi mate,
Impossible is what I hate most
So there a bit ugly solution but works actually, which goes:
stream the media file stream by TCP and receiving it after this by your embedded player
/* a listener function, when a client connects, it starts streaming the obj stream.
the parameter is of type object here, so I can call this function as a delegate when starting the thread. */

        void HTTPStreamer(object obj)
        {
            Thread.Sleep(1000);
            Stream Reciever = (Stream)obj;
            TcpListener listener = new TcpListener(IPAddress.Loopback, 12);
            listener.Start();
            TcpClient client = listener.AcceptTcpClient();
            client.Client.Send(Encoding.Default.GetBytes("HTTP/1.1 200 OK\nDate: Tue, 02 Aug 2011 22:24:05 GMT\nServer: Apache/2.2.8 (Win32) PHP/5.2.5\nLast-Modified: Tue, 02 Aug 2011 22:21:13 GMT\nETag: \"1000000009896-1743f-4a98d2a63ee22\"\nAccept-Ranges: bytes\nContent-Length: 95295\nKeep-Alive: timeout=5, max=100\nConnection: Keep-Alive\nContent-Type: text/plain"));// HTTP Headers
            int length = 0;
            byte[] buffer = new byte[1024];

            while (Reciever.CanRead)
            {
                try
                {
                    length = Reciever.Read(buffer, 0, 1024);
                    client.GetStream().Write(buffer, 0, length);
                }
                catch
                {
                    break;
                }
            }

        }
MemoryStream YourStream
Thread th = new Thread(HTTPListener);
th.start(YourStream);

<pre>





我在这个可爱的网站上的第一个解决方案,抱歉错误

干杯



My first solution in this lovely site, sorry for the mistakes
Cheers


这篇关于播放内存流中的视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆