2014-01-23 139 views
0

我正在asp.net c#中工作。我想从内存流中播放视频。我正在加密和解密视频。我将解密的视频存储在内存流中,并且想要播放它,而不保存。我搜索了它并发现了帖子的数量,但大多数帖子都是未完成的或者提供了与directshow的链接。我也尝试过使用directshow,但这对我来说是全新的,并且包含大量演示,这使得混淆内存流使用哪一个。从内存流播放视频

我只是想从内存流中播放解密的视频数据。请让我知道我能做什么,如果有来自任何论坛的样品,它会更好。

我的解密代码

public bool DecryptData(String inName, String outName, byte[] rijnKey, byte[] rijnIV) 
{ 
    FileStream fin = null; 
    FileStream fout = null; 
    CryptoStream decStream = null; 

    try 
    { 
      fin = new FileStream(inName, FileMode.Open, FileAccess.Read); 

      //Create variables to help with read and write. 

      byte[] bin = new byte[bufLen]; //This is intermediate storage for the encryption. 
      long rdlen = 0; //This is the total number of bytes written. 
      long totlen = fin.Length; //This is the total length of the input file. 
      int len; //This is the number of bytes to be written at a time. 
      RijndaelManaged rijn = new RijndaelManaged(); 

      //DES ds = new DESCryptoServiceProvider(); 

      decStream = new CryptoStream(fin, rijn.CreateDecryptor(rijnKey, rijnIV), CryptoStreamMode.Read); 


      //odkoduj testowy fragment 

      byte[] test = new byte[testHeader.Length]; 
      decStream.Read(test, 0, testHeader.Length); 
      string contents = new StreamReader(decStream).ReadToEnd(); 
      byte[] unicodes = Encoding.Unicode.GetBytes(contents); 
      MemoryStream msOutput = new MemoryStream(unicodes); 
//here I have to implement player that plays from memory stream. 
} 
catch 
{} 
} 
+0

您需要反正:) – Aby

+0

我不知道,利用DirectShow,如何使用它?我已经下载它,并研究它的形式。但没有得到想法,使用哪个例子,以及如何在我的解密代码如上所示。你能指导我吗? – user3119503

回答

0

今天做到这一点,最好的办法是,对于任何平台的作品...是使用HTTP实时流,然后你可以使用支持HLS或者您可以将播放器只需使用HTML5视频标签。请参阅下面我更新的答案...

Play a video without a file on disk [Java]

+0

为什么Java代码在提问者在C#中提问时。 –