forked from tvheadend/tvheadend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.ffmpeg
409 lines (329 loc) · 11.1 KB
/
Makefile.ffmpeg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
#
# Static Audio/Video libs (ffmpeg version) build
# Copyright (C) 2014 Jaroslav Kysela
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
DIR := $(dir $(lastword $(MAKEFILE_LIST)))
include $(DIR)/.config.mk
unexport CFLAGS
unexport LDFLAGS
# ###########################################################################
# Upstream Packages
# ###########################################################################
FFMPEG = ffmpeg-2.8.5
FFMPEG_TB = $(FFMPEG).tar.bz2
FFMPEG_URL = http://ffmpeg.org/releases/$(FFMPEG_TB)
FFMPEG_SHA1 = 74f82c0bdaada050ada9010ecb574fb02d434c00
FFMPEG_DIFFS =
EXTLIBS = libx264 libvorbis libvpx
COMPONENTS = avutil avformat avcodec swresample swscale avfilter avresample
PROTOCOLS = file
DECODERS = mpeg2video mp2 ac3 eac3 h264 h264_vdpau hevc aac aac_latm vorbis libvorbis
ENCODERS = mpeg2video mp2 libx264 libvpx_vp8 libvpx_vp9 aac libaacplus vorbis libvorbis
MUXERS = mpegts mpeg2dvd matroska webm mp4
BSFS = h264_mp4toannexb hevc_mp4toannexb
FILTERS = yadif scale
LIBOGG = libogg-1.3.2
LIBOGG_TB = $(LIBOGG).tar.gz
LIBOGG_URL = http://downloads.xiph.org/releases/ogg/$(LIBOGG_TB)
LIBOGG_SHA1 = df7f3977bbeda67306bc2a427257dd7375319d7d
LIBVORBIS = libvorbis-1.3.5
LIBVORBIS_TB = $(LIBVORBIS).tar.gz
LIBVORBIS_URL = http://downloads.xiph.org/releases/vorbis/$(LIBVORBIS_TB)
LIBVORBIS_SHA1 = 10c7fee173178d72855aa7593dfe49d9b3d6c804
LIBX264 = x264-snapshot-20160217-2245
LIBX264_TB = $(LIBX264).tar.bz2
LIBX264_URL = http://ftp.via.ecp.fr/pub/videolan/x264/snapshots/$(LIBX264_TB)
LIBX264_SHA1 = e3b9d6f3372c9052fac3bffe7175518bb269a359
LIBX265 = x265_1.9
LIBX265_TB = $(LIBX265).tar.gz
LIBX265_URL = http://ftp.videolan.org/pub/videolan/x265/$(LIBX265_TB)
LIBX265_SHA1 = 8c9aa3b87b0f0a418bbb9782e9354d112d75e003
LIBVPX = libvpx-1.5.0
LIBVPX_TB = $(LIBVPX).tar.bz2
LIBVPX_URL = http://storage.googleapis.com/downloads.webmproject.org/releases/webm/$(LIBVPX_TB)
LIBVPX_SHA1 = 0baf76627eb08450eaf307347d1721f56a880c64
YASM = yasm-1.3.0
YASM_TB = $(YASM).tar.gz
YASM_URL = http://www.tortall.net/projects/yasm/releases/$(YASM_TB)
YASM_SHA1 = b7574e9f0826bedef975d64d3825f75fbaeef55e
LIBMFX_HASH = 8220f463a97b098d9e37bbfa2110b117700d1205
LIBMFX = mfx_dispatch-$(LIBMFX_HASH)
LIBMFX_TB = $(LIBMFX_HASH).tar.gz
LIBMFX_URL = https://github.com/lu-zero/mfx_dispatch/archive/$(LIBMFX_TB)
LIBMFX_SHA1 = e7905a4e18f8d3933f23ed5cf5a96a40a31c76a8
# ###########################################################################
# Library Config
# ###########################################################################
LIB_NAME := ffmpeg
LIB_ROOT := $(BUILDDIR)/$(LIB_NAME)
LIB_FILES :=\
$(LIB_ROOT)/$(FFMPEG)/.tvh_download \
$(LIB_ROOT)/$(FFMPEG)/.tvh_build \
$(LIB_ROOT)/$(LIBOGG)/.tvh_download \
$(LIB_ROOT)/$(LIBOGG)/.tvh_build \
$(LIB_ROOT)/$(LIBVORBIS)/.tvh_download \
$(LIB_ROOT)/$(LIBVORBIS)/.tvh_build \
$(LIB_ROOT)/$(LIBX264)/.tvh_download \
$(LIB_ROOT)/$(LIBX264)/.tvh_build \
$(LIB_ROOT)/$(LIBX265)/.tvh_download \
$(LIB_ROOT)/$(LIBX265)/.tvh_build \
$(LIB_ROOT)/$(LIBVPX)/.tvh_download \
$(LIB_ROOT)/$(LIBVPX)/.tvh_build \
$(LIB_ROOT)/$(YASM)/.tvh_download \
$(LIB_ROOT)/$(YASM)/.tvh_build \
$(LIB_ROOT)/$(LIBMFX)/.tvh_download \
$(LIB_ROOT)/$(LIBMFX)/.tvh_build \
$(LIB_ROOT)/build/ffmpeg/lib/*.a \
$(LIB_ROOT)/build/ffmpeg/include/*
include $(DIR)/Makefile.static
.PHONY: build $(PHONY)
build: $(LIB_ROOT)/$(FFMPEG)/.tvh_build
# ###########################################################################
# Build Rules
# ###########################################################################
export PATH := $(LIB_ROOT)/build/ffmpeg/bin:$(PATH)
ECFLAGS = -I$(LIB_ROOT)/build/ffmpeg/include
ELIBS = -L$(LIB_ROOT)/build/ffmpeg/lib -ldl
EXTRAENV =
CONFIGURE = TVHEADEND_LIBAV_BUILD=$(LIB_ROOT)/build/ffmpeg \
PKG_CONFIG=$(ROOTDIR)/support/pkg-config.ffmpeg ./configure
#
# YASM
#
$(LIB_ROOT)/$(YASM)/.tvh_download:
$(call DOWNLOAD,$(YASM_URL),$(LIB_ROOT)/$(YASM_TB),$(YASM_SHA1))
$(call UNTAR,$(YASM_TB),z)
@touch $@
$(LIB_ROOT)/$(YASM)/.tvh_build: \
$(LIB_ROOT)/$(YASM)/.tvh_download
cd $(LIB_ROOT)/$(YASM) && $(CONFIGURE) \
--prefix=/ffmpeg
DESTDIR=$(LIB_ROOT)/build \
$(MAKE) -C $(LIB_ROOT)/$(YASM) install
@touch $@
#
# VDPAU library
#
ifeq (yes,$(CONFIG_VDPAU))
EXTRAARG += --enable-vdpau
DECODERS += h264_vdpau
endif
#
# NVENC
#
ifeq (yes,$(CONFIG_NVENC))
EXTRAARG += --enable-nvenc --enable-nonfree
ENCODERS += nvenc_h264 nvenc_hevc
endif
#
# MFX Dispatcher (libmfx)
#
ifeq (yes,$(CONFIG_LIBMFX))
EXTLIBS += libmfx
DECODERS += mpeg2_qsv h264_qsv hevc_qsv
ENCODERS += mpeg2_qsv h264_qsv hevc_qsv
ELIBS += -lva
ifeq ($(CONFIG_VA_DRM),yes)
ELIBS += -lva-drm
endif
ifeq ($(CONFIG_VA_X11),yes)
ELIBS += -lva-x11
endif
endif
ifeq (yes,$(CONFIG_LIBMFX_STATIC))
$(LIB_ROOT)/$(LIBMFX)/.tvh_download:
$(call DOWNLOAD,$(LIBMFX_URL),$(LIB_ROOT)/$(LIBMFX_TB),$(LIBMFX_SHA1))
$(call UNTAR,$(LIBMFX_TB),z)
@touch $@
$(LIB_ROOT)/$(LIBMFX)/.tvh_build: \
$(LIB_ROOT)/$(LIBMFX)/.tvh_download
cd $(LIB_ROOT)/$(LIBMFX) && autoreconf -i
cd $(LIB_ROOT)/$(LIBMFX) && ./configure \
--prefix=/ffmpeg \
--enable-static \
--disable-shared
DESTDIR=$(LIB_ROOT)/build \
$(MAKE) -C $(LIB_ROOT)/$(LIBMFX) install
@touch $@
else
LIBMFX_CFLAGS = $(shell $(PKG_CONFIG) --cflags libmfx)
LIBMFX_LIBS = $(shell $(PKG_CONFIG) --libs libmfx)
EXTRAENV += TVHEADEND_LIBMFX_CFLAGS="$(LIBMFX_CFLAGS)" TVHEADEND_LIBMFX_LIBS="$(LIBMFX_LIBS)"
$(LIB_ROOT)/$(LIBMFX)/.tvh_download:
@mkdir -p $(LIB_ROOT)/$(LIBMFX)
@touch $@
$(LIB_ROOT)/$(LIBMFX)/.tvh_build: \
$(LIB_ROOT)/$(LIBMFX)/.tvh_download
@touch $@
endif
#
# libogg & libvorbis
#
$(LIB_ROOT)/$(LIBOGG)/.tvh_download:
$(call DOWNLOAD,$(LIBOGG_URL),$(LIB_ROOT)/$(LIBOGG_TB),$(LIBOGG_SHA1))
$(call UNTAR,$(LIBOGG_TB),z)
@touch $@
$(LIB_ROOT)/$(LIBOGG)/.tvh_build: \
$(LIB_ROOT)/$(YASM)/.tvh_build \
$(LIB_ROOT)/$(LIBOGG)/.tvh_download
cd $(LIB_ROOT)/$(LIBOGG) && $(CONFIGURE) \
--prefix=/ffmpeg \
--enable-static \
--disable-shared
DESTDIR=$(LIB_ROOT)/build \
$(MAKE) -C $(LIB_ROOT)/$(LIBOGG) install
@touch $@
$(LIB_ROOT)/$(LIBVORBIS)/.tvh_download: \
$(LIB_ROOT)/$(LIBOGG)/.tvh_download
$(call DOWNLOAD,$(LIBVORBIS_URL),$(LIB_ROOT)/$(LIBVORBIS_TB),$(LIBVORBIS_SHA1))
$(call UNTAR,$(LIBVORBIS_TB),z)
@touch $@
$(LIB_ROOT)/$(LIBVORBIS)/.tvh_build: \
$(LIB_ROOT)/$(LIBVORBIS)/.tvh_download \
$(LIB_ROOT)/$(YASM)/.tvh_build \
$(LIB_ROOT)/$(LIBOGG)/.tvh_build
cd $(LIB_ROOT)/$(LIBVORBIS) && $(CONFIGURE) \
--prefix=/ffmpeg \
--enable-static \
--disable-shared \
--with-ogg=$(LIB_ROOT)/build/ffmpeg
DESTDIR=$(LIB_ROOT)/build \
$(MAKE) -C $(LIB_ROOT)/$(LIBVORBIS) install
@touch $@
#
# libx264
#
ifneq (yes,$(CONFIG_LIBX264_STATIC))
$(LIB_ROOT)/$(LIBX264)/.tvh_download:
@echo "***** LIBX264 STATIC BUILD IS DISABLED, USING INSTALLED PACKAGE *****"
@mkdir -p $(LIB_ROOT)/$(LIBX264)
@touch $@
$(LIB_ROOT)/$(LIBX264)/.tvh_build: $(LIB_ROOT)/$(LIBX264)/.tvh_download
@touch $@
else
ifneq (,$(DEB_BUILD_GNU_TYPE))
LIBX264_HOST := --host=$(DEB_BUILD_GNU_TYPE)
endif
$(LIB_ROOT)/$(LIBX264)/.tvh_download:
$(call DOWNLOAD,$(LIBX264_URL),$(LIB_ROOT)/$(LIBX264_TB),$(LIBX264_SHA1))
#rm -rf $(LIB_ROOT)/x264-snapshot-*
$(call UNTAR,$(LIBX264_TB),j)
#{ ln -sf $$(basename $(LIB_ROOT)/x264-snapshot-*) $(LIB_ROOT)/$(LIBX264); }
@touch $@
$(LIB_ROOT)/$(LIBX264)/.tvh_build: \
$(LIB_ROOT)/$(LIBX264)/.tvh_download \
$(LIB_ROOT)/$(YASM)/.tvh_build
cd $(LIB_ROOT)/$(LIBX264) && $(CONFIGURE) \
--prefix=/ffmpeg \
--enable-static \
--disable-shared \
--disable-avs \
--disable-swscale \
--disable-lavf \
--disable-ffms \
--disable-gpac \
--disable-lsmash \
$(LIBX264_HOST)
DESTDIR=$(LIB_ROOT)/build \
$(MAKE) -C $(LIB_ROOT)/$(LIBX264) install
@touch $@
endif
#
# libx265
#
ifeq (yes,$(CONFIG_LIBX265))
EXTLIBS += libx265
ENCODERS += libx265
endif
ifeq (yes,$(CONFIG_LIBX265_STATIC))
$(LIB_ROOT)/$(LIBX265)/.tvh_download:
$(call DOWNLOAD,$(LIBX265_URL),$(LIB_ROOT)/$(LIBX265_TB),$(LIBX265_SHA1))
$(call UNTAR,$(LIBX265_TB),z)
@touch $@
$(LIB_ROOT)/$(LIBX265)/.tvh_build: \
$(LIB_ROOT)/$(LIBX265)/.tvh_download \
$(LIB_ROOT)/$(YASM)/.tvh_build
cd $(LIB_ROOT)/$(LIBX265)/build/linux && cmake \
-G "Unix Makefiles" \
-DCMAKE_INSTALL_PREFIX="/ffmpeg" \
-DENABLE_SHARED:bool=off \
../../source
DESTDIR=$(LIB_ROOT)/build \
$(MAKE) -C $(LIB_ROOT)/$(LIBX265)/build/linux install
@touch $@
else
$(LIB_ROOT)/$(LIBX265)/.tvh_download:
@mkdir -p $(LIB_ROOT)/$(LIBX265)
@touch $@
$(LIB_ROOT)/$(LIBX265)/.tvh_build: $(LIB_ROOT)/$(LIBX265)/.tvh_download
@touch $@
endif
#
# libvpx (VP8)
#
$(LIB_ROOT)/$(LIBVPX)/.tvh_download:
@mkdir -p $(LIB_ROOT)
$(call DOWNLOAD,$(LIBVPX_URL),$(LIB_ROOT)/$(LIBVPX_TB),$(LIBVPX_SHA1))
$(call UNTAR,$(LIBVPX_TB),j)
@touch $@
$(LIB_ROOT)/$(LIBVPX)/.tvh_build: \
$(LIB_ROOT)/$(LIBVPX)/.tvh_download \
$(LIB_ROOT)/$(YASM)/.tvh_build
cd $(LIB_ROOT)/$(LIBVPX) && $(CONFIGURE) \
--prefix=/ffmpeg \
--enable-static \
--disable-shared
DIST_DIR=$(LIB_ROOT)/build/ffmpeg \
$(MAKE) -C $(LIB_ROOT)/$(LIBVPX) install
@touch $@
#
# FFMPEG
#
$(LIB_ROOT)/$(FFMPEG)/.tvh_download:
@mkdir -p $(LIB_ROOT)/build
$(call DOWNLOAD,$(FFMPEG_URL),$(LIB_ROOT)/$(FFMPEG_TB),$(FFMPEG_SHA1))
$(call UNTAR,$(FFMPEG_TB),j)
$(call PATCH,$(FFMPEG),$(FFMPEG_DIFFS))
@touch $@
$(LIB_ROOT)/$(FFMPEG)/.tvh_build: \
$(LIB_ROOT)/$(YASM)/.tvh_build \
$(LIB_ROOT)/$(LIBVORBIS)/.tvh_build \
$(LIB_ROOT)/$(LIBX264)/.tvh_build \
$(LIB_ROOT)/$(LIBX265)/.tvh_build \
$(LIB_ROOT)/$(LIBVPX)/.tvh_build \
$(LIB_ROOT)/$(LIBMFX)/.tvh_build \
$(LIB_ROOT)/$(FFMPEG)/.tvh_download
cd $(LIB_ROOT)/$(FFMPEG) && $(EXTRAENV) $(CONFIGURE) \
--prefix=/ffmpeg \
--disable-all \
--enable-static \
--disable-shared \
--enable-gpl \
--extra-cflags="$(ECFLAGS)" \
--extra-libs="$(ELIBS)" \
--pkg-config="$(ROOTDIR)/support/pkg-config.ffmpeg" \
$(EXTRAARG) \
$(foreach extlib,$(EXTLIBS),--enable-$(extlib)) \
$(foreach component,$(COMPONENTS),--enable-$(component)) \
$(foreach protocol,$(PROTOCOLS),--enable-protocol=$(protocol)) \
$(foreach decoder,$(DECODERS),--enable-decoder=$(decoder)) \
$(foreach encoder,$(ENCODERS),--enable-encoder=$(encoder)) \
$(foreach muxer,$(MUXERS),--enable-muxer=$(muxer)) \
$(foreach bsf,$(BSFS),--enable-bsf=$(bsf)) \
$(foreach filter,$(FILTERS),--enable-filter=$(filter))
DESTDIR=$(LIB_ROOT)/build \
$(MAKE) -C $(LIB_ROOT)/$(FFMPEG) install
@touch $@