question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add an option to create a new MediaFoundationReader from stream

See original GitHub issue

I’m using your amazing library in UWP and I would love if the new MediaFoundationReader() constructor would accept also preferably a stream (or bytes or buffer) instead of a file path only, in this way I’ll be able to use it directly with no need to copy the file to an app folder or ask for a broader filesystem permission, hopefully it’s possible.

Thanks

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7

github_iconTop GitHub Comments

2reactions
wtywtykkcommented, Aug 5, 2020

Not until I searched the reference of MFCreateMFByteStreamOnStreamEx did I realize there’s already something called StreamMediaFoundationReader… So it’s just unnecessary to write our own wrappers…

1reaction
wtywtykkcommented, Aug 4, 2020

In MediaFoundationReader.cs the original CreateReader function uses MFCreateSourceReaderFromURL to read files. And MFCreateSourceReaderFromByteStream is the stream version. Here’s the code I used:

System.Runtime.InteropServices.ComTypes.IStream managedStream=new WaveStreams.ManagedIStream(stream);
IMFByteStream byteStream;
MediaFoundationInterop.MFCreateMFByteStreamOnStream(managedStream, out byteStream);
MediaFoundationInterop.MFCreateSourceReaderFromByteStream(byteStream, null, out reader);
Marshal.ReleaseComObject(byteStream);

I don’t know how to calculate the BPM. But maybe you can check this out https://github.com/stengerh/foo_bpm

Read more comments on GitHub >

github_iconTop Results From Across the Web

NAudio proper way to stream MediaFoundationReader
I've tried to see if there was any way to determine if there was data enough in the buffer and avoid reading the...
Read more >
Mediafoundationreader stream file by url with naudio ...
successfully stream file from URL but now i want calculate total time of file just like in media player . and when the...
Read more >
Sound Code: 2012
MediaFoundationReader this implements WaveStream and basically allows you to play anything that Media Foundation can play. This means MP3, AAC, ...
Read more >
How to Encode MP3s with NAudio MediaFoundationEncoder
The first step is to make sure Media Foundation is initialised. This requires a call to MediaFoundation.Startup() . You only need to do...
Read more >
Create WAV stream in memory [16503] - NAudio
using (MediaFoundationReader reader = new MediaFoundationReader(audioFileURL)) ... where I create stream with WAV header and then add the data to the stream ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found