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—连连看-实现封装
    java—连连看GUI
    连连看--产生随机数
    勇者斗恶龙
    在ctex环境下利用Metapost作图
    [leetcode] Binary Tree Postorder Traversal
    [leetcode] Binary Tree Maximum Path Sum
    [leetcode] Binary Tree Level Order Traversal II
    [leetcode] Binary Tree Level Order Traversal
    [leetcode] Binary Tree Inorder Traversal
  • 原文地址:https://www.cnblogs.com/xihong2014/p/6699225.html
Copyright © 2011-2022 走看看