Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extract wav file from video file

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

like image 797
Nikos Steiakakis Avatar asked Jun 18 '09 05:06

Nikos Steiakakis


People also ask

Can you extract an audio file from a video?

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.

Can you extract audio from MP4?

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.


2 Answers

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
}
like image 56
Tomi Paananen Avatar answered Oct 20 '22 00:10

Tomi Paananen


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.

like image 38
Shay Erlichmen Avatar answered Oct 20 '22 00:10

Shay Erlichmen