2 # Copyright (C) 2017-2020 Ian Leonard <antonlacon@gmail.com>
3 # Copyright (C) 2018 Ted Hess <thess@kitschensync.net>
5 # This is free software, licensed under the GNU General Public License v2.
6 # See /LICENSE for more information.
9 include $(TOPDIR
)/rules.mk
15 PKG_SOURCE
:=$(PKG_NAME
)-$(PKG_VERSION
).
tar.xz
16 PKG_SOURCE_URL
:=https
://ffmpeg.org
/releases
/
17 PKG_HASH
:=9f0a68fbd74feb4e50dc220bddd59d84626774a53687fb737806ae00e5c6e9e6
18 PKG_MAINTAINER
:=Ted Hess
<thess@kitschensync.net
>, \
19 Ian Leonard
<antonlacon@gmail.com
>
21 PKG_LICENSE
:=LGPL-2.1
-or-later GPL-2.0
-or-later LGPL-3.0
-or-later
22 PKG_LICENSE_FILES
:=COPYING.GPLv2 COPYING.GPLv3 COPYING.LGPLv2.1 COPYING.LGPLv3
23 PKG_CPE_ID
:=cpe
:/a
:ffmpeg
:ffmpeg
27 FFMPEG_CUSTOM_ENCODERS
:= \
39 FFMPEG_CUSTOM_DECODERS
:= \
70 FFMPEG_CUSTOM_MUXERS
:= \
83 FFMPEG_CUSTOM_DEMUXERS
:= \
111 FFMPEG_CUSTOM_PARSERS
:= \
122 FFMPEG_CUSTOM_PROTOCOLS
:= \
123 file http icecast pipe rtp tcp udp
125 FFMPEG_MINI_DECODERS
:= \
139 FFMPEG_PATENTED_MINI_DECODERS
:= \
144 FFMPEG_MINI_DEMUXERS
:= \
155 FFMPEG_MINI_PROTOCOLS
:= \
158 FFMPEG_AUDIO_DECODERS
:= \
177 FFMPEG_AUDIO_DEMUXERS
:= \
199 FFMPEG_AUDIO_PROTOCOLS
:= \
200 file http icecast rtp tcp udp
202 FFMPEG_PATENTED_DECODERS
:= \
208 FFMPEG_PATENTED_MUXERS
:= \
213 FFMPEG_PATENTED_DEMUXERS
:=$(FFMPEG_PATENTED_MUXERS
)
215 FFMPEG_PATENTED_PARSERS
:= \
220 PKG_CONFIG_DEPENDS
:= \
221 $(patsubst %,CONFIG_FFMPEG_CUSTOM_ENCODER_
%,$(FFMPEG_CUSTOM_ENCODERS
)) \
222 $(patsubst %,CONFIG_FFMPEG_CUSTOM_DECODER_
%,$(FFMPEG_CUSTOM_DECODERS
)) \
223 $(patsubst %,CONFIG_FFMPEG_CUSTOM_MUXER_
%,$(FFMPEG_CUSTOM_MUXERS
)) \
224 $(patsubst %,CONFIG_FFMPEG_CUSTOM_DEMUXER_
%,$(FFMPEG_CUSTOM_DEMUXERS
)) \
225 $(patsubst %,CONFIG_FFMPEG_CUSTOM_PARSER_
%,$(FFMPEG_CUSTOM_PARSERS
)) \
226 $(patsubst %,CONFIG_FFMPEG_CUSTOM_PROTOCOL_
%,$(FFMPEG_CUSTOM_PROTOCOLS
))
228 include $(INCLUDE_DIR
)/package.mk
230 define Package
/ffmpeg
/Default
232 URL
:=https
://ffmpeg.org
/
233 DEPENDS
+= +libpthread
236 define Package
/ffmpeg
/Default
/description
237 FFmpeg is a a software package that can record
, convert and stream digital
238 audio and video in numerous formats.
240 FFmpeg licensing
/ patent issues are complex. It is the reponsibility of the
241 user to understand any requirements in this regard with its usage. See
:
242 https
://ffmpeg.org
/legal.html for further information.
246 define Package
/ffmpeg
247 $(call Package
/ffmpeg
/Default
)
251 DEPENDS
+= +libffmpeg-full
255 define Package
/ffmpeg-custom
256 $(call Package
/ffmpeg
/Default
)
259 TITLE
+= program
(custom
)
260 DEPENDS
+= @
!ALL libffmpeg-custom
264 define Package
/ffmpeg
/description
265 $(call Package
/ffmpeg
/Default
/description
)
267 This package contains the FFmpeg command line tool.
270 Package
/ffmpeg-custom
/description
= $(Package
/ffmpeg
/description
)
272 define Package
/ffprobe
273 $(call Package
/ffmpeg
/Default
)
276 TITLE
+= CLI media identifier
277 DEPENDS
+= +libffmpeg-full
281 define Package
/ffprobe-custom
282 $(call Package
/ffmpeg
/Default
)
285 TITLE
+= CLI media identifier
(custom
)
286 DEPENDS
+= @
!ALL libffmpeg-custom
290 define Package
/ffprobe
/description
291 $(call Package
/ffmpeg
/Default
/description
)
293 This package contains the FFprobe command line tool.
296 Package
/ffprobe-custom
/description
= $(Package
/ffprobe
/description
)
298 define Package
/libffmpeg
/Default
299 $(call Package
/ffmpeg
/Default
)
303 DEPENDS
+= +libpthread
+zlib
+libbz2
308 # Package build suppressed when CONFIG_ALL=y
309 define Package
/libffmpeg-custom
310 $(call Package
/libffmpeg
/Default
)
313 +FFMPEG_CUSTOM_SELECT_libopus
:libopus \
314 +PACKAGE_libx264
:libx264
+PACKAGE_lame-lib
:lame-lib \
315 +FFMPEG_CUSTOM_SELECT_libshine
:shine \
316 +PACKAGE_fdk-aac
:fdk-aac
321 define Package
/libffmpeg-custom
/config
322 source
"$(SOURCE)/Config.in"
325 define Package
/libffmpeg-custom
/description
326 $(call Package
/ffmpeg
/Default
/description
)
328 This package contains customized FFmpeg shared libraries.
332 define Package
/libffmpeg-audio-dec
333 $(call Package
/libffmpeg
/Default
)
338 define Package
/libffmpeg-audio-dec
/description
339 $(call Package
/ffmpeg
/Default
/description
)
341 This package contains FFmpeg shared libraries for audio decoding
345 define Package
/libffmpeg-full
346 $(call Package
/libffmpeg
/Default
)
348 DEPENDS
+= +alsa-lib
+libgnutls
+PACKAGE_libopus
:libopus \
350 +!SOFT_FLOAT
:lame-lib \
351 +PACKAGE_libx264
:libx264 \
352 +!PACKAGE_libx264
:fdk-aac
357 define Package
/libffmpeg-full
/description
358 $(call Package
/ffmpeg
/Default
/description
)
360 This package contains full-featured FFmpeg shared libraries.
364 define Package
/libffmpeg-mini
365 $(call Package
/libffmpeg
/Default
)
370 define Package
/libffmpeg-mini
/description
371 $(call Package
/ffmpeg
/Default
/description
)
373 This package contains minimal-featured FFmpeg shared libraries.
377 # Strip off FPU notation
378 REAL_CPU_TYPE
:=$(firstword $(subst +, ,$(CONFIG_CPU_TYPE
)))
379 # Fixup cpu types recogized by ffmpeg configure
380 REAL_CPU_TYPE
:=$(subst octeonplus
,octeon
+,$(REAL_CPU_TYPE
))
383 CFLAGS
="$(TARGET_CFLAGS) $(TARGET_CPPFLAGS) $(FPIC)" \
384 LDFLAGS
="$(TARGET_LDFLAGS)" \
386 --enable-cross-compile \
387 --cross-prefix
="$(TARGET_CROSS)" \
389 $(if
$(REAL_CPU_TYPE
),--cpu
=$(call qstrip
,$(REAL_CPU_TYPE
)),) \
392 --pkg-config
="pkg-config" \
405 ifeq ($(CONFIG_SOFT_FLOAT
),y
)
413 --disable-fast-unaligned \
414 --disable-runtime-cpudetect
416 else ifneq ($(findstring arm
,$(CONFIG_ARCH
))$(findstring aarch64
,$(CONFIG_ARCH
)),)
418 --disable-runtime-cpudetect
419 # XXX: GitHub issue 3320 ppc cpu with fpu but no altivec (WNDR4700)
420 else ifneq ($(findstring powerpc
,$(CONFIG_ARCH
)),)
425 # selectively disable optimizations according to arch/cpu type
426 ifneq ($(findstring arm
,$(CONFIG_ARCH
)),)
427 FFMPEG_CONFIGURE
+= --enable-lto
429 ifneq ($(findstring vfp
,$(CONFIG_CPU_TYPE
)),)
430 FFMPEG_CONFIGURE
+= --enable-vfp
432 FFMPEG_CONFIGURE
+= --disable-vfp
434 ifneq ($(findstring neon
,$(CONFIG_CPU_TYPE
)),)
439 FFMPEG_CONFIGURE
+= --disable-neon
443 ifneq ($(findstring aarch64
,$(CONFIG_ARCH
)),)
450 ifeq ($(ARCH
),x86_64
)
451 FFMPEG_CONFIGURE
+= --enable-lto
454 ifeq ($(CONFIG_FFMPEG_X86ASM
),y
)
455 FFMPEG_CONFIGURE
+= --enable-x86asm
457 FFMPEG_CONFIGURE
+= --disable-x86asm
460 ifeq ($(BUILD_VARIANT
),full
)
464 --disable-
$(1)="$(c)" \
469 $(if
$(CONFIG_BUILD_PATENTED
),, \
470 $(call FFMPEG_DISABLE
,decoder
,$(FFMPEG_PATENTED_DECODERS
)) \
471 $(call FFMPEG_DISABLE
,muxer
,$(FFMPEG_PATENTED_MUXERS
)) \
472 $(call FFMPEG_DISABLE
,demuxer
,$(FFMPEG_PATENTED_DEMUXERS
)) \
473 $(call FFMPEG_DISABLE
,parser
,$(FFMPEG_PATENTED_PARSERS
))) \
474 $(if
$(CONFIG_PACKAGE_libopus
),--enable-libopus
)
475 ifeq ($(CONFIG_SOFT_FLOAT
),y
)
479 $(if
$(CONFIG_PACKAGE_shine
),--enable-libshine
)
481 ifeq ($(ARCH
),x86_64
)
482 FFMPEG_CONFIGURE
+= --enable-hardcoded-tables
484 FFMPEG_CONFIGURE
+= --enable-small
486 FFMPEG_CONFIGURE
+= $(if
$(CONFIG_PACKAGE_lame-lib
),--enable-libmp3lame
)
488 # x264 support and fdk-aac support can't coexist and be distributed.
489 # Prioritize x264 over fdk-aac in default builds (maintain status-quo).
490 ifneq ($(CONFIG_PACKAGE_libx264
),)
495 FFMPEG_CONFIGURE
+= $(if
$(CONFIG_PACKAGE_fdk-aac
),--enable-libfdk-aac
)
499 ifeq ($(BUILD_VARIANT
),custom
)
503 $(if
$($(3)_
$(c
)),--enable-
$(1)="$(c)") \
506 ifeq ($(CONFIG_FFMPEG_CUSTOM_LARGE
),y
)
508 --enable-hardcoded-tables
514 ifeq ($(CONFIG_FFMPEG_CUSTOM_GPL
),y
)
515 FFMPEG_CONFIGURE
+= --enable-gpl
518 ifeq ($(CONFIG_FFMPEG_CUSTOM_GPLV3
),y
)
519 FFMPEG_CONFIGURE
+= --enable-version3
522 ifeq ($(CONFIG_FFMPEG_CUSTOM_NONFREE
),y
)
523 FFMPEG_CONFIGURE
+= --enable-nonfree
526 ifneq ($(CONFIG_FFMPEG_CUSTOM_PROGRAMS
),y
)
535 --disable-everything \
536 $(call FFMPEG_ENABLE
,encoder
,$(FFMPEG_CUSTOM_ENCODERS
),CONFIG_FFMPEG_CUSTOM_ENCODER
) \
537 $(call FFMPEG_ENABLE
,decoder
,$(FFMPEG_CUSTOM_DECODERS
),CONFIG_FFMPEG_CUSTOM_DECODER
) \
538 $(call FFMPEG_ENABLE
,muxer
,$(FFMPEG_CUSTOM_MUXERS
),CONFIG_FFMPEG_CUSTOM_MUXER
) \
539 $(call FFMPEG_ENABLE
,demuxer
,$(FFMPEG_CUSTOM_DEMUXERS
),CONFIG_FFMPEG_CUSTOM_DEMUXER
) \
540 $(call FFMPEG_ENABLE
,parser
,$(FFMPEG_CUSTOM_PARSERS
),CONFIG_FFMPEG_CUSTOM_PARSER
) \
541 $(call FFMPEG_ENABLE
,protocol
,$(FFMPEG_CUSTOM_PROTOCOLS
),CONFIG_FFMPEG_CUSTOM_PROTOCOL
) \
543 ifeq ($(CONFIG_FFMPEG_CUSTOM_SELECT_adpcm
),y
)
545 --enable-decoder
=adpcm_ima_wav \
546 --enable-decoder
=adpcm_ima_qt \
547 --enable-decoder
=adpcm_ms
550 ifeq ($(CONFIG_FFMPEG_CUSTOM_SELECT_libfdk-aac
),y
)
552 --enable-libfdk-aac
--enable-encoder
=libfdk_aac
555 ifeq ($(CONFIG_FFMPEG_CUSTOM_SELECT_libmp3lame
),y
)
557 --enable-libmp3lame
--enable-encoder
=libmp3lame
560 ifeq ($(CONFIG_FFMPEG_CUSTOM_SELECT_libopus
),y
)
562 --enable-libopus
--enable-decoder
=libopus
--enable-encoder
=libopus
565 ifeq ($(CONFIG_FFMPEG_CUSTOM_SELECT_libshine
),y
)
567 --enable-libshine
--enable-encoder
=libshine
570 ifeq ($(CONFIG_FFMPEG_CUSTOM_SELECT_libx264
),y
)
572 --enable-libx264
--enable-encoder
=libx264
574 FFMPEG_CONFIGURE
+= --disable-postproc
579 ifeq ($(BUILD_VARIANT
),audio-dec
)
583 --enable-
$(1)="$(c)" \
593 --disable-swresample \
595 --disable-everything \
596 $(call FFMPEG_ENABLE
,decoder
,$(FFMPEG_AUDIO_DECODERS
)) \
597 $(call FFMPEG_ENABLE
,demuxer
,$(FFMPEG_AUDIO_DEMUXERS
)) \
598 $(call FFMPEG_ENABLE
,protocol
,$(FFMPEG_AUDIO_PROTOCOLS
)) \
599 --disable-decoder
=pcm_bluray
,pcm_dvd
602 ifeq ($(BUILD_VARIANT
),mini
)
606 --enable-
$(1)="$(c)" \
616 --disable-swresample \
618 --disable-everything \
619 $(call FFMPEG_ENABLE
,decoder
,$(FFMPEG_MINI_DECODERS
)) \
620 $(call FFMPEG_ENABLE
,demuxer
,$(FFMPEG_MINI_DEMUXERS
)) \
621 $(call FFMPEG_ENABLE
,protocol
,$(FFMPEG_MINI_PROTOCOLS
)) \
622 $(if
$(CONFIG_BUILD_PATENTED
), \
623 $(call FFMPEG_ENABLE
,decoder
,$(FFMPEG_PATENTED_MINI_DECODERS
)))
626 ifneq ($(CONFIG_TARGET_x86
),)
627 TARGET_CFLAGS
+= -fomit-frame-pointer
630 define Build
/Configure
631 ( cd
$(PKG_BUILD_DIR
); $(FFMPEG_CONFIGURE
) )
635 +$(MAKE
) $(PKG_JOBS
) -C
$(PKG_BUILD_DIR
) \
636 DESTDIR
="$(PKG_INSTALL_DIR)" \
640 define Build
/InstallDev
/custom
641 $(INSTALL_DIR
) $(1)/usr
/include
642 $(CP
) $(PKG_INSTALL_DIR
)/usr
/include/lib
{avcodec
,avdevice
,avformat
,avutil
} $(1)/usr
/include/
643 $(INSTALL_DIR
) $(1)/usr
/lib
644 $(CP
) $(PKG_INSTALL_DIR
)/usr
/lib
/lib
{avcodec
,avdevice
,avformat
,avutil
}.
{a
,so
*} $(1)/usr
/lib
/
645 ifeq ($(CONFIG_FFMPEG_CUSTOM_PROGRAMS
),y
)
646 $(CP
) $(PKG_INSTALL_DIR
)/usr
/lib
/lib
{avfilter
,swresample
}.
{a
,so
*} $(1)/usr
/lib
/
648 $(INSTALL_DIR
) $(1)/usr
/lib
/pkgconfig
649 $(CP
) $(PKG_INSTALL_DIR
)/usr
/lib
/pkgconfig
/lib
{avcodec
,avdevice
,avformat
,avutil
}.
pc $(1)/usr
/lib
/pkgconfig
/
650 ifeq ($(CONFIG_FFMPEG_CUSTOM_SELECT_libx264
),y
)
651 $(CP
) $(PKG_INSTALL_DIR
)/usr
/include/libpostproc
$(1)/usr
/include/
652 $(CP
) $(PKG_INSTALL_DIR
)/usr
/lib
/libpostproc.
{a
,so
*} $(1)/usr
/lib
/
653 $(CP
) $(PKG_INSTALL_DIR
)/usr
/lib
/pkgconfig
/libpostproc.
pc $(1)/usr
/lib
/pkgconfig
/
657 # Only ffmpeg with libx264 is GPL (yes libpostproc); all other builds are lgpl (no libpostproc)
658 define Build
/InstallDev
/full
659 $(INSTALL_DIR
) $(1)/usr
/include
660 $(INSTALL_DIR
) $(1)/usr
/lib
661 $(INSTALL_DIR
) $(1)/usr
/lib
/pkgconfig
662 $(CP
) $(PKG_INSTALL_DIR
)/usr
/include/lib
{avcodec
,avdevice
,avfilter
,avformat
,avutil
,swresample
,swscale
} $(1)/usr
/include/
663 $(CP
) $(PKG_INSTALL_DIR
)/usr
/lib
/lib
{avcodec
,avdevice
,avfilter
,avformat
,avutil
,swresample
,swscale
}.
{a
,so
*} $(1)/usr
/lib
/
664 $(CP
) $(PKG_INSTALL_DIR
)/usr
/lib
/pkgconfig
/lib
{avcodec
,avdevice
,avfilter
,avformat
,avutil
,swresample
,swscale
}.
pc $(1)/usr
/lib
/pkgconfig
/
665 ifneq ($(CONFIG_PACKAGE_libx264
),)
666 $(CP
) $(PKG_INSTALL_DIR
)/usr
/include/libpostproc
$(1)/usr
/include/
667 $(CP
) $(PKG_INSTALL_DIR
)/usr
/lib
/libpostproc.
{a
,so
*} $(1)/usr
/lib
/
668 $(CP
) $(PKG_INSTALL_DIR
)/usr
/lib
/pkgconfig
/libpostproc.
pc $(1)/usr
/lib
/pkgconfig
/
672 define Build
/InstallDev
/mini
673 $(INSTALL_DIR
) $(1)/usr
/include
674 $(CP
) $(PKG_INSTALL_DIR
)/usr
/include/lib
{avcodec
,avformat
,avutil
} $(1)/usr
/include/
675 $(INSTALL_DIR
) $(1)/usr
/lib
676 $(CP
) $(PKG_INSTALL_DIR
)/usr
/lib
/lib
{avcodec
,avformat
,avutil
}.
{a
,so
*} $(1)/usr
/lib
/
677 $(INSTALL_DIR
) $(1)/usr
/lib
/pkgconfig
678 $(CP
) $(PKG_INSTALL_DIR
)/usr
/lib
/pkgconfig
/lib
{avcodec
,avformat
,avutil
}.
pc $(1)/usr
/lib
/pkgconfig
/
681 Build
/InstallDev
/audio-dec
= $(Build
/InstallDev
/custom
)
683 # XXX: attempt at installing "best" dev files available
684 ifeq ($(BUILD_VARIANT
),custom
)
685 # XXX: only install "custom" dev files if -full & -mini are not selected
686 ifeq ($(CONFIG_PACKAGE_libffmpeg-full
)$(CONFIG_PACKAGE_libffmpeg-mini
),)
687 Build
/InstallDev
= $(Build
/InstallDev
/custom
)
690 ifeq ($(BUILD_VARIANT
),audio-dec
)
691 # XXX: only install "audio-dec" dev files if -full & -mini are not selected
692 ifeq ($(CONFIG_PACKAGE_libffmpeg-full
)$(CONFIG_PACKAGE_libffmpeg-mini
),)
693 Build
/InstallDev
= $(Build
/InstallDev
/audio-dec
)
696 ifeq ($(BUILD_VARIANT
),full
)
697 # XXX: always install "full" dev files if -full is selected
698 Build
/InstallDev
= $(Build
/InstallDev
/full
)
700 ifeq ($(BUILD_VARIANT
),mini
)
701 # XXX: only install "mini" dev files if -full is not selected
702 ifeq ($(CONFIG_PACKAGE_libffmpeg-full
),)
703 Build
/InstallDev
= $(Build
/InstallDev
/mini
)
707 define Package
/ffmpeg
/install
708 $(INSTALL_DIR
) $(1)/usr
/bin
709 $(CP
) $(PKG_INSTALL_DIR
)/usr
/bin
/ffmpeg
$(1)/usr
/bin
/
712 Package
/ffmpeg-custom
/install = $(Package
/ffmpeg
/install)
714 define Package
/ffprobe
/install
715 $(INSTALL_DIR
) $(1)/usr
/bin
716 $(CP
) $(PKG_INSTALL_DIR
)/usr
/bin
/ffprobe
$(1)/usr
/bin
/
719 Package
/ffprobe-custom
/install = $(Package
/ffprobe
/install)
721 define Package
/libffmpeg-custom
/install
722 $(INSTALL_DIR
) $(1)/usr
/lib
723 $(CP
) $(PKG_INSTALL_DIR
)/usr
/lib
/lib
{avcodec
,avdevice
,avformat
,avutil
}.so.
* $(1)/usr
/lib
/
724 ifeq ($(CONFIG_FFMPEG_CUSTOM_SELECT_libx264
),y
)
725 $(CP
) $(PKG_INSTALL_DIR
)/usr
/lib
/libpostproc.so.
* $(1)/usr
/lib
/
727 ifeq ($(CONFIG_FFMPEG_CUSTOM_PROGRAMS
),y
)
728 $(CP
) $(PKG_INSTALL_DIR
)/usr
/lib
/lib
{avfilter
,swresample
}.so.
* $(1)/usr
/lib
/
732 # Only ffmpeg with libx264 is GPL (yes libpostproc); all other builds are lgpl (no libpostproc)
733 define Package
/libffmpeg-full
/install
734 $(INSTALL_DIR
) $(1)/usr
/lib
735 $(CP
) $(PKG_INSTALL_DIR
)/usr
/lib
/lib
{avcodec
,avdevice
,avfilter
,avformat
,avutil
,swresample
,swscale
}.so.
* $(1)/usr
/lib
/
736 ifneq ($(CONFIG_PACKAGE_libx264
),)
737 $(CP
) $(PKG_INSTALL_DIR
)/usr
/lib
/libpostproc.so.
* $(1)/usr
/lib
/
741 define Package
/libffmpeg-mini
/install
742 $(INSTALL_DIR
) $(1)/usr
/lib
743 $(CP
) $(PKG_INSTALL_DIR
)/usr
/lib
/lib
{avcodec
,avformat
,avutil
}.so.
* $(1)/usr
/lib
/
746 Package
/libffmpeg-audio-dec
/install = $(Package
/libffmpeg-custom
/install)
748 $(eval
$(call BuildPackage
,ffmpeg
))
749 $(eval
$(call BuildPackage
,ffprobe
))
750 $(eval
$(call BuildPackage
,ffmpeg-custom
))
751 $(eval
$(call BuildPackage
,ffprobe-custom
))
752 $(eval
$(call BuildPackage
,libffmpeg-audio-dec
))
753 $(eval
$(call BuildPackage
,libffmpeg-full
))
754 $(eval
$(call BuildPackage
,libffmpeg-mini
))
755 $(eval
$(call BuildPackage
,libffmpeg-custom
))