MP3 in memorystream

Hi all,

is any possibilityhow to play mp3 from memorystreamor other forms of streams?

Or how decode mp3 file to wav with any external dll (no *.exe!) with api wraps.

I appreciate, if you could solve this problem out, and help me or tell me how i can do this, thank you
[527 byte] By [neurobion] at [2007-12-30]
# 1

the Async sample in the filters folder of the SDK includes a DirectShow source filter that will deliver data from a memory buffer. If you use this and render the output, you should be able to play MP3 and any other DirectShow supported format from a memory buffer.

G

GeraintDavies at 2007-9-5 > top of Msdn Tech,Software Development for Windows Vista,DirectShow Development...
# 2
Geraint Davies wrote:

the Async sample in the filters folder of the SDK includes a DirectShow source filter that will deliver data from a memory buffer. If you use this and render the output, you should be able to play MP3 and any other DirectShow supported format from a memory buffer.

G

The Async File Source filter opens and reads only local files of many different data formats.

http://msdn2.microsoft.com/en-us/library/ms783348.aspx

i dont find some filter work with stream format (maybe am looking for badly ;p). Can explain me please your idea?

Sorry for me english ;)

neurobion at 2007-9-5 > top of Msdn Tech,Software Development for Windows Vista,DirectShow Development...
# 3

why don't you try to create your own source filter? (try extending the CSource that implements IBaseFilter class and create just one output pin extending CSourceStream that implements IPin).

Create a graph using your source filter as the data entry and use any additional filter to process your data (perhaps MP3 decoder and an audio renderer), run the graph, obtain your MP3 file from anywhere (from disk, http stream, your own audio streamer etc) and pass bunches of data down stream to be processed.

HaroldJimenez at 2007-9-5 > top of Msdn Tech,Software Development for Windows Vista,DirectShow Development...
# 4

That works for raw stream formats like mp3 but won't work with non-linear streams like AVI, WAV. For those there much be a parser, which you could implement yourself in the source or implement the source as an Async source like in the sample. The Async mem source is very simple and works with the stock parsers.

ChrisP. at 2007-9-5 > top of Msdn Tech,Software Development for Windows Vista,DirectShow Development...
# 5
neurobion wrote:

The Async File Source filter opens and reads only local files of many different data formats.

http://msdn2.microsoft.com/en-us/library/ms783348.aspx

Geraint was refering to the Async "mem" source sample.

\WindowsVistaSDK\Samples\Multimedia\DirectShow\Filters\Async(\MemFile)

ChrisP. at 2007-9-5 > top of Msdn Tech,Software Development for Windows Vista,DirectShow Development...
# 6
Chris P. wrote:

Geraint was refering to the Async "mem" source sample.

\WindowsVistaSDK\Samples\Multimedia\DirectShow\Filters\Async(\MemFile)

i must download this or something else ?

http://www.microsoft.com/downloads/details.aspx?familyid=c2b1e300-f358-4523-b479-f53d234cdccf&displaylang=en

thank you.

neurobion at 2007-9-5 > top of Msdn Tech,Software Development for Windows Vista,DirectShow Development...
# 7

Yes, that one will do it. If you already have an older Platform SDK installed you can find it there as well.

ChrisP. at 2007-9-5 > top of Msdn Tech,Software Development for Windows Vista,DirectShow Development...
# 8

so this is the case Chris!!

If you take a look at the neurobion's original question, he/she needs to decode an MP3 file from memory to a .wav file. He/She can achieve this by using filter graphs. He/She can burn the entire graph into a dll and call a single function that receives the memory stream (the .MP3 file) and passes it to his/her custom source filter (by querying a custom interface implemented by the coclass or the CSource extender in the source filter). The graph should have the following down stream filters connected:

  1. Custom Source Filter (reads an MP3 from memory)
  2. An MPEG-I Stream Splitter
  3. An MP3 Decoder (MPEG Layer-3 Decoder)
  4. A WMA or PCM Encoder depending on what format neurobion wants to store the converted stream
  5. A Wave Dest filter (that does nothing, just provides compatibility for wav pins)
  6. And a File Writer to store the converted stream

Neurobion needs to provide the appropriate MEDIATYPE, SUBTYPE and FORMAT (this is the harder part but he/she can use the MPEGLAYER3WAVEFORMAT structure) from his/her source filter's output pin to allow connection with the next filter's input pin.

Sample code that fills the MPEGLAYER3WAVEFORMAT structure

MPEGLAYER3WAVEFORMAT.wfx.wFormatTag
= WAVE_FORMAT_MPEGLAYER3;
MPEGLAYER3WAVEFORMAT.wfx.nChannels
= mode == 3 ? 1 : 2;
MPEGLAYER3WAVEFORMAT.wfx.nSamplesPerSec
= ...; /// from sampling_freq and version
MPEGLAYER3WAVEFORMAT.wfx.nAvgBytesPerSec
= ...; /// from bitrate_index, version and layer, then
divide by 8
MPEGLAYER3WAVEFORMAT.wfx.nBlockAlign
= 1;
MPEGLAYER3WAVEFORMAT.wfx.wBitsPerSample
= 0;
MPEGLAYER3WAVEFORMAT.wfx.cbSize
= MPEGLAYER3_WFX_EXTRA_BYTES;
MPEGLAYER3WAVEFORMAT.wID
= MPEGLAYER3_ID_MPEG;
MPEGLAYER3WAVEFORMAT.fdwFlags
= MPEGLAYER3_FLAG_PADDING_OFF;
MPEGLAYER3WAVEFORMAT.nBlockSize
= ...; /// the frame size
MPEGLAYER3WAVEFORMAT.nFramesPerBlock
= 1;
MPEGLAYER3WAVEFORMAT.nCodecDelay
= 1393;

Notice that the first member of this structure is of type WAVEFORMATEX. This member holds the basic info required to define the wave format. The MPEGLAYER3WAVEFORMAT acts exactly as a WAVEFORMATEX structure with variable size where additional fields are required. This information can be used by non-PCM formats to store extra attributes for the wFormatTag.

Hope this helps

HaroldJimenez at 2007-9-5 > top of Msdn Tech,Software Development for Windows Vista,DirectShow Development...
# 9
Harold Jimenez wrote:

Neurobion needs to provide the appropriate MEDIATYPE, SUBTYPE and FORMAT (this is the harder part but he/she can use the MPEGLAYER3WAVEFORMAT structure) from his/her source filter's output pin to allow connection with the next filter's input pin.

Not entirely true. If he uses the Async Mem source filter sample as suggested then the media type is supplied by the MPEG-1 parser. He simply has to load that filter into the graph first, initialize it appropriately and render it's output pin. Done and done.

If he wrote a custom push source with a MPEGLAYER3WAVEFORMAT as you are suggesting, then a MPEG-1 parser would not be required at all. But this is more work than above.

ChrisP. at 2007-9-5 > top of Msdn Tech,Software Development for Windows Vista,DirectShow Development...
# 10
Hi,

I'd like to do nearly the same thing as Neurobion with a mp2 stream.
Your proposal aims to Windows Vista, did I get that right?

Is it possible with older Windows versions, too?

regards

GerhardMueller at 2007-9-5 > top of Msdn Tech,Software Development for Windows Vista,DirectShow Development...

Software Development for Windows Vista

Site Classified