From patchwork Fri Jul 28 10:07:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Le Cuirot X-Patchwork-Id: 4500 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.1.76 with SMTP id 73csp841848vsb; Fri, 28 Jul 2017 14:52:55 -0700 (PDT) X-Received: by 10.223.139.3 with SMTP id n3mr7144618wra.249.1501278775316; Fri, 28 Jul 2017 14:52:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501278775; cv=none; d=google.com; s=arc-20160816; b=zzulAm9zXXcNoMsDAelMTwmFNc95ShJvQob8zHntQdFFDE2fqRSI+E3/3Br7zPReec s5BR4zh8vFJ2daPju88t+RxV58+bw18dgCddl9AEayJOOgW9aNktJKH102wJp4inX19b g5uaPT9C58go87XIUVq4jp7r8/sbiyyQTHlluBghYTpkE4Pn2MY3q9OXf6jNASIty9Wx uJGJzF64hXExGw+1kkPFa8A2GM7Pny6e+4a3zEHz0JkQyId97oOzFVXOHbzJGEmv+WeA npTnZRnpfuj6Ylihoy98DrfB8qese5koUvbw3LfyQitxjFMG0IsHXe/cnsKock+PvbMB 5Pfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:delivered-to :arc-authentication-results; bh=fNzJ5kI8xZLRkixdO1m96goXhJhryR7+eE5AobcMYe4=; b=K3slCIcgM8L7yhY2QcpBpZDn3TM9hjAsmj7H/KIE01Fr9kVhcvZuNYGeng6nZNO0nl yT+u8aDMOAsQ5T3qsrUPZNCptonNx0xXFVSv0I9hiA+76m7peoX0PfLFHDRG/fP5GnVG L/qoEzZcGoc1F17LYj8v23ykUNHLopc7U5o1qSfUhBC1PxM3HTowysg86rWuWompXcJd vrXif9fztiIEqeWLVvdxkJTWAae/679lQEskVeJ26KCtO5lgXk0Atq2t6Rxq/PQAn74R EH2dKQnWVY//FD9fesol38oYIHtMazj0xyOGu/HWuR+Gk1CeDOkWRAlHQM3WgtlEqomY XO5w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gentoo.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id z4si16101000wrb.275.2017.07.28.14.52.54; Fri, 28 Jul 2017 14:52:55 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gentoo.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2B800689C4F; Sat, 29 Jul 2017 00:52:50 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 539326882AE for ; Fri, 28 Jul 2017 13:09:03 +0300 (EEST) Received: from symphony.aura-online.co.uk (154.189.187.81.in-addr.arpa [81.187.189.154]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: chewi) by smtp.gentoo.org (Postfix) with ESMTPSA id 98E233418F1; Fri, 28 Jul 2017 10:09:00 +0000 (UTC) From: James Le Cuirot To: ffmpeg-devel@ffmpeg.org Date: Fri, 28 Jul 2017 11:07:16 +0100 Message-Id: <20170728100716.8143-1-chewi@gentoo.org> X-Mailer: git-send-email 2.13.1 X-Mailman-Approved-At: Sat, 29 Jul 2017 00:52:47 +0300 Subject: [FFmpeg-devel] [PATCH] build: Allow libffmpeg to be built for Chromium-based browsers X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: phajdan.jr@gentoo.org, James Le Cuirot , aballier@gentoo.org MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Google Chrome ships with support for proprietary codecs and Chromium can be built with support for them, either using the bundled FFmpeg or a system copy. This leaves other browsers such as Opera and Vivaldi, which ship with a libffmpeg that does not support proprietary codecs, presumably for cost reasons. These projects actively encourage users to swap this library with an alternative. Official instructions say to download the very large Chromium tarball and use its build system to configure and build libffmpeg. This involves building a lot of extra baggage that simply isn't needed because libffmpeg is literally just the main FFmpeg libraries combined. Binary-based distributions can easily take this hit but for source-based distributions, this hit is passed onto the end user. This Makefile snippet allows libffmpeg to be created without the help of Chromium's build system. It uses the CONFIG_SHARED variable to decide whether to link the FFmpeg libraries statically or dynamically. In the latter case, libffmpeg is just a wrapper with no symbols of its own. At this current time, recent Chromium versions support the 3.x ABI with just one major exception. Unless built against the system copy, -DFF_API_CONVERGENCE_DURATION=0 is used. This means that, other factors notwithstanding, full compatibility will not be seen until libavcodec hits 59. This is why I have provided the ability to link FFmpeg statically. This is how to build libffmpeg for a recent Chromium-based release: ./configure --disable-shared --enable-static --enable-pic --extra-cflags="-DFF_API_CONVERGENCE_DURATION=0" make libffmpeg make install-libffmpeg I have tested this with FFmpeg 3.3.2 and latest master. I have tested it against current Opera Stable, Opera Beta, Opera Developer, Vivaldi Stable, and Vivaldi Snapshot. --- Makefile | 1 + ffbuild/libffmpeg.mak | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 ffbuild/libffmpeg.mak diff --git a/Makefile b/Makefile index 29870d7..1e267e7 100644 --- a/Makefile +++ b/Makefile @@ -65,6 +65,7 @@ all: all-yes include $(SRC_PATH)/tools/Makefile include $(SRC_PATH)/ffbuild/common.mak +include $(SRC_PATH)/ffbuild/libffmpeg.mak FF_EXTRALIBS := $(FFEXTRALIBS) FF_DEP_LIBS := $(DEP_LIBS) diff --git a/ffbuild/libffmpeg.mak b/ffbuild/libffmpeg.mak new file mode 100644 index 0000000..992cf3c --- /dev/null +++ b/ffbuild/libffmpeg.mak @@ -0,0 +1,21 @@ +LIBFFMPEG = $(SLIBPREF)ffmpeg$(SLIBSUF) +LIBFFMPEG_LINK = $(LD) -shared -Wl,-soname,$(LIBFFMPEG) -Wl,-Bsymbolic -Wl,-z,now -Wl,-z,relro -Wl,-z,defs -Wl,--gc-sections $(LDFLAGS) $(LDLIBFLAGS) -o $(LIBFFMPEG) + +libffmpeg-: libavcodec/$(LIBPREF)avcodec$(LIBSUF) libavformat/$(LIBPREF)avformat$(LIBSUF) libavutil/$(LIBPREF)avutil$(LIBSUF) libswresample/$(LIBPREF)swresample$(LIBSUF) + $(LIBFFMPEG_LINK) -Wl,--whole-archive $^ -Wl,--no-whole-archive $(FFEXTRALIBS) + +libffmpeg-yes: libavcodec/$(SLIBPREF)avcodec$(SLIBSUF) libavformat/$(SLIBPREF)avformat$(SLIBSUF) libavutil/$(SLIBPREF)avutil$(SLIBSUF) + $(LIBFFMPEG_LINK) -Wl,--no-as-needed -lavcodec -lavformat -lavutil + +$(LIBFFMPEG): libffmpeg-$(CONFIG_SHARED) +libffmpeg: $(LIBFFMPEG) + +install-libffmpeg: $(LIBFFMPEG) + $(Q)mkdir -p "$(SHLIBDIR)/chromium" + $(INSTALL) -m 755 $< "$(SHLIBDIR)/chromium/$<" + $(STRIP) "$(SHLIBDIR)/chromium/$<" + +uninstall-libffmpeg: + $(RM) "$(SHLIBDIR)/chromium/$(LIBFFMPEG)" + +.PHONY: libffmpeg libffmpeg-* install-libffmpeg