ffmpeg编译及使用

sd卡有关拔插等方面的工作已经完成,接下来要实现对sd卡的录像工作。之前公司的代码中有相关的代码,是用ffmpeg做的。昨天问同事要了个ffmpeg的源码,是2.2.4版本的,交叉编译完用到我们的程序中不行。因为我们之前用的ffmpeg的版本太早,很多东西已经不一样了,本来还想着改一下的,后来发现不一样的地方越改越多,只能问要了我们用的那个版本(差不多附近)的ffmpeg,交叉编译后加入到我们的程序中,编译成功。
编译命令:(版本大概是0.5版本的)
1.    ./configure --prefix=./ffmpeg_release --enable-pthreads --arch=arm --cc=arm-hisiv100nptl-linux-gcc --cross_prefix=arm-hisiv100nptl-linux- --enable-cross-compile --disable-decoders --disable-encoders --disable-muxers --disable-demuxers --disable-parsers --disable-protocols --disable-bsfs --disable-devices --disable-filters --disable-network --disable-ipv6 --disable-mpegaudio-hp --disable-debug --enable-muxer=avi --enable-protocol=file 
如果提示bash: ./configure: Permission denied,需要给configure增加可执行权限。
2.make;make install


遇到的问题:
把库链接到程序后发现库中很多函数都找不到,如下:
/Samba/EsongIPC/trunk/src/ipcamera/libs/ffmpeg/libavformat.a(allformats.o): In function `av_register_all':
allformats.c:(.text+0x1c): undefined reference to `avcodec_register_all'
/Samba/EsongIPC/trunk/src/ipcamera/libs/ffmpeg/libavformat.a(options.o): In function `avformat_alloc_context':
options.c:(.text+0x54): undefined reference to `av_opt_set_defaults'
/Samba/EsongIPC/trunk/src/ipcamera/libs/ffmpeg/libavformat.a(options.o): In function `av_alloc_format_context':
options.c:(.text+0x98): undefined reference to `av_opt_set_defaults'
/Samba/EsongIPC/trunk/src/ipcamera/libs/ffmpeg/libavformat.a(utils.o): In function `parse_frame_rate':
utils.c:(.text+0x1b60): undefined reference to `av_parse_video_frame_rate'
/Samba/EsongIPC/trunk/src/ipcamera/libs/ffmpeg/libavformat.a(utils.o): In function `parse_image_size':
utils.c:(.text+0x1b78): undefined reference to `av_parse_video_frame_size'
/Samba/EsongIPC/trunk/src/ipcamera/libs/ffmpeg/libavformat.a(utils.o): In function `dump_stream_format':
utils.c:(.text+0x1f68): undefined reference to `avcodec_string'
/Samba/EsongIPC/trunk/src/ipcamera/libs/ffmpeg/libavformat.a(utils.o): In function `av_new_stream':
utils.c:(.text+0x2b0c): undefined reference to `avcodec_alloc_context'
/Samba/EsongIPC/trunk/src/ipcamera/libs/ffmpeg/libavformat.a(utils.o): In function `av_add_index_entry':
utils.c:(.text+0x3a88): undefined reference to `av_fast_realloc'
/Samba/EsongIPC/trunk/src/ipcamera/libs/ffmpeg/libavformat.a(utils.o): In function `av_write_header':
utils.c:(.text+0x40f0): undefined reference to `av_get_bits_per_sample'
/Samba/EsongIPC/trunk/src/ipcamera/libs/ffmpeg/libavformat.a(utils.o): In function `av_read_frame_flush':
utils.c:(.text+0x4ce8): undefined reference to `av_parser_close'
/Samba/EsongIPC/trunk/src/ipcamera/libs/ffmpeg/libavformat.a(utils.o): In function `av_close_input_stream':
utils.c:(.text+0x4d70): undefined reference to `av_parser_close'
/Samba/EsongIPC/trunk/src/ipcamera/libs/ffmpeg/libavformat.a(utils.o): In function `compute_pkt_fields':
utils.c:(.text+0x7268): undefined reference to `av_get_bits_per_sample'
/Samba/EsongIPC/trunk/src/ipcamera/libs/ffmpeg/libavformat.a(utils.o): In function `av_read_frame_internal':
utils.c:(.text+0x75a8): undefined reference to `av_parser_init'
utils.c:(.text+0x7624): undefined reference to `av_parser_parse'
utils.c:(.text+0x7880): undefined reference to `av_parser_parse'
/Samba/EsongIPC/trunk/src/ipcamera/libs/ffmpeg/libavformat.a(utils.o): In function `av_find_stream_info':
utils.c:(.text+0x8138): undefined reference to `av_parser_init'
utils.c:(.text+0x871c): undefined reference to `avcodec_close'
utils.c:(.text+0x8838): undefined reference to `av_get_bits_per_sample'
utils.c:(.text+0x8a30): undefined reference to `avcodec_decode_video'
utils.c:(.text+0x8ad0): undefined reference to `avcodec_decode_audio2'
utils.c:(.text+0x9040): undefined reference to `avcodec_pix_fmt_to_codec_tag'
utils.c:(.text+0x9418): undefined reference to `av_parser_close'
utils.c:(.text+0xa3c8): undefined reference to `avcodec_string'
utils.c:(.text+0xa880): undefined reference to `avcodec_find_decoder'
utils.c:(.text+0xa890): undefined reference to `avcodec_open'
/Samba/EsongIPC/trunk/src/ipcamera/libs/ffmpeg/libavformat.a(utils.o): In function `compute_pkt_fields2':
utils.c:(.text+0xb334): undefined reference to `av_get_bits_per_sample'
utils.c:(.text+0xb390): undefined reference to `av_get_bits_per_sample'
/Samba/EsongIPC/trunk/src/ipcamera/libs/ffmpeg/libavformat.a(riff.o): In function `put_wav_header':
riff.c:(.text+0x238): undefined reference to `av_get_bits_per_sample'
collect2: ld returned 1 exit status
make: *** [ipcamera] Error 1


以前就遇到过这种需要同时链接多个库结果找不到函数定义的问题,这是因为库之间存在依赖关系,所以就对库的加载顺序有要求了,因为我之前在Makefile中用wildcard来寻找库的,所以库的加载顺序就是按字母顺序来进行的了,解决方法,手动指定库加载的顺序,如下:
FFMPEG_LIB := $(MAKEDIR)/libs/ffmpeg/libavformat.a \
      $(MAKEDIR)/libs/ffmpeg/libavdevice.a \
      $(MAKEDIR)/libs/ffmpeg/libavcodec.a \
      $(MAKEDIR)/libs/ffmpeg/libavutil.a 
问题解决。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值