rules.mak 4.75 KB
Newer Older
Philippe Gorley's avatar
Philippe Gorley committed
1
FFMPEG_HASH := 18516d3e695980525bd9758dc7b8a8e36cd3f09e
2
FFMPEG_URL := https://git.ffmpeg.org/gitweb/ffmpeg.git/snapshot/$(FFMPEG_HASH).tar.gz
Edric Milaret's avatar
Edric Milaret committed
3

4
PKGS+=ffmpeg
Philippe Gorley's avatar
Philippe Gorley committed
5

6
ifeq ($(call need_pkg,"libavutil >= 55.75.100 libavcodec >= 57.106.101 libavformat >= 57.82.100 libavdevice >= 57.8.101 libavfilter >= 6.105.100 libswscale >= 4.7.103"),)
7 8 9
PKGS_FOUND += ffmpeg
endif

10
DEPS_ffmpeg = iconv zlib vpx opus speex
11

Edric Milaret's avatar
Edric Milaret committed
12
FFMPEGCONF = \
13 14
	--cc="$(CC)" \
	--pkg-config="$(PKG_CONFIG)"
Edric Milaret's avatar
Edric Milaret committed
15 16 17

#disable everything
FFMPEGCONF += \
18 19 20 21 22
	--disable-everything \
	--enable-zlib \
	--enable-gpl \
	--enable-swscale \
	--enable-protocols \
Philippe Gorley's avatar
Philippe Gorley committed
23
	--enable-bsfs \
24
	--enable-filters \
Philippe Gorley's avatar
Philippe Gorley committed
25
	--disable-programs
Edric Milaret's avatar
Edric Milaret committed
26 27 28

#enable muxers/demuxers
FFMPEGCONF += \
29 30
	--enable-demuxers \
	--enable-muxers
Edric Milaret's avatar
Edric Milaret committed
31 32 33

#enable parsers
FFMPEGCONF += \
34 35 36 37
	--enable-parser=h263 \
	--enable-parser=h264 \
	--enable-parser=mpeg4video \
	--enable-parser=vp8
Edric Milaret's avatar
Edric Milaret committed
38 39 40

#encoders/decoders
FFMPEGCONF += \
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
	--enable-encoder=adpcm_g722 \
	--enable-decoder=adpcm_g722 \
	--enable-encoder=rawvideo \
	--enable-decoder=rawvideo \
	--enable-encoder=libx264 \
	--enable-decoder=h264 \
	--enable-encoder=pcm_alaw \
	--enable-decoder=pcm_alaw \
	--enable-encoder=pcm_mulaw \
	--enable-decoder=pcm_mulaw \
	--enable-encoder=mpeg4 \
	--enable-decoder=mpeg4 \
	--enable-encoder=libvpx_vp8 \
	--enable-decoder=vp8 \
	--enable-encoder=h263 \
	--enable-encoder=h263p \
	--enable-decoder=h263 \
	--enable-encoder=mjpeg \
	--enable-decoder=mjpeg \
	--enable-decoder=mjpegb \
	--enable-libspeex \
	--enable-libopus \
	--enable-libvpx \
	--enable-encoder=libspeex \
	--enable-decoder=libspeex \
	--enable-encoder=libopus \
	--enable-decoder=libopus
Edric Milaret's avatar
Edric Milaret committed
68

69 70
#encoders/decoders for images
FFMPEGCONF += \
71 72 73 74 75 76 77 78 79 80 81 82 83 84
	--enable-encoder=gif \
	--enable-decoder=gif \
	--enable-encoder=jpegls \
	--enable-decoder=jpegls \
	--enable-encoder=ljpeg \
	--enable-decoder=jpeg2000 \
	--enable-encoder=png \
	--enable-decoder=png \
	--enable-encoder=bmp \
	--enable-decoder=bmp \
	--enable-encoder=tiff \
	--enable-decoder=tiff

#platform specific options
Alexandre Lision's avatar
Alexandre Lision committed
85

86
ifdef HAVE_WIN32
Edric Milaret's avatar
Edric Milaret committed
87 88
FFMPEGCONF += \
	--enable-indev=dshow \
89
	--enable-indev=gdigrab \
Edric Milaret's avatar
Edric Milaret committed
90
	--enable-dxva2
91
endif
Edric Milaret's avatar
Edric Milaret committed
92

Philippe Gorley's avatar
Philippe Gorley committed
93
ifdef HAVE_LINUX
94 95 96 97 98 99
FFMPEGCONF += --enable-pic
FFMPEGCONF += --extra-cxxflags=-fPIC --extra-cflags=-fPIC
ifdef HAVE_ANDROID
# Android Linux
FFMPEGCONF += \
	--target-os=android \
100
	--enable-jni \
101 102
	--enable-mediacodec \
	--enable-hwaccel=vp8_mediacodec \
103
	--enable-hwaccel=h264_mediacodec \
104 105
	--enable-hwaccel=mpeg4_mediacodec \
	--enable-decoder=vp8_mediacodec \
106
	--enable-decoder=h264_mediacodec \
107 108 109 110 111
	--enable-decoder=mpeg4_mediacodec
# ASM not working on Android x86 https://trac.ffmpeg.org/ticket/4928
ifeq ($(ARCH),i386)
FFMPEGCONF += --disable-asm
endif
112 113 114
ifeq ($(ARCH),x86_64)
FFMPEGCONF += --disable-asm
endif
115 116
else
# Desktop Linux
Philippe Gorley's avatar
Philippe Gorley committed
117
FFMPEGCONF += \
118 119 120
	--target-os=linux \
	--enable-indev=v4l2 \
	--enable-indev=xcbgrab \
