question

jtorjo avatar image
0 Votes"
jtorjo asked jtorjo commented

is there a way to force loading a StorageFile in memory?

I have a StorageFile that I want to use as input for a Media Composition (as a Media Clip).

I'm hoping loading everything in memory, to speed things up. I don't know how to do this - is there any way to do it?

windows-uwp
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

RichardZhang-MSFT avatar image
0 Votes"
RichardZhang-MSFT answered jtorjo commented

Hello,​

Welcome to our Microsoft Q&A platform!

The MediaClip.CreateFromFileAsync method accepts a parameter type of IStorageFile, which means you need to pass in a variable of type StorageFile.

Although we can use a MemoryStream to save a file stream in memory, MediaClip doesn't have a method of CreateFromStreamAsync, so in your case you can only load data from the file.



If you are establishing a connection between MediaClip and Stream, you can use StorageFile.ReplaceWithStreamedFileAsync as a relay.

You can first read the StorageFile as a Stream, then use this method to convert the Stream to a StorageFile when needed, and pass it to MediaClip.

However, it should be noted that loading the file into memory has no effect on the speed of MediaComposition.

Thanks.

· 5
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

So, I am well aware of the above. And basically what you're saying is: it's not possible. Yes?

0 Votes 0 ·

Hi, I update my answer, please check. And I mentioned that you need to increase the loading speed, but reading the file into memory does not affect the speed of MediaComposition. What is the reason you want to do this?

0 Votes 0 ·
jtorjo avatar image jtorjo RichardZhang-MSFT ·

Hi Richard,

I wanted to speed the processing of the MediaComposition - but if it's not doing that, then I'll need to do something else.

Long story short, I've been suggested to use MediaOverlays and create an IVideoCompositor to speed things up - it will take some work on my part, but we'll see

Regarding StorageFile.ReplaceWithStreamedFileAsync - it may actually do what i was initially asking, even if the docs are really vague about it.

Best,
John

0 Votes 0 ·
Show more comments
macintoshpro avatar image
0 Votes"
macintoshpro answered jtorjo commented

Of couse, you can read StorageFile as a stream (stream is in memory)

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks, I am aware of that. But my issue is this:

 MediaClip clip = await MediaClip.CreateFromFileAsync(await StorageFile.GetFileFromPathAsync(src_file_name_));


So, basically, I have a StorageFile which I pass to MediaClip.CreateFromFileAsync - how do I know the file is already in memory?

0 Votes 0 ·