rules.mak 5 KB
Newer Older
Adrien Béraud's avatar
Adrien Béraud committed
1
FFMPEG_HASH := n3.3.3
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

Adrien Béraud's avatar
Adrien Béraud committed
6
ifeq ($(call need_pkg,"libavutil >= 55.58.100 libavcodec >= 57.89.100 libavformat >= 57.71.100 libavdevice >= 57.6.100 libswscale >= 4.6.100"),)
7 8 9 10 11
PKGS_FOUND += ffmpeg
endif

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

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 \
Adrien Béraud's avatar
Adrien Béraud committed
23 24
	--disable-programs \
	--disable-sdl
Edric Milaret's avatar
Edric Milaret committed
25 26 27

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

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

#encoders/decoders
FFMPEGCONF += \
40 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
	--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
67

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

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

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

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

Philippe Gorley's avatar
Philippe Gorley committed
136 137
ifdef HAVE_MACOSX
FFMPEGCONF += \
Adrien Béraud's avatar
Adrien Béraud committed
138 139
	--enable-indev=avfcapture \
	--enable-indev=avfgrab \
140 141 142
	--enable-videotoolbox \
	--enable-hwaccel=h263_videotoolbox \
	--enable-hwaccel=h264_videotoolbox \
Adrien Béraud's avatar
Adrien Béraud committed
143 144 145
	--enable-hwaccel=mpeg4_videotoolbox \
	--enable-vda \
	--enable-hwaccel=h264_vda
Philippe Gorley's avatar
Philippe Gorley committed
146
endif
Edric Milaret's avatar
Edric Milaret committed
147

148 149 150 151 152
ifdef HAVE_IOS
FFMPEGCONF += \
	--target-os=darwin \
	--enable-cross-compile \
	--arch=$(ARCH) \
Adrien Béraud's avatar
Adrien Béraud committed
153 154
	--enable-pic \
	--enable-indev=avfoundation
155 156
endif

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

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

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

172 173
# ARM stuff
ifeq ($(ARCH),arm)
174 175
# neon causes SIGBUS error on ARM 32 bits
FFMPEGCONF += --disable-neon
176 177 178 179 180
FFMPEGCONF += --arch=arm
ifdef HAVE_ARMV7A
FFMPEGCONF += --cpu=cortex-a8
endif
ifdef HAVE_ARMV6
181
FFMPEGCONF += --cpu=armv6
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)
Adrien Béraud's avatar
Adrien Béraud committed
211 212 213 214
ifdef HAVE_MACOSX
	$(APPLY) $(SRC)/ffmpeg/0004-add-avfcapture-device.patch
	$(APPLY) $(SRC)/ffmpeg/0005-add-avfgrab-device.patch
endif
Philippe Gorley's avatar
Philippe Gorley committed
215 216 217 218 219 220 221
ifdef HAVE_ANDROID
ifeq ($(ARCH),arm)
	$(APPLY) $(SRC)/ffmpeg/0001-use-internal-log2-log2f.patch
endif
ifeq ($(ARCH),i386)
	$(APPLY) $(SRC)/ffmpeg/0001-use-internal-log2-log2f.patch
endif
222
endif
Edric Milaret's avatar
Edric Milaret committed
223 224 225 226
	$(MOVE)

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