Windows下用ndk编译ffmpeg

Windows下用ndk编译ffmpeg

 

第一步:创建一个android工程,然后将ffmpeg整体放到jni下,并创建Android.mk和Application.mk

 

Android.mk:

{

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
#include $(all-subdir-makefiles)
include $(LOCAL_PATH)/ffmpeg/Android.mk

LOCAL_SHORT_COMMANDS :=true

}

 

 

Application.mk:

{

# The ARMv7 issignificanly faster due to the use of the hardware FPU

 

APP_ABI := armeabi-v7a

APP_PLATFORM :=android-9

#APP_MODULES     := libffmpeg

APP_BUILD_SCRIPT :=$(call my-dir)/Android.mk

APP_PROJECT_PATH :=$(call my-dir)

APP_SHORT_COMMANDS      := true

}

 

第二步:在ffmpeg下新建一个android_config.sh,然后运行android_config.sh

 

android_config.sh : 
{
#!/bin/bash 
E:/research_workspace/FFmpeg/jni/ffmpeg/configure --disable-static --enable-shared --enable-gpl --enable-version3 --enable-nonfree --enable-doc --enable-ffmpeg --enable-ffplay --enable-ffprobe --enable-ffserver --enable-avdevice --enable-avfilter --enable-postproc --enable-small --cross-prefix=D:/android-ndk-r8e/toolchains/arm-linux-androideabi-4.4.3/prebuilt/windows/bin/arm-linux-androideabi- --enable-cross-compile --target-os=linux --extra-cflags='-ID:/android-ndk-r8e/platforms/android-9/arch-arm/usr/include' --extra-ldflags='-LD:/android-ndk-r8e/platforms/android-9/arch-arm/usr/lib -nostdlib' --arch=arm --disable-symver --disable-debug --disable-stripping
}

 

 

第三步:在ffmpeg下添加一个文件av.mk和Android.mk,在libavcodec、libavfilter、libavformat、libavutil、libpostproc和libswscale下添加Android.mk,然后分别修改libavcodec、libswresample 、libavfilter、libavformat、libavutil、libpostproc和libswscale下的Makefile,把include $(SUBDIR)../config.mak屏蔽

 

 

Ffmpeg下的Android.mk

{

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS) 

LOCAL_WHOLE_STATIC_LIBRARIES:= libavformat libavcodec libavutil libpostproc libswresample libswscale

LOCAL_LDLIBS := \
-llog \
-lgcc \
-lz 

LOCAL_MODULE := ffmpeg

include $(BUILD_SHARED_LIBRARY)
#include$(BUILD_STATIC_LIBRARY) 

include $(call all-makefiles-under, $(LOCAL_PATH))

}

 

Ffmpeg下的av.mk

