I am developing an application in which I need to extract the audio from a video. The audio needs to be extracted in .wav format but I do not have a problem with the video format. Any format will do, as long as I can extract the audio in a wav file.
Currently I am using Windows Media Player COM control in a windows form to play the videos, but any other embedded player will do as well.
Any suggestions on how to do this? Thanks
One of the quickest ways to extract the audio from a video file on a Windows PC is to use the VLC Media Player. Although VLC is a free media player app, it has some secret features, including conversion options built into it as well. You can use those conversion options to convert your video file into an audio file.
Whether you need to extract an audio file from a single clip or a whole video, Adobe Premiere Pro has the tools to create audio clips from any video file including MP4, AVI, FLV, and MPEG. And using your video editor as an audio converter can streamline your workflow, as well.
If you want to do this with C#, take a look at NAudio library. It can analyze the audio format (like FFMpeg) and also provide the audio stream. Here's one example.
Snippet from the sample:
using NAudio.Wave;
using System.IO;
...
// contentAsByteArray consists of video bytes
MemoryStream contentAsMemoryStream = new MemoryStream(contentAsByteArray);
using (WaveStream pcmStream =
WaveFormatConversionStream.CreatePcmStream(
new StreamMediaFoundationReader(contentAsMemoryStream)))
{
WaveStream blockAlignReductionStream = new BlockAlignReductionStream(pcmStream);
// Do something with the wave stream
}
Here is a link on how to extract audio using GraphEdit, GraphEdit is an front end UI for the DirectShow API so everything it can do you can do with API.
You can use the DirectShow.NET liberty which wraps the DirectShow API for the managed world.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With