将视频中的音频作为wav提取 [英] Extract audio from video as wav

查看:173
本文介绍了将视频中的音频作为wav提取的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道有一个类似于我的问题: http://stackoverflow.com / questions / 1010937 / extract-wav-file-from-video-file

I know there is a question similar to mine: http://stackoverflow.com/questions/1010937/extract-wav-file-from-video-file

我是C ++新手,了解COM library + directX视频和音频。我一直在寻找教程和示例代码,但没有成功。

I am new to C++ and understand about COM library + directX is needed for video and audio. I been looking for tutorial and samples code but little success.

我的问题是如何编写应用程序来拍摄视频文件(任何类型),并将提取的音频作为.wav保存在我的应用程序中,而不是使用其他应用程序graphedit或virtualdub?

My question is how do I code the application to take video file (any type) and saved the extracted audio as .wav in my application rather than using other applications such as graphedit or virtualdub?

推荐答案

我将第二个动议只使用一个ffmpeg构建来执行音频提取。它可以在一个简单的命令,而不是最可能几百行代码(如果你要检查所有可能发生的问题,当处理不同的视频格式和编解码器)。

I'll second the motion to just use a build of ffmpeg to perform the audio extraction. It can be done in one easy command as opposed to most likely hundreds of lines of code (If your going to check for all of the possible problems that could happen when dealing with different video formats and codecs).

ffmpeg -i video.avi -vn soundfile.wav

你可以使用libavformat和libavformat(ffmpeg后面的库)来做同样的事情,但是除非你需要在输出到wav之前对原始音频进行一些处理,否则除了知识。

You could use libavformat and libavformat(libraries behind ffmpeg) to do the same thing, but unless you need to do some processing on the raw audio before outputting to wav, there would be nothing to gain except for knowledge.

ffmpeg很不错,因为可执行文件包含你可能需要的所有音频和视频解码器,所以解决方案是高度可移植的。你没有安装编解码器或任何东西。输入视频文件可以是ffmpeg支持的任何格式或编解码器,您不必费心在代码中对它们进行不同的处理。

ffmpeg is nice because the executable contains all of the audio and video decoders you'll probably ever need so the solution is highly portable. You don't have it install codecs or anything. The input video file can be in any format or codec that ffmpeg supports and you don't have to bother with treating them differently in your code.

从C ++可以调用ffmpeg通过在代码中构建命令行字符串并从代码中启动过程(是新的C ++,你可能需要研究如何做到这一点,但很容易)。

From C++ you can call ffmpeg by building the command line string in your code and kicking off the process from your code (being new the C++, you'll probably need to research how to do this, but it's pretty easy).

这篇关于将视频中的音频作为wav提取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