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.
我正在开发一个应用程序,我需要从视频中提取音频。音频需要以.wav格式提取,但我对视频格式没有问题。任何格式都可以,只要我可以在wav文件中提取音频。
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.
目前我在Windows窗体中使用Windows Media Player COM控件来播放视频,但任何其他嵌入式播放器也可以。
Any suggestions on how to do this? Thanks
有关如何做到这一点的任何建议?谢谢
3 个解决方案
#1
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.
以下是有关如何使用GraphEdit提取音频的链接,GraphEdit是DirectShow API的前端UI,因此您可以使用API执行所有操作。您可以使用DirectShow.NET*包装DirectShow API用于托管世界。
#2
Probably easiest to use ffmpeg for this kinda thing...
可能最容易使用ffmpeg来做这件事......
#3
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.
如果您想使用C#执行此操作,请查看NAudio库。它可以分析音频格式(如FFMpeg)并提供音频流。这是一个例子。
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
}
#1
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.
以下是有关如何使用GraphEdit提取音频的链接,GraphEdit是DirectShow API的前端UI,因此您可以使用API执行所有操作。您可以使用DirectShow.NET*包装DirectShow API用于托管世界。
#2
Probably easiest to use ffmpeg for this kinda thing...
可能最容易使用ffmpeg来做这件事......
#3
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.
如果您想使用C#执行此操作,请查看NAudio库。它可以分析音频格式(如FFMpeg)并提供音频流。这是一个例子。
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
}