zoukankan      html  css  js  c++  java
  • 基于ffmpeg静态库的应用开发

    最近几天在试着做基本ffmpeg静态库的开发,只有main中包含了avdevice_register_all 或avfilter_register_all,编译就通不过,undefined refrence ,静态库的链接次序一直搞不定。

    后尝试了pkg-config命令,首先配置PKG_CONFIG_PATH环境变量

    pkg-config --libs libavdevice

    -pthread -L/usr/local/test_ffmpeg/lib -lavdevice -lavfilter -lpostproc -lswresample -lswscale -lavformat -lavcodec -ldl -lasound -lx264 -lfaac -lz -lrt -lavutil -lm  

    根据这个次序,调整编译shell,则成功编译。

    arm-linux-gnueabihf-gcc device.c -o device
    -I/usr/local/test_ffmpeg/include -I/usr/local/faac/include -I/usr/local/include
    -L/usr/local/test_ffmpeg/lib -L/usr/local/faac/lib -L/usr/local/lib
    -lavdevice -lavfilter -lpostproc -lswresample -lswscale -lavformat -lavcodec -lavutil -ldl -lasound -lx264 -lfaac -pthread -lz -lrt -lm

    或使用下面的Makefile文件编译(从ffmpeg1.1.16/doc/example中拷贝,已修改并测试通过

    CC = arm-linux-gnueabihf-gcc
    # use pkg-config for getting CFLAGS and LDLIBS
    FFMPEG_LIBS= libavdevice
    libavformat
    libavfilter
    libavcodec
    libswresample
    libswscale
    libavutil

    CFLAGS += -Wall -O2 -g
    LDLIBS += -L/usr/local/faac/lib -L/usr/local/lib   ##这句为增加的语句
    CFLAGS := $(shell pkg-config --cflags $(FFMPEG_LIBS)) $(CFLAGS)
    LDLIBS := $(shell pkg-config --libs $(FFMPEG_LIBS)) $(LDLIBS)

    EXAMPLES= decoding_encoding
    demuxing
    filtering_video
    filtering_audio
    metadata
    muxing
    resampling_audio
    scaling_video

    OBJS=$(addsuffix .o,$(EXAMPLES))

    # the following examples make explicit use of the math library
    decoding_encoding: LDLIBS += -lm
    muxing: LDLIBS += -lm

    .phony: all clean-test clean

    all: $(OBJS) $(EXAMPLES)

    clean-test:
    $(RM) test*.pgm test.h264 test.mp2 test.sw test.mpg

    clean: clean-test
    $(RM) $(EXAMPLES) $(OBJS)

  • 相关阅读:
    java的概述 常量 变量
    css 基础2
    css 盒子模型1
    css 基础1
    HTML 基础 3
    HTML基础2
    servletContext百科
    hibernate 一对多双向关联 详解
    hibernate generator class="" id详解
    Hibernate缓存原理与策略
  • 原文地址:https://www.cnblogs.com/xihong2014/p/6699225.html
Copyright © 2011-2022 走看看