[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Decrypt and play video from TMemoryStream

Posted on 2011-03-25
6
Medium Priority
?
1,840 Views
Last Modified: 2012-05-11
Hello,

I have encrypted video located in http server, and i want to do with it the following.
- Download and decrypt it in MemoryStream.
- Play this video from MemoryStream.

So i won't to put the video in the hard driver, i want to download, decrypt and play it in memory.
0
Comment
Question by:Mahdi78
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 24

Expert Comment

by:jimyX
ID: 35221501
You can't download to MemoryStream. You have to assign physical destination in the local hard drive.
All the online Multimedia players download videos before playback (through buffering). Even Youtube downloads and use temp files to stream the videos.

The default path is the Temp Folder, default is:
C:\Documents and Settings\UserName\Local Settings\Temp

So you should download your video to the Temp Folder and then decrypt it and finally play it.

All the Audio/Video players require path/file location to start. Haven't seen Multimedia player that supports such streaming from Memory.
0
 
LVL 9

Author Comment

by:Mahdi78
ID: 35222729
>> You can't download to MemoryStream.

It is possible with idhttp to download to MemoryStream, like the following example

var MStrm: TMemoryStream;
begin
MStrm := TMemoryStream.Create;
  try
  IdHttp1.Get('http://localhost/video.wmv', MStrm);
  MStrm.SaveToFile('myvideo.wmv');
  Showmessage('Download finished');
  finally
  MStrm.Free;
  end;
end;

It is possible to Decrypt MemoryStream too

>> All the Audio/Video players require path/file location to start. Haven't seen Multimedia player that supports such streaming from Memory.

what about mms protocol? like this link
mms://83.221.120.201/streaming/mednetu/5455/Lez001.wmv

My idea about how to do like the following example

var MStrm1, MStrm2: TMemoryStream;
begin
MStrm1 := TMemoryStream.Create;
MStrm2 := TMemoryStream.Create;
  try
  IdHttp1.Get('http://localhost/video.wmv', MStrm1);
  MStrm2 := Decrypt(MStrm1);
  MyPlayer.Loadstream(MStrm2);
  MyPlayer.Play;
  finally
  MStrm1.Free;
  MStrm2.Free;
  end;
end;

0
 
LVL 24

Accepted Solution

by:
jimyX earned 2000 total points
ID: 35223544
I don't know much about TIdhttp, but I will investigate on how it handles that exactly (i.e. does it use local temp file or it's a direct stream loading).
Ya agree, decrypting streams is not an issue, once you have your stream fully loaded and ready, you can change it easily.

MMS is a network streaming protocol which uses data packets to be sent via network, then played on the fly. It differs than downloading multimedia content to a stream.

Ciuly has developed a component which will enable you to play multimedia contents from stream:
http://www.ciuly.com/delphi/multimedia/

http://www.experts-exchange.com/Programming/Languages/Pascal/Delphi/Q_22901002.html

Let's find out how it goes:
procedure TForm1.Button1Click(Sender: TObject);
var
  MStrm: TMemoryStream;
begin
  MStrm := TMemoryStream.Create;
  try
    IdHttp1.Get('http://MultimediaLink/test.avi', MStrm);
    Caption := 'Download finished';
    MCIStreamPlayer1.Stream := MStrm;
    MCIStreamPlayer1.open;
  finally
    MStrm.Free;
  end;
end;

Open in new window

0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 9

Author Comment

by:Mahdi78
ID: 35260895
Good links jimyX, this what i'm looking for
But unfortunately the both components don't work with Delphi 2009 and don't support wmv video,

Your code doesn't work it raise an error when MCIStreamPlayer1 get the stream, but i got the way how to load stream into MCIStreamPlayer1

You really answered to my question,  if you have or any expert has an additional comment please shoot it
0
 
LVL 24

Expert Comment

by:jimyX
ID: 35261177
>   "components don't work with Delphi 2009"
When compiling it under Delphi 2009 and you get the errors, just change all the PAnsiChar to PChar.

>   "it raise an error when MCIStreamPlayer1 get the stream"
Let me guess, you downloaded to a temp file, converted it, then loaded it to the MCIStreamPlayer1, no?
0
 
LVL 9

Author Comment

by:Mahdi78
ID: 35261512
>> When compiling it under Delphi 2009 and you get the errors, just change all the PAnsiChar to PChar.

Oops, thank you it resolved, i was so lazy, when got errors with TMCIStreamPlayer i changed all functions PAnsiChar to PChar but i forgot to change the variable from AnsiChar to Char, when i converted my components to Delphi 2009 i changed variables Char to AnsiChar and function PChar to PAnsiChar except TMCIStreamPlayer, it work by opposite way lol, i don't know why.

DSPack still unconverted to Delphi 2009.

>> Let me guess, you downloaded to a temp file, converted it, then loaded it to the MCIStreamPlayer1, no?

I downloaded an avi from local http server like this example

procedure TForm1.Button1Click(Sender: TObject);
var
  MStrm: TMemoryStream;
begin
  MStrm := TMemoryStream.Create;
  try
    IdHttp1.Get('http://localhost/video/test.avi', MStrm);
    Caption := 'Download finished';
    MCIStreamPlayer1.Stream := MStrm;
    MCIStreamPlayer1.open;
  finally
    MStrm.Free;
  end;
end;

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question