You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

633 lines
14 KiB

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