{

# LOCAL_PATH is one of libavutil, libavcodec, libavformat, or libswscale
#include$(LOCAL_PATH)/../config-$(TARGET_ARCH).mak
include $(LOCAL_PATH)/../config.mak


OBJS :=
OBJS-yes :=
MMX-OBJS-yes :=
include $(LOCAL_PATH)/Makefile


# collect objects
OBJS-$(HAVE_MMX) +=$(MMX-OBJS-yes)
OBJS += $(OBJS-yes)


FFNAME := lib$(NAME)
FFLIBS := $(foreach, NAME, $(FFLIBS), lib$(NAME))
FFCFLAGS  = -DHAVE_AV_CONFIG_H -Wno-sign-compare-Wno-switch -Wno-pointer-sign
FFCFLAGS +=-DTARGET_CONFIG=\"config-$(TARGET_ARCH).h\"
ALL_S_FILES := $(wildcard $(LOCAL_PATH)/$(TARGET_ARCH)/*.S)
ALL_S_FILES := $(addprefix $(TARGET_ARCH)/, $(notdir $(ALL_S_FILES)))
ifneq ($(ALL_S_FILES), )
ALL_S_OBJS := $(patsubst %.S, %.o, $(ALL_S_FILES))
C_OBJS := $(filter-out $(ALL_S_OBJS), $(OBJS))
S_OBJS := $(filter $(ALL_S_OBJS), $(OBJS))
else
C_OBJS := $(OBJS)
S_OBJS :=
endif
C_FILES := $(patsubst %.o, %.c, $(C_OBJS))
S_FILES := $(patsubst %.o, %.S, $(S_OBJS))
FFFILES := $(sort $(S_FILES)) $(sort $(C_FILES))

}


libavcodec、libswresample下的Android.mk:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

include $(LOCAL_PATH)/../av.mk

LOCAL_SRC_FILES :=$(FFFILES)


LOCAL_C_INCLUDES := \
$(LOCAL_PATH) \
$(LOCAL_PATH)/..


LOCAL_CFLAGS +=$(FFCFLAGS) 

LOCAL_LDLIBS := -lz

LOCAL_STATIC_LIBRARIES:= $(FFLIBS)

LOCAL_MODULE :=$(FFNAME)

include $(BUILD_STATIC_LIBRARY)



libavformat下的Android.mk:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

include $(LOCAL_PATH)/../av.mk

LOCAL_SRC_FILES :=$(FFFILES)

LOCAL_C_INCLUDES := \
$(LOCAL_PATH) \
$(LOCAL_PATH)/..

LOCAL_CFLAGS +=$(FFCFLAGS)

LOCAL_CFLAGS +=-include "string.h" -Dipv6mr_interface=ipv6mr_ifindex

LOCAL_LDLIBS := -lz

LOCAL_STATIC_LIBRARIES:= $(FFLIBS)

LOCAL_MODULE := $(FFNAME)

include $(BUILD_STATIC_LIBRARY)


libavfilter、libavutil、libpostproc和libswscale下的Android.mk内容如下
{

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
include $(LOCAL_PATH)/../av.mk
LOCAL_SRC_FILES := $(FFFILES)
LOCAL_C_INCLUDES := \
$(LOCAL_PATH) \
$(LOCAL_PATH)/..
LOCAL_CFLAGS += $(FFCFLAGS)
LOCAL_STATIC_LIBRARIES := $(FFLIBS)
LOCAL_MODULE := $(FFNAME)
include $(BUILD_STATIC_LIBRARY)

}

第四步:


没有找到config.mak, config.h的话,手动从C:\cygwin\home\WIN下拷过来


手动添加 libavutil/ffversion.h     #define FFMPEG_VERSION "wr.ndkr8e.ffmpeg281";


没有找到avconfig.h,手动从C:\cygwin\home\WIN\libavutil下拷过来



将libavutil里的libm.h里的static函数注释掉

 


第五步:

最后运行ndk-build

 

 

 

 

遇到的问题:

 

问题1

$ ./android_config.sh

D:/android-ndk-r8e/toolchains/arm-linux-androideabi-4.4.3/prebuilt/windows/bin/arm-linux-androideabi-gccis unable to create an executable file.

C compiler testfailed.

 

尝试

 

export TMPDIR="d:/temp"

$ /cygdrive/d/ffmpeg-2.8.1/android_config.sh

/cygdrive/d/ffmpeg-2.8.1/android_config.sh:3:$'\r':未找到命令

.nable to createtemporary file in d:/temp

 

解决:

 

这个问题是因为cygwin的路径起点与交叉编译工具链的路径起点不一致,需要在configure进行之前将configure内用到的TMPDIR变量设置为cygwin中某个文件夹在windows中的路径。

即:exportTMPDIR=D:/cygwin/tmp或者其它路径。

export TMPDIR=C:/cygwin/temp

 

WIN@WIN70509/cygdrive/d/ffmpeg-2.8.1

$ ./android_config.sh

D:/ffmpeg-2.8.1/configure:line 5743: [: =: unary operator expected

install prefix            /usr/local

source path               .

C compiler               D:/android-ndk-r8e/toolchains/arm-linux-androideabi-4.4.3/prebuilt/windows/bin/arm-linux-androideabi-gcc

C library                 bionic

host C compiler           gcc

host C library

ARCH                      arm (armv5te)

big-endian                no

runtime cpudetection     yes

ARMv5TE enabled           yes

ARMv6 enabled             yes

ARMv6T2 enabled           yes

VFP enabled               yes

NEON enabled              yes

THUMB enabled             no

debug symbols             no

strip symbols             no

optimize forsize         yes

optimizations             yes

static                    no

shared                    yes

postprocessingsupport    yes

new filtersupport        yes

network support           yes

threadingsupport         no

safe bitstreamreader     yes

SDL support               no

opencl enabled            no

texi2htmlenabled         no

perl enabled              no

pod2man enabled           no

makeinfo enabled          no

makeinfo supportsHTML    no

 

Enabled programs:

ffmpeg                  ffprobe

 

External libraries:

zlib

 

Enabled decoders:

aac                     ayuv                    frwu

aac_fixed               bethsoftvid             g2m

aac_latm                bfi                     g723_1

aasc                    bink                    g729

ac3                     binkaudio_dct           gif

ac3_fixed               binkaudio_rdft          gsm

adpcm_4xm               bintext                 gsm_ms

adpcm_adx               bmp                     h261

adpcm_afc               bmv_audio               h263

adpcm_ct                bmv_video               h263i

adpcm_dtk               brender_pix             h263p

adpcm_ea                c93                     h264

adpcm_ea_maxis_xa       cavs                   hap

adpcm_ea_r1             ccaption                hevc

adpcm_ea_r2             cdgraphics              hnm4_video

adpcm_ea_r3             cdxl                    hq_hqa

adpcm_ea_xas            cinepak                 hqx

adpcm_g722              cljr                    huffyuv

adpcm_g726              cllc                    iac

adpcm_g726le            comfortnoise            idcin

adpcm_ima_amv           cook                    idf

adpcm_ima_apc           cpia                    iff_byterun1

adpcm_ima_dk3           cscd                    iff_ilbm

adpcm_ima_dk4           cyuv                    imc

adpcm_ima_ea_eacs       dca                     indeo2

adpcm_ima_ea_sead       dds                     indeo3

adpcm_ima_iss           dfa                     indeo4

adpcm_ima_oki           dirac                   indeo5

adpcm_ima_qt            dnxhd                   interplay_dpcm

adpcm_ima_rad           dpx                     interplay_video

adpcm_ima_smjpeg        dsd_lsbf                jacosub

adpcm_ima_wav           dsd_lsbf_planar         jpeg2000

adpcm_ima_ws            dsd_msbf                jpegls

adpcm_ms                dsd_msbf_planar         jv

adpcm_sbpro_2           dsicinaudio             kgv1

adpcm_sbpro_3           dsicinvideo             kmvc

adpcm_sbpro_4           dss_sp                  lagarith

adpcm_swf               dvbsub                  loco

adpcm_thp               dvdsub                  mace3

adpcm_thp_le            dvvideo                 mace6

adpcm_vima              dxa                     mdec

adpcm_xa                dxtory                  metasound

adpcm_yamaha            eac3                    microdvd

aic                     eacmv                   mimic

alac                    eamad                   mjpeg

alias_pix               eatgq                   mjpegb

als                     eatgv                   mlp

amrnb                   eatqi                   mmvideo

amrwb                   eightbps                motionpixels

amv                     eightsvx_exp            movtext

anm                     eightsvx_fib            mp1

ansi                    escape124               mp1float

ape                     escape130               mp2

apng                    evrc                    mp2float

ass                     exr                     mp3

asv1                    ffv1                    mp3adu

asv2                    ffvhuff                 mp3adufloat

atrac1                  ffwavesynth             mp3float

atrac3                  fic                     mp3on4

atrac3p                 flac                    mp3on4float

aura                    flashsv                 mpc7

aura2                   flashsv2                mpc8

avrn                    flic                    mpeg1video

avrp                    flv                     mpeg2video

avs                     fourxm                  mpeg4

avui                    fraps                   mpegvideo

mpl2                    prores_lgpl             tscc2

msa1                    ptx                     tta

msmpeg4v1               qcelp                   twinvq

msmpeg4v2               qdm2                    txd

msmpeg4v3               qdraw                   ulti

msrle                   qpeg                    utvideo

mss1                    qtrle                   v210

mss2                    r10k                    v210x

msvideo1                r210                    v308

mszh                    ra_144                  v408

mts2                    ra_288                  v410

mvc1                    ralf                    vb

mvc2                    rawvideo                vble

mxpeg                   realtext                vc1

nellymoser              rl2                     vc1image

nuv                     roq                     vcr1

on2avc                  roq_dpcm                vima

opus                    rpza                    vmdaudio

paf_audio               rv10                    vmdvideo

paf_video               rv20                    vmnc

pam                     rv30                    vorbis

pbm                     rv40                    vp3

pcm_alaw                s302m                   vp5

pcm_bluray              sami                    vp6

pcm_dvd                 sanm                    vp6a

pcm_f32be               sgi                     vp6f

pcm_f32le               sgirle                  vp7

pcm_f64be               shorten                 vp8

pcm_f64le               sipr                    vp9

pcm_lxf                 smackaud                vplayer

pcm_mulaw               smacker                 vqa

pcm_s16be               smc                     wavpack

pcm_s16be_planar        smvjpeg                 webp

pcm_s16le               snow                    webvtt

pcm_s16le_planar        sol_dpcm                wmalossless

pcm_s24be               sonic                   wmapro

pcm_s24daud             sp5x                    wmav1

pcm_s24le               srt                     wmav2

pcm_s24le_planar        ssa                     wmavoice

pcm_s32be               stl                     wmv1

pcm_s32le               subrip                  wmv2

pcm_s32le_planar        subviewer               wmv3

pcm_s8                  subviewer1              wmv3image

pcm_s8_planar           sunrast                 wnv1

pcm_u16be               svq1                    ws_snd1

pcm_u16le               svq3                    xan_dpcm

pcm_u24be               tak                     xan_wc3

pcm_u24le               targa                   xan_wc4

pcm_u32be               targa_y216              xbin

pcm_u32le               tdsc                    xbm

pcm_u8                  text                    xface

pcm_zork                theora                  xl

pcx                     thp                     xsub

pgm                     tiertexseqvideo         xwd

pgmyuv                  tiff                    y41p

pgssub                  tmv                     yop

pictor                  truehd                  yuv4

pjs                     truemotion1             zero12v

png                     truemotion2             zerocodec

ppm                     truespeech              zlib

prores                  tscc                    zmbv

 

Enabled encoders:

a64multi                jpeg2000                ppm

a64multi5               jpegls                  prores

aac                     ljpeg                   prores_aw

ac3                     mjpeg                   prores_ks

ac3_fixed               movtext                 qtrle

adpcm_adx               mp2                     r10k

adpcm_g722              mp2fixed                r210

adpcm_g726              mpeg1video              ra_144

adpcm_ima_qt            mpeg2video              rawvideo

adpcm_ima_wav           mpeg4                   roq

adpcm_ms                msmpeg4v2               roq_dpcm

adpcm_swf               msmpeg4v3               rv10

adpcm_yamaha            msvideo1                rv20

alac                    nellymoser              s302m

alias_pix               pam                     sgi

amv                     pbm                     snow

apng                    pcm_alaw                sonic

ass                     pcm_f32be               sonic_ls

asv1                    pcm_f32le               srt

asv2                    pcm_f64be               ssa

avrp                    pcm_f64le               subrip

avui                    pcm_mulaw               sunrast

ayuv                    pcm_s16be               svq1

bmp                     pcm_s16be_planar        targa

cinepak                 pcm_s16le               tiff

cljr                    pcm_s16le_planar        tta

comfortnoise            pcm_s24be               utvideo

dca                     pcm_s24daud             v210

dnxhd                   pcm_s24le               v308

dpx                     pcm_s24le_planar        v408

dvbsub                  pcm_s32be               v410

dvdsub                  pcm_s32le               vorbis

dvvideo                 pcm_s32le_planar        wavpack

eac3                    pcm_s8                  webvtt

ffv1                    pcm_s8_planar           wmav1

ffvhuff                 pcm_u16be               wmav2

flac                    pcm_u16le               wmv1

flashsv                 pcm_u24be               wmv2

flashsv2                pcm_u24le               xbm

flv                     pcm_u32be               xface

g723_1                  pcm_u32le               xsub

gif                     pcm_u8                  xwd

h261                    pcx                     y41p

h263                    pgm                     yuv4

h263p                   pgmyuv                  zlib

huffyuv                 png                     zmbv

 

Enabled hwaccels:

 

Enabled parsers:

aac                     dvdsub                  mpegvideo

aac_latm                flac                    opus

ac3                     g729                    png

adx                     gsm                     pnm

bmp                     h261                    rv30

cavsvideo               h263                    rv40

cook                    h264                    tak

dca                     hevc                    vc1

dirac                   mjpeg                   vorbis

dnxhd                   mlp                     vp3

dpx                     mpeg4video              vp8

dvbsub                  mpegaudio               vp9

dvd_nav

 

Enabled demuxers:

aa                      g723_1                  mpjpeg

aac                     g729                    mpl2

ac3                     gif                     mpsub

act                     gsm                     msnwc_tcp

adf                     gxf                     mtv

adp                     h261                    mv

adx                     h263                    mvi

aea                     h264                    mxf

afc                     hevc                    mxg

aiff                    hls                     nc

amr                     hnm                     nistsphere

anm                     ico                     nsv

apc                     idcin                   nut

ape                     idf                     nuv

apng                    iff                     ogg

aqtitle                 ilbc                    oma

asf                     image2                  paf

asf_o                   image2_alias_pix        pcm_alaw

ass                     image2_brender_pix      pcm_f32be

ast                     image2pipe              pcm_f32le

au                      image_bmp_pipe          pcm_f64be

avi                     image_dds_pipe          pcm_f64le

avr                     image_dpx_pipe          pcm_mulaw

avs                     image_exr_pipe          pcm_s16be

bethsoftvid             image_j2k_pipe          pcm_s16le

bfi                     image_jpeg_pipe         pcm_s24be

bfstm                   image_jpegls_pipe       pcm_s24le

bink                    image_pictor_pipe       pcm_s32be

bintext                 image_png_pipe          pcm_s32le

bit                     image_qdraw_pipe        pcm_s8

bmv                     image_sgi_pipe          pcm_u16be

boa                     image_sunrast_pipe      pcm_u16le

brstm                   image_tiff_pipe         pcm_u24be

c93                     image_webp_pipe         pcm_u24le

caf                     ingenient               pcm_u32be

cavsvideo               ipmovie                 pcm_u32le

cdg                     ircam                   pcm_u8

cdxl                    iss                     pjs

cine                    iv8                     pmp

concat                  ivf                     pva

data                    jacosub                 pvf

daud                    jv                      qcp

dfa                     latm                    r3d

dirac                   live_flv                rawvideo

dnxhd                   lmlm4                   realtext

dsf                     loas                    redspark

dsicin                  lrc                     rl2

dss                     lvf                     rm

dts                     lxf                     roq

dtshd                   m4v                     rpl

dv                      matroska                rsd

dvbsub                  mgsts                   rso

dxa                     microdvd                rtp

ea                      mjpeg                   rtsp

ea_cdata                mlp                     sami

eac3                    mlv                     sap

epaf                    mm                      sbg

ffm                     mmf                     sdp

ffmetadata              mov                     sdr2

filmstrip               mp3                     segafilm

flac                    mpc                     shorten

flic                    mpc8                    siff

flv                     mpegps                  sln

fourxm                  mpegts                  smacker

frm                     mpegtsraw               smjpeg

g722                    mpegvideo               smush

sol                     tmv                     wav

sox                     truehd                  wc3

spdif                   tta                     webm_dash_manifest

srt                     tty                     webvtt

stl                     txd                     wsaud

str                     vc1                     wsvqa

subviewer               vc1t                    wtv

subviewer1              vivo                    wv

sup                     vmd                     xa

swf                     vobsub                  xbin

tak                     voc                     xmv

tedcaptions             vplayer                 xwma

thp                     vqf                     yop

tiertexseq              w64                     yuv4mpegpipe

 

Enabled muxers:

a64                     ipod                    pcm_s32be

ac3                     ircam                   pcm_s32le

adts                    ismv                    pcm_s8

adx                     ivf                     pcm_u16be

aiff                    jacosub                 pcm_u16le

amr                     latm                    pcm_u24be

apng                    lrc                     pcm_u24le

asf                     m4v                     pcm_u32be

asf_stream              matroska                pcm_u32le

ass                     matroska_audio          pcm_u8

ast                     md5                     psp

au                      microdvd                rawvideo

avi                     mjpeg                   rm

avm2                    mkvtimestamp_v2         roq

bit                     mlp                     rso

caf                     mmf                     rtp

cavsvideo               mov                     rtp_mpegts

crc                     mp2                     rtsp

dash                    mp3                     sap

data                    mp4                     segment

daud                    mpeg1system             singlejpeg

dirac                   mpeg1vcd                smjpeg

dnxhd                   mpeg1video              smoothstreaming

dts                     mpeg2dvd                sox

dv                      mpeg2svcd               spdif

eac3                    mpeg2video              spx

f4v                     mpeg2vob                srt

ffm                     mpegts                  stream_segment

ffmetadata              mpjpeg                  swf

filmstrip               mxf                     tee

flac                    mxf_d10                 tg2

flv                     mxf_opatom              tgp

framecrc                null                    truehd

framemd5                nut                     uncodedframecrc

g722                    oga                     vc1

g723_1                  ogg                     vc1t

gif                     oma                     voc

gxf                     opus                    w64

h261                    pcm_alaw                wav

h263                    pcm_f32be               webm

h264                    pcm_f32le               webm_chunk

hds                     pcm_f64be               webm_dash_manifest

hevc                    pcm_f64le               webp

hls                     pcm_mulaw               webvtt

ico                     pcm_s16be               wtv

ilbc                    pcm_s16le               wv

image2                  pcm_s24be               yuv4mpegpipe

image2pipe              pcm_s24le

 

Enabled protocols:

cache                   http                    rtmpt

concat                  httpproxy               rtp

crypto                  icecast                 srtp

data                    md5                     subfile

ffrtmphttp              mmsh                    tcp

file                    mmst                    udp

ftp                     pipe                    udplite

gopher                  rtmp                    unix

hls

 

Enabled filters:

acrossfade              curves                  mptestsrc

adelay                  dcshift                 negate

adrawgraph              dctdnoiz                noformat

aecho                   deband                  noise

aeval                   decimate                null

aevalsrc                deflate                 nullsink

afade                   dejudder                nullsrc

aformat                 delogo                  overlay

ainterleave             deshake                 owdenoise

allpass                 detelecine              pad

allrgb                  dilation                palettegen

allyuv                  drawbox                 paletteuse

alphaextract            drawgraph               pan

alphamerge              drawgrid                perms

amerge                  earwax                  perspective

amix                    ebur128                 phase

amovie                  edgedetect              pixdesctest

anull                   elbg                    pp

anullsink               eq                      pp7

anullsrc                equalizer               psnr

apad                    erosion                 pullup

aperms                  extractplanes           qp

aphasemeter             fade                    random

aphaser                 fftfilt                 removegrain

aresample               field                   removelogo

areverse                fieldmatch              repeatfields

aselect                 fieldorder              replaygain

asendcmd                find_rect               reverse

asetnsamples            flanger                 rgbtestsrc

asetpts                 format                  rotate

asetrate                fps                     sab

asettb                  framepack               scale

ashowinfo               framerate               scale2ref

asplit                  framestep               select

astats                  fspp                    sendcmd

astreamsync             geq                     separatefields

atadenoise              gradfun                 setdar

atempo                  haldclut                setfield

atrim                   haldclutsrc             setpts

avectorscope            hflip                   setsar

bandpass                highpass                settb

bandreject              histeq                  showcqt

bass                    histogram               showfreqs

bbox                    hqdn3d                  showinfo

biquad                  hqx                     showpalette

blackdetect             hstack                  showspectrum

blackframe              hue                     showvolume

blend                   idet                    showwaves

boxblur                 il                      showwavespic

cellauto                inflate                 shuffleplanes

channelmap              interlace               sidechaincompress

channelsplit            interleave              signalstats

chorus                  join                    silencedetect

codecview               kerndeint               silenceremove

color                   lenscorrection          sine

colorbalance            life                    smartblur

colorchannelmixer       lowpass                 smptebars

colorkey                lut                     smptehdbars

colorlevels             lut3d                   split

colormatrix             lutrgb                  spp

compand                 lutyuv                  ssim

concat                  mandelbrot              stereo3d

copy                    mcdeint                 super2xsai

cover_rect              mergeplanes             swapuv

crop                    movie                   tblend

cropdetect              mpdecimate              telecine

testsrc                 unsharp                 vstack

thumbnail               uspp                    w3fdif

tile                    vectorscope             waveform

tinterlace              vflip                   xbr

transpose               vignette                yadif

treble                  volume                  zoompan

trim                    volumedetect

 

Enabled bsfs:

aac_adtstoasc           imx_dump_header         mpeg4_unpack_bframes

chomp                   mjpeg2jpeg              noise

dump_extradata          mjpega_dump_header      remove_extradata

h264_mp4toannexb        mov2textsub             text2movsub

hevc_mp4toannexb        mp3_header_decompress

 

Enabled indevs:

dv1394                  lavfi                   v4l2

fbdev

 

Enabled outdevs:

fbdev                   v4l2

 

License: nonfree andunredistributable

Creating config.mak,config.h, and doc/config.texi...

D:/ffmpeg-2.8.1/configure:line 1316: cmp: command not found

D:/ffmpeg-2.8.1/configure:line 1316: cmp: command not found

 

WARNING:D:/android-ndk-r8e/toolchains/arm-linux-androideabi-4.4.3/prebuilt/windows/bin/arm-linux-androideabi-pkg-confignot found, library detection may fail.

 

 

问题2ndk编译时,遇到   make:Nothing to be done for `all'.

 

通过cmd来尝试

       C:\Users\WIN>D:\android-ndk-r8e\ndk-build.cmdNDK_PROJECT_PATH=E:\research_works

       pace\FFmpeg NDK_APPLICATION_MK=E:\research_workspace\FFmpeg\jni\application.mk

       Android NDK: Your APP_BUILD_SCRIPT pointsto an unknown file: Android.mk

       D:/android-ndk-r8e/build/core/add-application.mk:165:*** Android NDK: Aborting.

       ..   .  Stop.

 

解决android.mk 小写不行 要大写 Android.mk

 

 

 

问题3*** Android NDK: Missing LOCAL_MODULE beforeincluding BUILD_STATIC_LIBRARY in jni/ffmpeg/libavcodec/Android.mk

修改av.mk,在前面加上

#include$(LOCAL_PATH)/../config-$(TARGET_ARCH).mak

include$(LOCAL_PATH)/../config.mak

 

OBJS :=

OBJS-yes :=

MMX-OBJS-yes :=

include$(LOCAL_PATH)/Makefile

 

# collect objects

OBJS-$(HAVE_MMX) +=$(MMX-OBJS-yes)

OBJS += $(OBJS-yes)

 

 

问题4*** target file `clean' has both : and ::entries.  Stop.

在libavfilter目录中的Makefile的末尾处多了 Clean 这个玩意儿 将其注释掉或者删掉就可以了

 

 

问题5

"Compile thumb :avformat <= 4xm.c

In file included fromjni/ffmpeg/libavformat/../libavutil/common.h:39:0,

                 fromjni/ffmpeg/libavformat/../libavutil/avutil.h:288,

                 fromjni/ffmpeg/libavformat/../libavutil/samplefmt.h:24,

                 fromjni/ffmpeg/libavformat/../libavcodec/avcodec.h:31,

                 fromjni/ffmpeg/libavformat/avformat.h:306,

                 fromjni/ffmpeg/libavformat/4xm.c:32:

D:/android-ndk-r8e/platforms/android-14/arch-arm/usr/include/stdlib.h:54:14:error: expected identifier or '(' before 'void'

D:/android-ndk-r8e/platforms/android-14/arch-arm/usr/include/stdlib.h:54:14:error: expected ')' before numeric constant

make: ***[obj/local/armeabi/objs/avformat/4xm.o] Error 1

 

备注:

由于之前android_config.sh的时候指定了android-9,这里Application.mk也要指定APP_PLATFORM := android-9(注意Application.mk头字母要大写)

 

非正常解决方法:

自做主张把stdlib.h 中的 extern char *getenv(const char*);改成extern char*_getenv(const char *);

变量名加个下划线,编译完再改回来。

 

正常解决方法:

将config.h里的#define getenv(x) NULL注释掉

 

 

问题6

{

jni/ffmpeg/libavformat/../libavutil/time_internal.h:26:26:error: static declaration of 'gmtime_r' follows non-static declaration

D:/android-ndk-r8e/platforms/android-9/arch-arm/usr/include/time.h:77:20:note: previous declaration of 'gmtime_r' was here

jni/ffmpeg/libavformat/../libavutil/time_internal.h:37:26:error: static declaration of 'localtime_r' follows non-static declaration

D:/android-ndk-r8e/platforms/android-9/arch-arm/usr/include/time.h:74:20:note: previous declaration of 'localtime_r' was here

}

可以与上面非正常解决方法同样处理

 

解决:

将config.h里的#define HAVE_GMTIME_R 0改为#define HAVE_GMTIME_R 1  //搜了一下,只有time_internal.h这里用到了HAVE_GMTIME_R

还有config.h里的#define HAVE_LOCALTIME_R 0改为#define HAVE_LOCALTIME_R 1  //搜了一下,只有time_internal.HAVE_LOCALTIME_R

 

 

问题7

In file included fromjni/ffmpeg/libavformat/../libavcodec/dca.h:30:0,

                 fromjni/ffmpeg/libavformat/dtsdec.c:23:

jni/ffmpeg/libavformat/../libavutil/float_dsp.h:148:50:error: expected ';', ',' or ')' before 'v1'

make: ***[obj/local/armeabi/objs/avformat/dtsdec.o] Error 1

jni/ffmpeg/libavformat/../libavutil/float_dsp.h:148:50:error: expected ';', ',' or ')' before 'v1'

 

解决:

c、修改jni/ffmpeg/config.h下的

#define avrestrict restrict为#define restrict

 

这个应该改为 #define av_restrict

 

 

 

问题8

"Compile thumb :avcodec <= aacdec_fixed.c

C:\Temp\cczAntBF.s:Assembler messages:

C:\Temp\cczAntBF.s:6264:Error: instruction not supported in Thumb16 mode -- `adds ip,r2,r1,lsr#31'

C:\Temp\cczAntBF.s:6265:Error: selected processor does not support Thumb mode `itet ne'

C:\Temp\cczAntBF.s:6266:Error: Thumb does not support conditional execution

C:\Temp\cczAntBF.s:6267:Error: Thumb does not support conditional execution

C:\Temp\cczAntBF.s:6268:Error: Thumb does not support conditional execution

C:\Temp\cczAntBF.s:6307:Error: instruction not supported in Thumb16 mode -- `adds ip,r2,r1,lsr#31'

C:\Temp\cczAntBF.s:6308:Error: selected processor does not support Thumb mode `itet ne'

C:\Temp\cczAntBF.s:6309:Error: Thumb does not support conditional execution

C:\Temp\cczAntBF.s:6310:Error: Thumb does not support conditional execution

C:\Temp\cczAntBF.s:6311:Error: Thumb does not support conditional execution

C:\Temp\cczAntBF.s:13752:Error: selected processor does not support Thumb mode `umull r1,r0,r3,r2'

make: ***[obj/local/armeabi/objs/avcodec/aacdec_fixed.o] Error 1

 

解决:

在Application.mk上加上

APP_ABI := armeabi-v7a

 

问题9

"Compile thumb :avcodec <= cinepakenc.c

jni/ffmpeg/libavcodec/cinepakenc.c:In function 'rd_strip':

jni/ffmpeg/libavcodec/cinepakenc.c:966:13:error: 'for' loop initial declarations are only allowed in C99 mode

jni/ffmpeg/libavcodec/cinepakenc.c:966:13:note: use option -std=c99 or -std=gnu99 to compile your code

make: ***[obj/local/armeabi-v7a/objs/avcodec/cinepakenc.o] Error 1

 

jni/ffmpeg/libavcodec/movtextdec.c:In function 'mov_text_decode_frame':

jni/ffmpeg/libavcodec/movtextdec.c:492:13:error: 'for' loop initial declarations are only allowed in C99 mode

jni/ffmpeg/libavcodec/movtextdec.c:492:13:note: use option -std=c99 or -std=gnu99 to compile your code

make: ***[obj/local/armeabi-v7a/objs/avcodec/movtextdec.o] Error 1

 

解决:将initial放到for之外

 

 

问题10

"Compile thumb :avutil <= parseutils.c

In file included fromjni/ffmpeg/libavutil/parseutils.c:33:0:

jni/ffmpeg/libavutil/parseutils.h:186:64:warning: 'struct tm' declared inside parameter list [enabled by default]

jni/ffmpeg/libavutil/parseutils.h:186:64:warning: its scope is only this definition or declaration, which is probablynot what you want [enabled by default]

jni/ffmpeg/libavutil/parseutils.h:191:25:warning: 'struct tm' declared inside parameter list [enabled by default]

jni/ffmpeg/libavutil/parseutils.c:468:64:warning: 'struct tm' declared inside parameter list [enabled by default]

jni/ffmpeg/libavutil/parseutils.c:468:7:error: conflicting types for 'av_small_strptime'

jni/ffmpeg/libavutil/parseutils.h:186:7:note: previous declaration of 'av_small_strptime' was here

jni/ffmpeg/libavutil/parseutils.c:In function 'av_small_strptime':

jni/ffmpeg/libavutil/parseutils.c:490:15:error: dereferencing pointer to incomplete type

jni/ffmpeg/libavutil/parseutils.c:496:15:error: dereferencing pointer to incomplete type

jni/ffmpeg/libavutil/parseutils.c:502:15:error: dereferencing pointer to incomplete type

jni/ffmpeg/libavutil/parseutils.c:508:15:error: dereferencing pointer to incomplete type

jni/ffmpeg/libavutil/parseutils.c:514:15:error: dereferencing pointer to incomplete type

jni/ffmpeg/libavutil/parseutils.c:520:15:error: dereferencing pointer to incomplete type

jni/ffmpeg/libavutil/parseutils.c:At top level:

jni/ffmpeg/libavutil/parseutils.c:539:25:warning: 'struct tm' declared inside parameter list [enabled by default]

jni/ffmpeg/libavutil/parseutils.c:539:8:error: conflicting types for 'av_timegm'

jni/ffmpeg/libavutil/parseutils.h:191:8:note: previous declaration of 'av_timegm' was here

jni/ffmpeg/libavutil/parseutils.c:In function 'av_timegm':

jni/ffmpeg/libavutil/parseutils.c:543:15:error: dereferencing pointer to incomplete type

jni/ffmpeg/libavutil/parseutils.c:543:39:error: dereferencing pointer to incomplete type

jni/ffmpeg/libavutil/parseutils.c:543:59:error: dereferencing pointer to incomplete type

jni/ffmpeg/libavutil/parseutils.c:553:19:error: dereferencing pointer to incomplete type

jni/ffmpeg/libavutil/parseutils.c:553:38:error: dereferencing pointer to incomplete type

jni/ffmpeg/libavutil/parseutils.c:553:51:error: dereferencing pointer to incomplete type

jni/ffmpeg/libavutil/parseutils.c:In function 'av_parse_time':

jni/ffmpeg/libavutil/parseutils.c:563:12:error: variable 'dt' has initializer but incomplete type

jni/ffmpeg/libavutil/parseutils.c:563:12:warning: excess elements in struct initializer [enabled by default]

jni/ffmpeg/libavutil/parseutils.c:563:12:warning: (near initialization for 'dt') [enabled by default]

jni/ffmpeg/libavutil/parseutils.c:563:15:error: storage size of 'dt' isn't known

jni/ffmpeg/libavutil/parseutils.c:563:27:error: storage size of 'tmbuf' isn't known

jni/ffmpeg/libavutil/parseutils.c:658:20:error: variable 'dt2' has initializer but incomplete type

jni/ffmpeg/libavutil/parseutils.c:658:23:error: storage size of 'dt2' isn't known

make: ***[obj/local/armeabi-v7a/objs/avutil/parseutils.o] Error 1

 

头文件冲突

 

解决:

 

把ffmpeg/libavutil/time.h更名为avtime.h,

 

同时修改下面文件中的引用libavutil/time.h为libavutil/avtime.h

ffmpeg/libavformat/avformat.h:211

ffmpeg/libavformat/avio.c:25

ffmpeg/libavformat/hls.c:33

ffmpeg/libavformat/hlsproto.c:29

 

ffmpeg/libavformat/mux.c:39:30

 

ffmpeg/libavformat/utils.c:40

ffmpeg/libavutil/time.c:36

 

搜索libavutil/time.h,把它们全部改为libavutil/avtime.h

 

libavutil/avtime.h 里添加 #include

 

 

问题11:编译出来ffmpeg.so太小

解决:将Android.mk里的LOCAL_STATIC_LIBRARIES替换为LOCAL_WHOLE_STATIC_LIBRARIES

 

 

问题12

 

SharedLibrary  : libffmpeg.so

D:/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe:error: ./obj/local/armeabi-v7a/libavcodec.a(golomb.o): multiple definition of'ff_interleaved_dirac_golomb_vlc_code'

D:/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe:./obj/local/armeabi-v7a/libavformat.a(golomb_tab.o): previous definition here

D:/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe:error: ./obj/local/armeabi-v7a/libavcodec.a(golomb.o): multiple definition of'ff_interleaved_se_golomb_vlc_code'

D:/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe:./obj/local/armeabi-v7a/libavformat.a(golomb_tab.o): previous definition here

D:/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe:error: ./obj/local/armeabi-v7a/libavcodec.a(golomb.o): multiple definition of'ff_interleaved_ue_golomb_vlc_code'

D:/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe:./obj/local/armeabi-v7a/libavformat.a(golomb_tab.o): previous definition here

D:/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe:error: ./obj/local/armeabi-v7a/libavcodec.a(golomb.o): multiple definition of'ff_interleaved_golomb_vlc_len'

D:/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe:./obj/local/armeabi-v7a/libavformat.a(golomb_tab.o): previous definition here

D:/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe:error: ./obj/local/armeabi-v7a/libavcodec.a(golomb.o): multiple definition of'ff_ue_golomb_len'

D:/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe:./obj/local/armeabi-v7a/libavformat.a(golomb_tab.o): previous definition here

D:/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe:error: ./obj/local/armeabi-v7a/libavcodec.a(golomb.o): multiple definition of'ff_se_golomb_vlc_code'

D:/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe:./obj/local/armeabi-v7a/libavformat.a(golomb_tab.o): previous definition here


此处忽略许多


D:/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe:./obj/local/armeabi-v7a/libavcodec.a(vp8dsp.o): in functionff_vp78dsp_init:jni/ffmpeg/libavcodec/vp8dsp.c:675: error: undefined referenceto 'ff_vp78dsp_init_arm'

D:/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe:./obj/local/armeabi-v7a/libavcodec.a(vp8dsp.o): in functionff_vp8dsp_init:jni/ffmpeg/libavcodec/vp8dsp.c:735: error: undefined referenceto 'ff_vp8dsp_init_arm'

D:/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe:./obj/local/armeabi-v7a/libavcodec.a(zmbvenc.o): in functionencode_frame:jni/ffmpeg/libavcodec/zmbvenc.c:219: error: undefined reference to'deflateReset'

D:/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe:./obj/local/armeabi-v7a/libavutil.a(cpu.o): in function av_get_cpu_flags:jni/ffmpeg/libavutil/cpu.c:84:error: undefined reference to 'ff_get_cpu_flags_arm'

D:/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe:./obj/local/armeabi-v7a/libavutil.a(float_dsp.o): in functionavpriv_float_dsp_init:jni/ffmpeg/libavutil/float_dsp.c:134: error: undefinedreference to 'ff_float_dsp_init_arm'

collect2: ld returned1 exit status

make: ***[obj/local/armeabi-v7a/libffmpeg.so] Error 1

 

解决:

子问题1libavcodec/log2_tab.o: multiple definition of'ff_log2_tab'解决办法

{

新增文件libavutil/log2_tab.h, 其内容如下

 

#ifndef AV_LOG2TAB_H

#define AV_LOG2TAB_H

 

#include

extern const uint8_t ff_log2_tab[256];

 

#endif

 

将所有报上述类似错误的, 做如下修改

 

如:修改 libavcodec/log2_tab.c,将log2_tab.c改为log2_tab.h

 

// #include"libavutil/log2_tab.c"

#include "libavutil/log2_tab.h"

}

 

子问题2error: libavformat/golomb_tab.o: multipledefinition of 'ff_interleaved_dirac_golomb_vlc_code'解决方法

修改libavformat/golomb_tab.c, 如下:

 

// #include "libavcodec/golomb.c"

#include "libavcodec/golomb.h"

 

 

子问题3obj/local/armeabi-v7a/libavutil.a(reverse.o):multiple definition of 'ff_reverse'

       /obj/local/armeabi-v7a/libavcodec.a(reverse.o):previous definition here                 解决方法

 

新增文件libavutil/reverse.h, 其内容如下

 

#ifndef AV_REVERSE_WR_H

#define AV_REVERSE_WR_H

 

#include

extern const uint8_t ff_reverse[256];

 

#endif //AV_REVERSE_WR_H

 

将所有报上述类似错误的, 做如下修改

 

如:修改libavutil/reverse.c, reverse.reverse.h

 

// #include "libavutil/reverse.c"

#include "libavutil/reverse.h"

 

 

子问题4error: undefined reference to 'inflateEnd'

{缺少zlib

在Android.mk上加上

LOCAL_LDLIBS := \

   -llog \

   -lgcc \

   -lz

 

子问题5error: undefined reference to'ff_ac3dsp_init_arm'

       解决方法:

       {

              /libffmpeg/libavcodec/arm/目录下 找 Makefile和ac3dsp_init_arm.c 定义都在这

             

              将av.mk单独拷一份到/libffmpeg/libavcodec下,libavcodec的Android.mk里指向这个av.mk,在里面加上include$(LOCAL_PATH)/arm/Makefile

             

              {

                     衍生问题:

                     {

                            StaticLibrary  :libavcodec.a

                            process_begin:CreateProcess(D:\android-ndk-r8e\toolchains\arm-linux-androideabi-4.6\prebuilt\windows\bin\arm-linux-androideabi-ar.exe,D:/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/arm-linux-androideabi-ar

此处忽略许多

./obj/local/armeabi-v7a/objs/avcodec/xwdenc.o./obj/local/armeabi-v7a/objs/avcodec/xxan.o./obj/local/armeabi-v7a/objs/avcodec/y41pdec.o./obj/local/armeabi-v7a/objs/avcodec/y41penc.o./obj/local/armeabi-v7a/objs/avcodec/yop.o./obj/local/armeabi-v7a/objs/avcodec/yuv4dec.o./obj/local/armeabi-v7a/objs/avcodec/yuv4enc.o ./obj/local/armeabi-v7a/objs/avcodec/zerocodec.o./obj/local/armeabi-v7a/objs/avcodec/zmbv.o./obj/local/armeabi-v7a/objs/avcodec/zmbvenc.o, ...) failed.

                            make (e=87): 参数错误。

                     }

                     原因是.MK文件中包含的文件太多了,而windows对于函数参数个数有限制

                     在Android.mk文件中添加:LOCAL_SHORT_COMMANDS := true

                     在Application.mk文件中添加:APP_SHORT_COMMANDS      := true

                     http://stackoverflow.com/questions/12598933/ndk-build-createprocess-make-e-87-the-parameter-is-incorrect

 

                    

                     问题:有更多的连接问题

                     未解决break

              }

       }

      

       换个解决方法:将undefined reference的全部加上WR_IGNORE忽略,在config.h上加上#define WR_IGNORE 0

 

子问题6error: undefined reference to 'swr_close'

       缺少libswresample

       android.mk里加上 libswresample,libswresample用libavcodec的Android.mk

      

      

       {

       衍生问题:audioconvert.c:158: error:undefined reference to 'swri_audio_convert_init_arm'

       解决:加上WR_IGNORE忽略

       }

 

 

终于成功了,下一步试试调用看看能不能用

 

可以~

你可能感兴趣的:(android开发)