本文章针对初学者
开始使用ffmpeg的动态库来写自己的程序,那么如何使用ffmpeg编译通过的动态库呢?
1.编译好ffmpeg(关于如何编译参考另一篇文章)
2.把ffmpeg编译安装路径下面的inlude文件夹下的文件和lib文件夹拷贝到自己的工程里面。
3.配置动态库的位置:
右键单击工程名 ->properties->Settoings->GCCLinker->Libraries
在路径上选择库的位置路径,在库的名字上面逐步添加库名。注意:如果库的名字是libavformat 那么添加库名的时候直接是 avformat不要前面lib
测试代码:
#include <stdio.h>
#include <stdlib.h>
#include "libavformat/avformat.h"
#include "libavdevice/avdevice.h"
#include "libswscale/swscale.h"
#include "libavutil/opt.h"
#include "libavutil/audioconvert.h"
#include "libavutil/parseutils.h"
#include "libavutil/samplefmt.h"
#include "libavutil/fifo.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/dict.h"
#include "libavutil/mathematics.h"
#include "libavutil/pixdesc.h"
#include "libavutil/avstring.h"
# include "libavfilter/avfilter.h"
# include "libavfilter/avfiltergraph.h"
#include <sys/types.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/select.h>
#include <time.h>
#include "libavutil/avassert.h"
int main(void) {
av_log(NULL, AV_LOG_WARNING, "*** THIS PROGRAM IS DEPRECATED ***\n"
"This program is only provided for compatibility "
"and will be removed in a future release. Please "
"use avconv instead.\n");
printf("测试成功没\n");
return EXIT_SUCCESS;
}
编译过程中可能出现错误,不管他,点击运行。
有什么疑问可以邮件 cugkuan@163.com