IMFSourceReader - Decode and Re-sample audio in C# -
i looking decode , re-sample audio file using imfsourcereader in c#.
for example:
i want decode (mp3 wav) , re-sample bit rate (64kbps 192kbps) of following audio file -
myaudiofile - 48khz - 64kbps.mp3
to -
myaudiofile - 48khz - 192kbps.wav
i trying decode mp3 wav specifying partial media settings in code below, not re-sampling decoded wav file:
var filestream = ((mediafoundationreaderrtsettings) settings).stream; var bytestream = mediafoundationapi.createbytestream(filestream); var reader = mediafoundationapi.createsourcereaderfrombytestream(bytestream); reader.setstreamselection( mediafoundationinterop.mf_source_reader_all_streams, false); reader.setstreamselection( mediafoundationinterop.mf_source_reader_first_audio_stream, true); //create partial media type indicating want uncompressed pcm audio var partialmediatype = new mediatype(); partialmediatype.majortype = mediatypes.mfmediatype_audio; partialmediatype.subtype = settings.requestfloatoutput ? audiosubtypes.mfaudioformat_float : audiosubtypes.mfaudioformat_pcm; partialmediatype.samplerate = 48000; partialmediatype.bitspersample = 16; partialmediatype.channelcount = 2; // set media type // can return mf_e_invalidmediatype if not supported reader.setcurrentmediatype( mediafoundationinterop.mf_source_reader_first_audio_stream, intptr.zero, partialmediatype.mediafoundationobject); return reader;
appreciate on how go example. thanks!
Comments
Post a Comment