rules.mak 4.71 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

Adrien Béraud's avatar
Adrien Béraud committed
6
ifeq ($(call need_pkg,"libavutil >= 55.75.100 libavcodec >= 57.106.101 libavformat >= 57.82.100 libavdevice >= 57.8.101 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 \
Philippe Gorley's avatar
Philippe Gorley committed
24
	--disable-programs
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
	--enable-jni \
100 101
	--enable-mediacodec \
	--enable-hwaccel=vp8_mediacodec \
102
	--enable-hwaccel=h264_mediacodec \
103 104
	--enable-hwaccel=mpeg4_mediacodec \
	--enable-decoder=vp8_mediacodec \
105
	--enable-decoder=h264_mediacodec \
106 107 108 109 110
	--enable-decoder=mpeg4_mediacodec
# ASM not working on Android x86 https://trac.ffmpeg.org/ticket/4928
ifeq ($(ARCH),i386)
FFMPEGCONF += --disable-asm
endif
111 112 113
ifeq ($(ARCH),x86_64)
FFMPEGCONF += --disable-asm
endif
114 115
else
# Desktop Linux
Philippe Gorley's avatar
Philippe Gorley committed
116
FFMPEGCONF += \
117 118 119
	--target-os=linux \
	--enable-indev=v4l2 \
	--enable-indev=xcbgrab \
120 121 122
	--enable-vdpau \
	--enable-hwaccel=h264_vdpau \
	--enable-hwaccel=mpeg4_vdpau \
Philippe Gorley's avatar
Philippe Gorley committed
123 124 125 126 127
	--enable-vaapi \
	--enable-hwaccel=h264_vaapi \
	--enable-hwaccel=mpeg4_vaapi \
	--enable-hwaccel=h263_vaapi
endif
128
endif
Philippe Gorley's avatar
Philippe Gorley committed
129

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

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

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

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

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

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

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

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

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

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

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

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

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