f87401444dc7ecbc4ff1bd51abf8093803253303
[feed/packages.git] / multimedia / ffmpeg / Makefile
1 #
2 # Copyright (C) 2006-2017 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7
8 include $(TOPDIR)/rules.mk
9
10 PKG_NAME:=ffmpeg
11 PKG_VERSION:=3.2.2
12 PKG_RELEASE:=1
13
14 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
15 PKG_SOURCE_URL:=https://ffmpeg.org/releases/
16 PKG_MD5SUM:=e34d1b92c5d844f2a3611c741a6dba18
17 PKG_HASH:=3f01bd1fe1a17a277f8c84869e5d9192b4b978cb660872aa2b54c3cc8a2fedfc
18 PKG_MAINTAINER:=Ted Hess <thess@kitschensync.net>
19
20 PKG_LICENSE:=LGPL-2.1+ GPL-2+ LGPL-3
21 PKG_LICENSE_FILES:=COPYING.GPLv2 COPYING.GPLv3 COPYING.LGPLv2.1 COPYING.LGPLv3
22
23 FFMPEG_CUSTOM_ENCODERS:= \
24 ac3 \
25 jpegls \
26 mpeg1video \
27 mpeg2video \
28 mpeg4 \
29 pcm_s16be \
30 pcm_s16le \
31 png \
32 vorbis \
33 zlib \
34
35 FFMPEG_CUSTOM_DECODERS:= \
36 aac \
37 ac3 \
38 alac \
39 amrnb \
40 amrwb \
41 ape \
42 atrac3 \
43 flac \
44 gif \
45 h264 \
46 hevc \
47 jpegls \
48 mp2 \
49 mp3 \
50 mpeg1video \
51 mpeg2video \
52 mpeg4 \
53 mpegvideo \
54 mpc7 \
55 mpc8 \
56 pcm_s16be \
57 pcm_s16le \
58 png \
59 vc1 \
60 vorbis \
61 wavpack \
62 wmav1 \
63 wmav2 \
64 zlib \
65
66 FFMPEG_CUSTOM_MUXERS:= \
67 ac3 \
68 ffm \
69 h264 \
70 hevc \
71 mp3 \
72 mp4 \
73 mpeg1video \
74 mpeg2video \
75 mpegts \
76 ogg \
77 rtp \
78
79 FFMPEG_CUSTOM_DEMUXERS:= \
80 aac \
81 ac3 \
82 amr \
83 ape \
84 avi \
85 flac \
86 ffm \
87 h264 \
88 hevc \
89 matroska \
90 mov \
91 mp3 \
92 mpegps \
93 mpegts \
94 mpegvideo \
95 mpc \
96 mpc8 \
97 ogg \
98 rm \
99 rtsp \
100 rtp \
101 sdp \
102 v4l2 \
103 vc1 \
104 wav \
105 wv \
106
107 FFMPEG_CUSTOM_PARSERS:= \
108 aac \
109 flac \
110 ac3 \
111 h264 \
112 hevc \
113 mpegaudio \
114 mpeg4video \
115 mpegvideo \
116 vc1 \
117
118 FFMPEG_CUSTOM_PROTOCOLS:= \
119 file http icecast pipe rtp tcp udp
120
121 FFMPEG_MINI_DECODERS:= \
122 aac \
123 ac3 \
124 flac \
125 h264 \
126 hevc \
127 jpegls \
128 mp3 \
129 mpeg1video \
130 mpeg2video \
131 mpeg4 \
132 mpegvideo \
133 opus \
134 png \
135 vc1 \
136 vorbis \
137 wmav1 \
138 wmav2 \
139
140 FFMPEG_MINI_DEMUXERS:= \
141 avi \
142 flac \
143 matroska \
144 mov \
145 mp3 \
146 mpegts \
147 mpegvideo \
148 ogg \
149
150 FFMPEG_MINI_PROTOCOLS:= \
151 file \
152
153 FFMPEG_AUDIO_DECODERS:= \
154 aac \
155 aac_latm \
156 ac3 \
157 adpcm_* \
158 alac \
159 amrnb \
160 amrwb \
161 ape \
162 atrac3 \
163 flac \
164 mp2 \
165 mp3* \
166 mpc7 \
167 mpc8 \
168 opus \
169 pcm_* \
170 vorbis \
171 wavpack \
172 wmav1 \
173 wmav2 \
174 wmalossless \
175 wmapro \
176 zlib \
177
178 FFMPEG_AUDIO_DEMUXERS:= \
179 aac \
180 ac3 \
181 aiff \
182 amr \
183 ape \
184 avi \
185 flac \
186 ffm \
187 matroska \
188 mp3 \
189 mov \
190 mpc \
191 mpc8 \
192 mpegts \
193 ogg \
194 rm \
195 rtsp \
196 rtp \
197 sdp \
198 wav \
199 wv \
200
201 FFMPEG_AUDIO_PARSERS:= \
202 aac \
203 aac_latm \
204 ac3 \
205 flac \
206 mpegaudio \
207 opus \
208
209 FFMPEG_AUDIO_PROTOCOLS:= \
210 file http icecast rtp tcp udp
211
212
213 PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
214
215 PKG_CONFIG_DEPENDS:= \
216 $(patsubst %,CONFIG_FFMPEG_CUSTOM_ENCODER_%,$(FFMPEG_CUSTOM_ENCODERS)) \
217 $(patsubst %,CONFIG_FFMPEG_CUSTOM_DECODER_%,$(FFMPEG_CUSTOM_DECODERS)) \
218 $(patsubst %,CONFIG_FFMPEG_CUSTOM_MUXER_%,$(FFMPEG_CUSTOM_DEMUXERS)) \
219 $(patsubst %,CONFIG_FFMPEG_CUSTOM_DEMUXER_%,$(FFMPEG_CUSTOM_DEMUXERS)) \
220 $(patsubst %,CONFIG_FFMPEG_CUSTOM_PARSER_%,$(FFMPEG_CUSTOM_PARSERS)) \
221 $(patsubst %,CONFIG_FFMPEG_CUSTOM_PROTOCOL_%,$(FFMPEG_CUSTOM_PROTOCOLS))
222
223 include $(INCLUDE_DIR)/package.mk
224
225 define Package/ffmpeg/Default
226 TITLE:=FFmpeg
227 URL:=http://ffmpeg.mplayerhq.hu/
228 endef
229
230 define Package/ffmpeg/Default/description
231 FFmpeg is a a software package that can record, convert and stream digital
232 audio and video in numerous formats.
233 endef
234
235
236 define Package/ffmpeg
237 $(call Package/ffmpeg/Default)
238 SECTION:=multimedia
239 CATEGORY:=Multimedia
240 TITLE+= program
241 DEPENDS+= +libpthread +libffmpeg-full
242 VARIANT:=full
243 endef
244
245 define Package/ffmpeg/description
246 $(call Package/ffmpeg/Default/description)
247 .
248 This package contains the FFmpeg command line tool.
249 endef
250
251
252 define Package/ffprobe
253 $(call Package/ffmpeg/Default)
254 SECTION:=multimedia
255 CATEGORY:=Multimedia
256 TITLE+= CLI media identifier
257 DEPENDS+= +libffmpeg-full
258 VARIANT:=full
259 endef
260
261 define Package/ffprobe/description
262 $(call Package/ffmpeg/Default/description)
263 .
264 This package contains the FFprobe command line tool.
265 endef
266
267
268 define Package/ffserver
269 $(call Package/ffserver/Default)
270 SECTION:=multimedia
271 CATEGORY:=Multimedia
272 TITLE+= streaming server
273 DEPENDS+= +libpthread +libffmpeg-full
274 VARIANT:=full
275 endef
276
277 define Package/ffserver/description
278 $(call Package/ffmpeg/Default/description)
279 .
280 This package contains the FFmpeg streaming server.
281 endef
282
283 define Package/libffmpeg/Default
284 $(call Package/ffmpeg/Default)
285 SECTION:=libs
286 CATEGORY:=Libraries
287 TITLE+= libraries
288 DEPENDS+= @BUILD_PATENTED +libpthread +zlib +libbz2
289 PROVIDES:= libffmpeg
290 endef
291
292
293 define Package/libffmpeg-custom
294 $(call Package/libffmpeg/Default)
295 TITLE+= (custom)
296 DEPENDS+= +FFMPEG_CUSTOM_SELECT_libopus:libopus \
297 +PACKAGE_libx264:libx264 +PACKAGE_lame-lib:lame-lib
298
299 VARIANT:=custom
300 MENU:=1
301 endef
302
303 define Package/libffmpeg-custom/config
304 source "$(SOURCE)/Config.in"
305 endef
306
307 define Package/libffmpeg-custom/description
308 $(call Package/ffmpeg/Default/description)
309 .
310 This package contains customized FFmpeg shared libraries.
311 endef
312
313
314 define Package/libffmpeg-audio-dec
315 $(call Package/libffmpeg/Default)
316 TITLE+= (audio)
317 VARIANT:=audio-dec
318 endef
319
320 define Package/libffmpeg-audio-dec/description
321 $(call Package/ffmpeg/Default/description)
322 .
323 This package contains FFmpeg shared libraries for audio decoding
324 endef
325
326
327 define Package/libffmpeg-full
328 $(call Package/libffmpeg/Default)
329 TITLE+= (full)
330 DEPENDS+= +alsa-lib +PACKAGE_libx264:libx264 +PACKAGE_lame-lib:lame-lib +libopus
331 VARIANT:=full
332 endef
333
334 define Package/libffmpeg-full/description
335 $(call Package/ffmpeg/Default/description)
336 .
337 This package contains full-featured FFmpeg shared libraries.
338 endef
339
340
341 define Package/libffmpeg-mini
342 $(call Package/libffmpeg/Default)
343 TITLE+= (mini)
344 VARIANT:=mini
345 endef
346
347 define Package/libffmpeg-mini/description
348 $(call Package/ffmpeg/Default/description)
349 .
350 This package contains minimal-featured FFmpeg shared libraries.
351 endef
352
353
354 FFMPEG_CONFIGURE:= \
355 CFLAGS="$(TARGET_CFLAGS) $(TARGET_CPPFLAGS) $(FPIC)" \
356 LDFLAGS="$(TARGET_LDFLAGS)" \
357 ./configure \
358 --enable-cross-compile \
359 --cross-prefix="$(TARGET_CROSS)" \
360 --arch="$(ARCH)" \
361 --target-os=linux \
362 --prefix="/usr" \
363 --pkg-config="pkg-config" \
364 --enable-shared \
365 --enable-static \
366 --enable-small \
367 --enable-pthreads \
368 --enable-zlib \
369 --disable-doc \
370 --disable-debug \
371 \
372 --enable-gpl \
373 --enable-version3 \
374 \
375 --disable-dxva2 \
376 --disable-lzma \
377 --disable-vaapi \
378 --disable-vda \
379 --disable-vdpau \
380 --disable-outdevs
381
382 ifeq ($(CONFIG_SOFT_FLOAT),y)
383 FFMPEG_CONFIGURE += \
384 --disable-altivec \
385 --disable-vsx \
386 --disable-power8 \
387 --disable-amd3dnow \
388 --disable-amd3dnowext \
389 --disable-mmx \
390 --disable-mmxext \
391 --disable-sse \
392 --disable-sse2 \
393 --disable-sse3 \
394 --disable-ssse3 \
395 --disable-sse4 \
396 --disable-sse42 \
397 --disable-avx \
398 --disable-xop \
399 --disable-fma3 \
400 --disable-fma4 \
401 --disable-avx2 \
402 --disable-aesni \
403 --disable-armv5te \
404 --disable-armv6 \
405 --disable-armv6t2 \
406 --disable-inline-asm \
407 --disable-mipsdsp \
408 --disable-mipsdspr2 \
409 --disable-mipsfpu \
410 --disable-msa \
411 --disable-mmi \
412 --disable-fast-unaligned \
413 --disable-runtime-cpudetect
414
415 else ifneq ($(findstring arm,$(CONFIG_ARCH)),)
416 FFMPEG_CONFIGURE += \
417 --disable-runtime-cpudetect
418 else ifneq ($(findstring powerpc,$(CONFIG_ARCH)),)
419 FFMPEG_CONFIGURE += \
420 --disable-altivec
421 endif
422
423 ifneq ($(CONFIG_YASM),y)
424 FFMPEG_CONFIGURE += \
425 --disable-yasm
426
427 endif
428
429 #selectibly disable optimizations according to arch/cpu type
430 ifneq ($(findstring arm,$(CONFIG_ARCH)),)
431 ifeq (,$(findstring vfp,$(CONFIG_TARGET_OPTIMIZATION)))
432 FFMPEG_CONFIGURE+= \
433 --disable-vfp
434 endif
435 ifeq (,$(findstring neon,$(CONFIG_TARGET_OPTIMIZATION)))
436 FFMPEG_CONFIGURE+= \
437 --disable-neon
438 endif
439
440 endif
441
442 ifeq ($(BUILD_VARIANT),full)
443 FFMPEG_CONFIGURE+= \
444 --enable-libopus --enable-decoder=libopus \
445 $(if $(CONFIG_PACKAGE_libx264),--enable-libx264) \
446 $(if $(CONFIG_PACKAGE_lame-lib),--enable-libmp3lame)
447 endif
448
449 ifeq ($(BUILD_VARIANT),custom)
450
451 FFMPEG_ENABLE= \
452 $(foreach c, $(2), \
453 $(if $($(3)_$(c)),--enable-$(1)="$(c)") \
454 )
455
456 FFMPEG_CONFIGURE+= \
457 --disable-programs \
458 --disable-avfilter \
459 --disable-postproc \
460 --disable-swresample \
461 --disable-swscale \
462 --disable-everything \
463 $(call FFMPEG_ENABLE,encoder,$(FFMPEG_CUSTOM_ENCODERS),CONFIG_FFMPEG_CUSTOM_ENCODER) \
464 $(call FFMPEG_ENABLE,decoder,$(FFMPEG_CUSTOM_DECODERS),CONFIG_FFMPEG_CUSTOM_DECODER) \
465 $(call FFMPEG_ENABLE,muxer,$(FFMPEG_CUSTOM_MUXERS),CONFIG_FFMPEG_CUSTOM_MUXER) \
466 $(call FFMPEG_ENABLE,demuxer,$(FFMPEG_CUSTOM_DEMUXERS),CONFIG_FFMPEG_CUSTOM_DEMUXER) \
467 $(call FFMPEG_ENABLE,parser,$(FFMPEG_CUSTOM_PARSERS),CONFIG_FFMPEG_CUSTOM_PARSER) \
468 $(call FFMPEG_ENABLE,protocol,$(FFMPEG_CUSTOM_PROTOCOLS),CONFIG_FFMPEG_CUSTOM_PROTOCOL) \
469
470 ifeq ($(CONFIG_FFMPEG_CUSTOM_SELECT_adpcm),y)
471 FFMPEG_CONFIGURE+= \
472 --enable-decoder=adpcm_ima_wav \
473 --enable-decoder=adpcm_ima_qt \
474 --enable-decoder=adpcm_ms \
475
476 endif
477
478 ifeq ($(CONFIG_FFMPEG_CUSTOM_SELECT_libopus),y)
479 FFMPEG_CONFIGURE+= \
480 --enable-libopus --enable-decoder=libopus
481 endif
482
483 ifeq ($(CONFIG_FFMPEG_CUSTOM_SELECT_x264),y)
484 FFMPEG_CONFIGURE+= \
485 --enable-libx264
486 endif
487
488 ifeq ($(CONFIG_FFMPEG_CUSTOM_SELECT_mp3lame),y)
489 FFMPEG_CONFIGURE+= \
490 --enable-libmp3lame
491 endif
492
493 endif
494
495 ifeq ($(BUILD_VARIANT),audio-dec)
496
497 FFMPEG_ENABLE= \
498 $(foreach c, $(2), \
499 --enable-$(1)="$(c)" \
500 )
501
502 FFMPEG_CONFIGURE+= \
503 --disable-programs \
504 --disable-avfilter \
505 --disable-postproc \
506 --disable-swresample \
507 --disable-swscale \
508 --disable-everything \
509 $(call FFMPEG_ENABLE,decoder,$(FFMPEG_AUDIO_DECODERS)) \
510 $(call FFMPEG_ENABLE,demuxer,$(FFMPEG_AUDIO_DEMUXERS)) \
511 $(call FFMPEG_ENABLE,parser,$(FFMPEG_AUDIO_PARSERS)) \
512 $(call FFMPEG_ENABLE,protocol,$(FFMPEG_AUDIO_PROTOCOLS)) \
513 --disable-decoder=pcm_bluray,pcm_dvd \
514
515 endif
516
517 ifeq ($(BUILD_VARIANT),mini)
518
519 FFMPEG_ENABLE= \
520 $(foreach c, $(2), \
521 --enable-$(1)="$(c)" \
522 )
523
524 FFMPEG_CONFIGURE+= \
525 --disable-programs \
526 --disable-avdevice \
527 --disable-avfilter \
528 --disable-postproc \
529 --disable-swresample \
530 --disable-swscale \
531 --disable-everything \
532 $(call FFMPEG_ENABLE,decoder,$(FFMPEG_MINI_DECODERS)) \
533 $(call FFMPEG_ENABLE,demuxer,$(FFMPEG_MINI_DEMUXERS)) \
534 $(call FFMPEG_ENABLE,protocol,$(FFMPEG_MINI_PROTOCOLS)) \
535
536 endif
537
538 ifneq ($(CONFIG_TARGET_x86),)
539 TARGET_CFLAGS += -fomit-frame-pointer
540 endif
541
542 define Build/Configure
543 ( cd $(PKG_BUILD_DIR); $(FFMPEG_CONFIGURE) )
544 endef
545
546 define Build/Compile
547 $(MAKE) -C $(PKG_BUILD_DIR) \
548 DESTDIR="$(PKG_INSTALL_DIR)" \
549 all install
550 endef
551
552 define Build/InstallDev/custom
553 $(INSTALL_DIR) $(1)/usr/include
554 $(CP) $(PKG_INSTALL_DIR)/usr/include/lib{avcodec,avdevice,avformat,avutil} $(1)/usr/include/
555 $(INSTALL_DIR) $(1)/usr/lib
556 $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{avcodec,avdevice,avformat,avutil}.{a,so*} $(1)/usr/lib/
557 $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
558 $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/lib{avcodec,avdevice,avformat,avutil}.pc $(1)/usr/lib/pkgconfig/
559 endef
560
561 define Build/InstallDev/full
562 $(INSTALL_DIR) $(1)/usr/include
563 $(CP) $(PKG_INSTALL_DIR)/usr/include/lib{avcodec,avdevice,avfilter,avformat,avutil,postproc,swresample,swscale} $(1)/usr/include/
564 $(INSTALL_DIR) $(1)/usr/lib
565 $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{avcodec,avdevice,avfilter,avformat,avutil,postproc,swresample,swscale}.{a,so*} $(1)/usr/lib/
566 $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
567 $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/lib{avcodec,avdevice,avfilter,avformat,avutil,postproc,swresample,swscale}.pc $(1)/usr/lib/pkgconfig/
568 endef
569
570 define Build/InstallDev/mini
571 $(INSTALL_DIR) $(1)/usr/include
572 $(CP) $(PKG_INSTALL_DIR)/usr/include/lib{avcodec,avformat,avutil} $(1)/usr/include/
573 $(INSTALL_DIR) $(1)/usr/lib
574 $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{avcodec,avformat,avutil}.{a,so*} $(1)/usr/lib/
575 $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
576 $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/lib{avcodec,avformat,avutil}.pc $(1)/usr/lib/pkgconfig/
577 endef
578
579 Build/InstallDev/audio-dec = $(Build/InstallDev/custom)
580
581 # XXX: attempt at installing "best" dev files available
582 ifeq ($(BUILD_VARIANT),custom)
583 # XXX: only install "custom" dev files if -full & -mini are not selected
584 ifeq ($(CONFIG_PACKAGE_libffmpeg-full)$(CONFIG_PACKAGE_libffmpeg-mini),)
585 Build/InstallDev = $(Build/InstallDev/custom)
586 endif
587 endif
588 ifeq ($(BUILD_VARIANT),audio-dec)
589 # XXX: only install "audio-dec" dev files if -full & -mini are not selected
590 ifeq ($(CONFIG_PACKAGE_libffmpeg-full)$(CONFIG_PACKAGE_libffmpeg-mini),)
591 Build/InstallDev = $(Build/InstallDev/audio-dec)
592 endif
593 endif
594 ifeq ($(BUILD_VARIANT),full)
595 # XXX: always install "full" dev files if -full is selected
596 Build/InstallDev = $(Build/InstallDev/full)
597 endif
598 ifeq ($(BUILD_VARIANT),mini)
599 # XXX: only install "mini" dev files if -full is not selected
600 ifeq ($(CONFIG_PACKAGE_libffmpeg-full),)
601 Build/InstallDev = $(Build/InstallDev/mini)
602 endif
603 endif
604
605 define Package/ffmpeg/install
606 $(INSTALL_DIR) $(1)/usr/bin
607 $(CP) $(PKG_INSTALL_DIR)/usr/bin/ffmpeg $(1)/usr/bin/
608 endef
609
610 define Package/ffprobe/install
611 $(INSTALL_DIR) $(1)/usr/bin
612 $(CP) $(PKG_INSTALL_DIR)/usr/bin/ffprobe $(1)/usr/bin/
613 endef
614
615 define Package/ffserver/install
616 $(INSTALL_DIR) $(1)/usr/bin
617 $(CP) $(PKG_INSTALL_DIR)/usr/bin/ffserver $(1)/usr/bin/
618 endef
619
620 define Package/libffmpeg-custom/install
621 $(INSTALL_DIR) $(1)/usr/lib
622 $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{avcodec,avdevice,avformat,avutil}.so.* $(1)/usr/lib/
623 endef
624
625 define Package/libffmpeg-full/install
626 $(INSTALL_DIR) $(1)/usr/lib
627 $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{avcodec,avdevice,avfilter,avformat,avutil,postproc,swresample,swscale}.so.* $(1)/usr/lib/
628 endef
629
630 define Package/libffmpeg-mini/install
631 $(INSTALL_DIR) $(1)/usr/lib
632 $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{avcodec,avformat,avutil}.so.* $(1)/usr/lib/
633 endef
634
635 Package/libffmpeg-audio-dec/install = $(Package/libffmpeg-custom/install)
636
637 $(eval $(call BuildPackage,ffmpeg))
638 $(eval $(call BuildPackage,ffprobe))
639 $(eval $(call BuildPackage,ffserver))
640 $(eval $(call BuildPackage,libffmpeg-audio-dec))
641 $(eval $(call BuildPackage,libffmpeg-full))
642 $(eval $(call BuildPackage,libffmpeg-mini))
643 ifneq ($(CONFIG_ALL),y)
644 $(eval $(call BuildPackage,libffmpeg-custom))
645 endif