121 122 123
	--enable-vdpau \
	--enable-hwaccel=h264_vdpau \
	--enable-hwaccel=mpeg4_vdpau \
Philippe Gorley's avatar
Philippe Gorley committed
124 125 126 127 128
	--enable-vaapi \
	--enable-hwaccel=h264_vaapi \
	--enable-hwaccel=mpeg4_vaapi \
	--enable-hwaccel=h263_vaapi
endif
129
endif
Philippe Gorley's avatar
Philippe Gorley committed
130

131 132
ifndef HAVE_ANDROID
FFMPEGCONF += --enable-libx264
133
DEPS_ffmpeg += x264
134 135
endif

Philippe Gorley's avatar
Philippe Gorley committed
136 137
ifdef HAVE_MACOSX
FFMPEGCONF += \
Philippe Gorley's avatar
Philippe Gorley committed
138
	--enable-avfoundation \
139
	--enable-indev=avfoundation \
140 141 142
	--enable-videotoolbox \
	--enable-hwaccel=h263_videotoolbox \
	--enable-hwaccel=h264_videotoolbox \
Philippe Gorley's avatar
Philippe Gorley committed
143
	--enable-hwaccel=mpeg4_videotoolbox
Philippe Gorley's avatar
Philippe Gorley committed
144
endif
Edric Milaret's avatar
Edric Milaret committed
145

146 147 148 149 150
ifdef HAVE_IOS
FFMPEGCONF += \
	--target-os=darwin \
	--enable-cross-compile \
	--arch=$(ARCH) \
Philippe Gorley's avatar
Philippe Gorley committed
151
	--enable-pic
152 153
endif

154
ifndef HAVE_IOS
Edric Milaret's avatar
Edric Milaret committed
155 156 157
ifdef HAVE_CROSS_COMPILE
FFMPEGCONF += --cross-prefix=$(HOST)-
endif
158
endif
Edric Milaret's avatar
Edric Milaret committed
159 160 161 162 163 164 165 166 167 168

# x86 stuff
ifeq ($(ARCH),i386)
FFMPEGCONF += --arch=x86
endif

ifeq ($(ARCH),x86_64)
FFMPEGCONF += --arch=x86_64
endif

169 170 171 172 173 174 175
# ARM stuff
ifeq ($(ARCH),arm)
FFMPEGCONF += --arch=arm
ifdef HAVE_ARMV7A
FFMPEGCONF += --cpu=cortex-a8
endif
ifdef HAVE_ARMV6
176
FFMPEGCONF += --cpu=armv6 --disable-neon
177 178 179 180 181 182 183
endif
endif

# ARM64 stuff
ifeq ($(ARCH),aarch64)
FFMPEGCONF += --arch=aarch64
endif
Adrien Béraud's avatar
Adrien Béraud committed
184 185 186
ifeq ($(ARCH),arm64)
FFMPEGCONF += --arch=aarch64
endif
187

Edric Milaret's avatar
Edric Milaret committed
188 189
# Windows
ifdef HAVE_WIN32
190
FFMPEGCONF += --target-os=mingw32
Edric Milaret's avatar
Edric Milaret committed
191 192 193
FFMPEGCONF += --enable-w32threads --disable-decoder=dca
endif

194
$(TARBALLS)/ffmpeg-$(FFMPEG_HASH).tar.gz:
195
	$(call download,$(FFMPEG_URL))
Edric Milaret's avatar
Edric Milaret committed
196

197
.sum-ffmpeg: ffmpeg-$(FFMPEG_HASH).tar.gz
Edric Milaret's avatar
Edric Milaret committed
198

199
ffmpeg: ffmpeg-$(FFMPEG_HASH).tar.gz
Edric Milaret's avatar
Edric Milaret committed
200 201
	rm -Rf $@ $@-$(FFMPEG_HASH)
	mkdir -p $@-$(FFMPEG_HASH)
202
	(cd $@-$(FFMPEG_HASH) && tar x $(if ${BATCH_MODE},,-v) --strip-components=1 -f ../$<)
Edric Milaret's avatar
Edric Milaret committed
203
	$(UPDATE_AUTOCONFIG)
Philippe Gorley's avatar
Philippe Gorley committed
204 205
ifdef HAVE_ANDROID
ifeq ($(ARCH),arm)
206
	$(APPLY) $(SRC)/ffmpeg/android_file_offset.patch
Philippe Gorley's avatar
Philippe Gorley committed
207 208
endif
ifeq ($(ARCH),i386)
209
	$(APPLY) $(SRC)/ffmpeg/android_file_offset.patch
Philippe Gorley's avatar
Philippe Gorley committed
210
endif
211
endif
Edric Milaret's avatar
Edric Milaret committed
212 213
	$(MOVE)

214
.ffmpeg: ffmpeg .sum-ffmpeg
Edric Milaret's avatar
Edric Milaret committed
215
	cd $< && $(HOSTVARS) ./configure \
216
		--extra-cflags="$(CFLAGS)" \
Edric Milaret's avatar
Edric Milaret committed
217
		--extra-ldflags="$(LDFLAGS)" $(FFMPEGCONF) \
218
		--prefix="$(PREFIX)" --enable-static --disable-shared
Edric Milaret's avatar
Edric Milaret committed
219 220
	cd $< && $(MAKE) install-libs install-headers
	touch $@