作者热门文章
- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我正在开发一个使用 ffmpeg 播放音频/视频的 c/c++ 应用程序。现在我想增强应用程序以允许用户从视频中提取音频并保存。我跟着这个https://ffmpeg.org/doxygen/trunk/muxing_8c-source.html对于保存部分,但现在问题出在 avformat_alloc_output_context2() 上。我收到一个错误:“对 `avformat_alloc_output_context2' 的 undefined reference “。有谁知道在 ffmpeg 版本 2.6.3 中调用 'avformat_alloc_output_context2' 的正确方法
最佳答案
记得包含
extern "C"
{
#include "libavformat/avformat.h"
}
之后你就可以调用
* @param *ctx is set to the created format context, or to NULL in
* case of failure
* @param oformat format to use for allocating the context, if NULL
* format_name and filename are used instead
* @param format_name the name of output format to use for allocating the
* context, if NULL filename is used instead
* @param filename the name of the filename to use for allocating the
* context, may be NULL
* @return >= 0 in case of success, a negative AVERROR code in case of
* failure
*/
int avformat_alloc_output_context2(AVFormatContext **ctx, AVOutputFormat *oformat, const char *format_name, const char *filename);
例如:
static const char* output_formats[] = { NULL, "mp3", "ogg", "wav" };
AVFormatContext* formatCtx = NULL;
QString outputFileName = "insert here your output file name";
avformat_alloc_output_context2(&formatCtx, NULL, output_formats[1], outputFileName.toStdString().c_str());
if(formatCtx == NULL)
{
//allocation have failed
}
关于c++ - 如何在 ffmpeg 2.6.3 中调用 avformat_alloc_output_context2?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30784796/
我是一名优秀的程序员,十分优秀!