rules.mak 4.65 KB
Newer Older
1
FFMPEG_HASH := n3.3.1
2
FFMPEG_URL := https://git.ffmpeg.org/gitweb/ffmpeg.git/snapshot/$(FFMPEG_HASH).tar.gz
Edric Milaret's avatar
Edric Milaret committed
3 4 5 6 7

ifdef HAVE_WIN32
PKGS += ffmpeg
endif

Alexandre Lision's avatar
Alexandre Lision committed
8 9 10 11
ifdef HAVE_MACOSX
PKGS += ffmpeg
endif

Philippe Gorley's avatar
Philippe Gorley committed
12 13 14 15
ifdef HAVE_LINUX
PKGS += ffmpeg
endif

16
ifeq ($(call need_pkg,"libavcodec >= 57.89.100 libavformat >= 57.71.100 libswscale >= 4.6.100 libavdevice >= 57.6.100 libavutil >= 55.58.100"),)
17 18 19 20 21
PKGS_FOUND += ffmpeg
endif

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

Edric Milaret's avatar
Edric Milaret committed
22
FFMPEGCONF = \
23 24
	--cc="$(CC)" \
	--pkg-config="$(PKG_CONFIG)"
Edric Milaret's avatar
Edric Milaret committed
25 26 27

#disable everything
FFMPEGCONF += \
28 29 30 31 32 33 34
	--disable-everything \
	--enable-zlib \
	--enable-gpl \
	--enable-swscale \
	--enable-protocols \
	--disable-programs \
	--disable-sdl
Edric Milaret's avatar
Edric Milaret committed
35 36 37

#enable muxers/demuxers
FFMPEGCONF += \
38 39
	--enable-demuxers \
	--enable-muxers
Edric Milaret's avatar
Edric Milaret committed
40 41 42

#enable parsers
FFMPEGCONF += \
43 44 45 46
	--enable-parser=h263 \
	--enable-parser=h264 \
	--enable-parser=mpeg4video \
	--enable-parser=vp8
Edric Milaret's avatar
Edric Milaret committed
47 48 49

#encoders/decoders
FFMPEGCONF += \
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
	--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
77

78 79
#encoders/decoders for images
FFMPEGCONF += \
80 81 82 83 84 85 86 87 88 89 90 91 92 93
	--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
94

95
ifdef HAVE_WIN32
Edric Milaret's avatar
Edric Milaret committed
96 97
FFMPEGCONF += \
	--enable-indev=dshow \
98
	--enable-indev=gdigrab \
Edric Milaret's avatar
Edric Milaret committed
99
	--enable-dxva2
100
endif
Edric Milaret's avatar
Edric Milaret committed
101

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

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

Philippe Gorley's avatar
Philippe Gorley committed
142 143 144 145 146
ifdef HAVE_MACOSX
FFMPEGCONF += \
	--enable-indev=avfcapture \
	--enable-indev=avfgrab
endif
Edric Milaret's avatar
Edric Milaret committed
147

148 149 150 151 152 153
ifdef HAVE_IOS
FFMPEGCONF += \
	--target-os=darwin \
	--enable-cross-compile \
	--arch=$(ARCH) \
	--enable-pic \
154
	--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 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189
# ARM stuff
ifeq ($(ARCH),arm)
FFMPEGCONF += --arch=arm
ifdef HAVE_NEON
FFMPEGCONF += --enable-neon
endif
ifdef HAVE_ARMV7A
FFMPEGCONF += --cpu=cortex-a8
endif
ifdef HAVE_ARMV6
FFMPEGCONF += --cpu=armv6 --disable-neon
endif
endif

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

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

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

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

207
ffmpeg: ffmpeg-$(FFMPEG_HASH).tar.gz .sum-ffmpeg
Edric Milaret's avatar
Edric Milaret committed
208 209
	rm -Rf $@ $@-$(FFMPEG_HASH)
	mkdir -p $@-$(FFMPEG_HASH)
210
	(cd $@-$(FFMPEG_HASH) && tar x $(if ${BATCH_MODE},,-v) --strip-components=1 -f ../$<)
Edric Milaret's avatar
Edric Milaret committed
211
	$(UPDATE_AUTOCONFIG)
212
ifdef HAVE_MACOSX
Alexandre Lision's avatar
Alexandre Lision committed
213 214
	$(APPLY) $(SRC)/ffmpeg/0004-add-avfcapture-device.patch
	$(APPLY) $(SRC)/ffmpeg/0005-add-avfgrab-device.patch
215
endif
Edric Milaret's avatar
Edric Milaret committed
216 217 218 219
	$(MOVE)

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