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

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

  1. #include
  2. #include
  3. #include
  4. #include
  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

你可能感兴趣的:(开发中遇到的问题)