rules.mak 4.85 KB
Newer Older
Philippe Gorley's avatar
Philippe Gorley committed
1 2 3
ifndef HAVE_MACOSX
FFMPEG_HASH := 18516d3e695980525bd9758dc7b8a8e36cd3f09e
else
Adrien Béraud's avatar
Adrien Béraud committed
4
FFMPEG_HASH := n3.3.3
Philippe Gorley's avatar
Philippe Gorley committed
5
endif
6
FFMPEG_URL := https://git.ffmpeg.org/gitweb/ffmpeg.git/snapshot/$(FFMPEG_HASH).tar.gz
Edric Milaret's avatar
Edric Milaret committed
7

8
PKGS+=ffmpeg
Philippe Gorley's avatar
Philippe Gorley committed
9

Philippe Gorley's avatar
Philippe Gorley committed
10
ifeq ($(call need_pkg,"libavutil >= 55.75.100 libavcodec >= 57.106.101 libavformat >= 57.82.100 libavdevice >= 57.8.101 libswscale >= 4.7.103"),)
11 12 13 14 15
PKGS_FOUND += ffmpeg
endif

DEPS_ffmpeg = iconv zlib x264 vpx opus speex $(DEPS_vpx)

Edric Milaret's avatar
Edric Milaret committed
16
FFMPEGCONF = \
17 18
	--cc="$(CC)" \
	--pkg-config="$(PKG_CONFIG)"
Edric Milaret's avatar
Edric Milaret committed
19 20 21

#disable everything
FFMPEGCONF += \
22 23 24 25 26
	--disable-everything \
	--enable-zlib \
	--enable-gpl \
	--enable-swscale \
	--enable-protocols \
Philippe Gorley's avatar
Philippe Gorley committed
27
	--disable-programs
Edric Milaret's avatar
Edric Milaret committed
28 29 30

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

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

#encoders/decoders
FFMPEGCONF += \
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 68 69
	--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
70

71 72
#encoders/decoders for images
FFMPEGCONF += \
73 74 75 76 77 78 79 80 81 82 83 84 85 86
	--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
87

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

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

137 138 139 140
ifndef HAVE_ANDROID
FFMPEGCONF += --enable-libx264
endif

Philippe Gorley's avatar
Philippe Gorley committed
141 142
ifdef HAVE_MACOSX
FFMPEGCONF += \
Philippe Gorley's avatar
Philippe Gorley committed
143
	--disable-sdl \
144
	--enable-indev=avfoundation \
145 146 147
	--enable-videotoolbox \
	--enable-hwaccel=h263_videotoolbox \
	--enable-hwaccel=h264_videotoolbox \
Philippe Gorley's avatar
Philippe Gorley committed
148
	--enable-hwaccel=mpeg4_videotoolbox
Philippe Gorley's avatar
Philippe Gorley committed
149
endif
Edric Milaret's avatar
Edric Milaret committed
150

151 152 153 154 155
ifdef HAVE_IOS
FFMPEGCONF += \
	--target-os=darwin \
	--enable-cross-compile \
	--arch=$(ARCH) \
Philippe Gorley's avatar
Philippe Gorley committed
156
	--enable-pic
157 158
endif

159
ifndef HAVE_IOS
Edric Milaret's avatar
Edric Milaret committed
160 161 162
ifdef HAVE_CROSS_COMPILE
FFMPEGCONF += --cross-prefix=$(HOST)-
endif
163
endif
Edric Milaret's avatar
Edric Milaret committed
164 165 166 167 168 169 170 171 172 173

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

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

174 175 176 177 178 179 180
# ARM stuff
ifeq ($(ARCH),arm)
FFMPEGCONF += --arch=arm
ifdef HAVE_ARMV7A
FFMPEGCONF += --cpu=cortex-a8
endif
ifdef HAVE_ARMV6
181
FFMPEGCONF += --cpu=armv6 --disable-neon
182 183 184 185 186 187 188
endif
endif

# ARM64 stuff
ifeq ($(ARCH),aarch64)
FFMPEGCONF += --arch=aarch64
endif
Adrien Béraud's avatar
Adrien Béraud committed
189 190 191
ifeq ($(ARCH),arm64)
FFMPEGCONF += --arch=aarch64
endif
192

Edric Milaret's avatar
Edric Milaret committed
193 194
# Windows
ifdef HAVE_WIN32
195
FFMPEGCONF += --target-os=mingw32
Edric Milaret's avatar
Edric Milaret committed
196 197 198
FFMPEGCONF += --enable-w32threads --disable-decoder=dca
endif

199
$(TARBALLS)/ffmpeg-$(FFMPEG_HASH).tar.gz:
200
	$(call download,$(FFMPEG_URL))
Edric Milaret's avatar
Edric Milaret committed
201

202
.sum-ffmpeg: ffmpeg-$(FFMPEG_HASH).tar.gz
203
	$(warning $@ is not implemented.)
Edric Milaret's avatar
Edric Milaret committed
204 205
	touch $@

206
ffmpeg: ffmpeg-$(FFMPEG_HASH).tar.gz .sum-ffmpeg
Edric Milaret's avatar
Edric Milaret committed
207 208
	rm -Rf $@ $@-$(FFMPEG_HASH)
	mkdir -p $@-$(FFMPEG_HASH)
209
	(cd $@-$(FFMPEG_HASH) && tar x $(if ${BATCH_MODE},,-v) --strip-components=1 -f ../$<)
Edric Milaret's avatar
Edric Milaret committed
210
	$(UPDATE_AUTOCONFIG)
Philippe Gorley's avatar
Philippe Gorley committed
211 212
ifdef HAVE_ANDROID
ifeq ($(ARCH),arm)
213
	$(APPLY) $(SRC)/ffmpeg/android_file_offset.patch
Philippe Gorley's avatar
Philippe Gorley committed
214 215
endif
ifeq ($(ARCH),i386)
216
	$(APPLY) $(SRC)/ffmpeg/android_file_offset.patch
Philippe Gorley's avatar
Philippe Gorley committed
217
endif
218
endif
Edric Milaret's avatar
Edric Milaret committed
219 220 221 222
	$(MOVE)

.ffmpeg: ffmpeg
	cd $< && $(HOSTVARS) ./configure \
223
		--extra-cflags="$(CFLAGS)" \
Edric Milaret's avatar
Edric Milaret committed
224
		--extra-ldflags="$(LDFLAGS)" $(FFMPEGCONF) \
225
		--prefix="$(PREFIX)" --enable-static --disable-shared
Edric Milaret's avatar
Edric Milaret committed
226 227
	cd $< && $(MAKE) install-libs install-headers
	touch $@