Click here to Skip to main content
15,896,606 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Aoa...Actually i m developing an application where i need to extact audio from video and this application based on speech recognition so initally in this project i use MSAPI ..now i want to extract audio with the same API ..i dont want to use any other API like DirectShow or MediaFoundation or ffmpeg etc which may lead project to be dependant..now after a time i have code using MSAPI that is written to extract audio from video but in a specific domain only from .wmv while i want to extract audio from all formats like .avi .mp4 etc and after extracting store that audio in mp3 or wave format..plz guide me and make possible changes which may work for me according to my need...Indeed i always got clear and helpful guide on this forum..kindly help me...

code i have:
using System;
using System.IO;
using Yeti.MMedia;
using Yeti.WMFSdk;
using WaveLib;
...
using (WmaStream str = new WmaStream("Somefile.wma"))
{
byte[] buffer = new byte[str.SampleSize*2];
AudioWriter writer = new WaveWriter(new FileStream("Somefile.wav",
FileMode.Create),
str.Format);
try
{
int read;
while ( (read = str.Read(buffer, 0, buffer.Length)) > 0)
{
writer.Write(buffer, 0, read);
}
}
finally
{
writer.Close();
}
} //str.Close() is automatically called by Dispose.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900