Ubuntu 16.04.3下FFmpeg编译与开发环境搭建测试程序

测试环境 ffmpeg 安装成功与否的例子:

  1. #include <stdio.h>
  2. #include <libavformat/avformat.h>
  3. #include <libswscale/swscale.h>
  4. #include <libavfilter/avfilter.h>
  5. #define dbmsgc(fmt, args ...) printf("cong:%s[%d]: "fmt"\n", __FUNCTION__, __LINE__,##args)
  6. //#define dbmsg(fmt, args ...) printf("cong:%s:%s[%d]: "fmt"\n",__FILE__, __FUNCTION__, __LINE__,##args)
  7. int main( int argc, char **argv)
  8. {
  9. int i= 0;
  10. AVFormatContext *pFormatCtx = NULL;
  11. avcodec_register_all();
  12. #if CONFIG_AVDEVICE
  13. avdevice_register_all();
  14. #endif
  15. avfilter_register_all();
  16. av_register_all();
  17. if(avformat_open_input(&pFormatCtx, argv[ 1], NULL, NULL)!= 0)
  18. return - 1; // Couldn't open file
  19. if(avformat_find_stream_info(pFormatCtx, NULL)< 0)
  20. return - 1; // Couldn't find stream inform
  21. av_dump_format(pFormatCtx, 0, 0, 0);
  22. return 0;
  23. }
6..编写Makefile
  1. FFMPEG =/usr/ local/ffmpeg
  2. CC =gcc
  3. CFLAGS =-g -I$(FFMPEG)/include
  4. LDFLAGS = -L$(FFMPEG)/lib / -lswscale -lswresample -lavformat -lavdevice -lavcodec -lavutil -lavfilter -lm
  5. TARGETS = test
  6. all: $(TARGETS)
  7. test:test .c
  8. $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) -std=c++11 #注意这里的-std=c++11
  9. clean:
  10. rm -rf $(TARGETS)

7.make

8../test
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值