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.
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.
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
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 ;)
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.
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.
neurobion wrote:
The Async File Source filter opens and reads only local files of many different data formats.
Geraint was refering to the Async "mem" source sample.
\WindowsVistaSDK\Samples\Multimedia\DirectShow\Filters\Async(\MemFile)
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 ?
thank you.
Yes, that one will do it. If you already have an older Platform SDK installed you can find it there as well.
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:
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
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.
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