rules.mak 4.69 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 x264 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 132 133
ifndef HAVE_ANDROID
FFMPEGCONF += --enable-libx264
endif

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

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

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

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

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

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

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

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

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

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

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

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