Otok public index

apotocki/ffmpeg

apotocki/ffmpeg 9.0.2 (r1, linux)

Library
ffmpeg
Variant
linux, target linux
Channel
stable
Published
2026-11-09
Recipe source
https://github.com/otok-dev/recipes
389f3ae9c2814c92ba9016b029e0d95828c2167f in recipes/ffmpeg/9.0/linux/
Recipe SHA-256
5d32aadbdf92dbda272c272ac61d77091eaa12225416d91ab13ffcb115bd1a6b

Recipe files changed

Inputs

source.commit946fcce07b6dcd0331c8cc609192aeff5e1924f8
source.githttps://github.com/FFmpeg/FFmpeg
source.tagn9.0.2

Platforms

linux

Options

OptionTypeDefaultDescription
dav1d bool true AV1 decoding with dav1d (the decoder libdav1d), much faster than FFmpeg's own AV1 decoder.

Dependencies

LibraryVersionRecipeDetails
dav1d >= 1.0 apotocki/dav1d when = { option = "dav1d" }
zlib >= 1.2 apotocki/zlib

Toolchains

Recipe files

build.lua 4855 bytes · raw
-- FFmpeg's own configure (not autoconf: no --host, its own --cc, --arch, --target-os) and make, out of the tree in
-- slice.build. Nothing is detected on the machine: --disable-autodetect turns off every library configure would find
-- there, the threads too, and what the recipe wants is enabled by name.

local libraries = { "avutil", "avcodec", "avformat", "avfilter", "swscale", "swresample" }

-- the flags as one argument of configure
local function joined(flags, extra)
    local all = {}
    for _, f in ipairs(flags) do all[#all + 1] = f end
    for _, f in ipairs(extra or {}) do all[#all + 1] = f end
    return table.concat(all, " ")
end

-- What av*_configuration() tell: the arguments of configure without the paths of this build, which would make the
-- libraries differ from one build to the next and carry the machine's directories
local function configuration(args)
    local shown = {}
    for i = 3, #args do
        if not args[i]:find("[/\\]") then shown[#shown + 1] = args[i] end
    end
    return table.concat(shown, " ")
end

function build(slice, options, deps)
    local t = slice.toolchain
    local dynamic = slice.linkage == "dynamic"
    local debug = slice.configuration == "debug"
    -- VERSION, as the release archive has it (without it, and without .git, version.sh takes RELEASE)
    otok.write(slice.source .. "/VERSION", otok.read(slice.source .. "/RELEASE"))
    -- the dependencies: zlib by its headers and library (configure checks -lz), dav1d through pkg-config
    local include, lib = {}, {}
    for name, d in pairs(deps) do
        if name ~= "tools" then
            include[#include + 1] = "-I" .. d.include
            for _, dir in ipairs(d.lib_dirs) do lib[#lib + 1] = "-L" .. dir end
        end
    end
    local args = {
        "sh", slice.source .. "/configure",
        "--prefix=" .. slice.prefix,
        "--libdir=" .. slice.prefix .. "/lib",
        "--incdir=" .. slice.prefix .. "/include",
        dynamic and "--enable-shared" or "--disable-shared",
        dynamic and "--disable-static" or "--enable-static",
        "--enable-pic",
        "--disable-programs", "--disable-doc", "--disable-avdevice", "--disable-stripping",
        "--disable-autodetect", "--enable-pthreads", "--enable-zlib",
        -- otok's flags choose the configuration: FFmpeg's -O3 follows them in release, none in debug
        debug and "--disable-optimizations" or "--enable-optimizations",
        debug and "--enable-debug" or "--disable-debug",
        "--cc=" .. t.cc, "--cxx=" .. t.cxx, "--ar=" .. t.ar, "--ranlib=" .. t.ranlib, "--nm=" .. t.nm,
        "--strip=" .. t.strip,
        "--pkg-config=" .. slice.toolchains["pkg-config"],
        "--extra-cflags=" .. joined(t.cflags, include),
        "--extra-cxxflags=" .. joined(t.cxxflags, include),
        "--extra-ldflags=" .. joined(t.ldflags, lib),
    }
    if slice.c_standard then args[#args + 1] = "--stdc=c" .. slice.c_standard end
    if slice.toolchains.nasm then
        args[#args + 1] = "--x86asmexe=" .. slice.toolchains.nasm
    else
        args[#args + 1] = "--disable-x86asm"
    end
    if options.dav1d then args[#args + 1] = "--enable-libdav1d" end
    -- dav1d's pkg-config file, of the dependency's prefix
    local pc = {}
    for name, d in pairs(deps) do
        if name ~= "tools" then pc[#pc + 1] = d.prefix .. "/lib/pkgconfig" end
    end
    otok.run(args, { cwd = slice.build, env = {
        PKG_CONFIG_PATH = table.concat(pc, ":"),
        CFLAGS = false, CXXFLAGS = false, CPPFLAGS = false, LDFLAGS = false,
    } })
    local config = slice.build .. "/config.h"
    local text, n = otok.read(config):gsub('#define FFMPEG_CONFIGURATION "[^\n]*"',
        function() return '#define FFMPEG_CONFIGURATION "' .. configuration(args) .. '"' end)
    assert(n == 1, "config.h has no FFMPEG_CONFIGURATION")
    otok.write(config, text)
    -- the libraries find each other beside themselves; written into config.mak, since configure evaluates its
    -- arguments: $$$$ is make's $, as library.mak expands the link's arguments twice, and the backslash keeps it from
    -- the shell of the rule
    if t.rpath ~= "" then
        local mak = slice.build .. "/ffbuild/config.mak"
        local rules, m = otok.read(mak):gsub("\nLDSOFLAGS=", function()
            return "\nLDSOFLAGS=-Wl,-rpath," .. t.rpath:gsub("%$", "\\$$$$") .. " "
        end)
        assert(m == 1, "config.mak has no LDSOFLAGS")
        otok.write(mak, rules)
    end
    otok.make{ "install", cwd = slice.build }

    local p = slice.prefix
    local result = {}
    for _, name in ipairs(libraries) do
        local file = otok.glob("lib/lib" .. name .. (dynamic and ".so" or ".a"), p)[1]
        assert(file, "FFmpeg installed no lib" .. name)
        result[name] = file
    end
    return { libraries = result, headers = p .. "/include" }
end
patches/0001-swscale-framepool-names.patch 2191 bytes · raw
diff --git a/libswscale/framepool.c b/libswscale/framepool.c
index 2d6bcb1..1dd0483 100644
--- a/libswscale/framepool.c
+++ b/libswscale/framepool.c
@@ -16,4 +16,5 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "framepool_names.h"
 #include "libavfilter/framepool.c"
diff --git a/libswscale/framepool_names.h b/libswscale/framepool_names.h
new file mode 100644
index 0000000..bae43dc
--- /dev/null
+++ b/libswscale/framepool_names.h
@@ -0,0 +1,32 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/*
+ * libswscale's copy of libavfilter's frame pool under names of its own, so that
+ * the static libraries libswscale and libavfilter define no symbol twice.
+ */
+
+#ifndef SWSCALE_FRAMEPOOL_NAMES_H
+#define SWSCALE_FRAMEPOOL_NAMES_H
+
+#define ff_frame_pool_video_reinit sws_ff_frame_pool_video_reinit
+#define ff_frame_pool_audio_reinit sws_ff_frame_pool_audio_reinit
+#define ff_frame_pool_get          sws_ff_frame_pool_get
+#define ff_frame_pool_uninit       sws_ff_frame_pool_uninit
+
+#endif /* SWSCALE_FRAMEPOOL_NAMES_H */
diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h
index 9a822cb..de3a033 100644
--- a/libswscale/swscale_internal.h
+++ b/libswscale/swscale_internal.h
@@ -28,6 +28,7 @@
 #include "swscale.h"
 #include "graph.h"
 
+#include "framepool_names.h"
 #include "libavfilter/framepool.h"
 #include "libavutil/avassert.h"
 #include "libavutil/common.h"
recipe.toml 2319 bytes · raw
# The otok recipe of FFmpeg (https://github.com/apotocki/otok): libavutil, libavcodec, libavformat, libavfilter,
# libswscale and libswresample for Linux, LGPL only (no GPL or nonfree parts), with FFmpeg's own configure and make;
# nothing found on the machine (--disable-autodetect), zlib and dav1d from their recipes; static or dynamic.
[recipe]
api = 1
library = "ffmpeg"
name = "ffmpeg"
version = "9.0.2"
revision = 1
license = "LGPL-2.1-or-later"
license-files = ["COPYING.LGPLv2.1", "LICENSE.md"]
homepage = "https://ffmpeg.org"
documentation = "https://ffmpeg.org/documentation.html"
description = "FFmpeg's libraries (avutil, avcodec, avformat, avfilter, swscale, swresample) under the LGPL."
keywords = ["video", "audio", "codec", "multimedia", "ffmpeg"]
linkage = ["static", "dynamic"]
c-standard = ">= 11"

# The tag of the release in FFmpeg's mirror on GitHub (ffmpeg.org often fails to answer): its tree is that of the
# release archive ffmpeg-9.0.2.tar.xz, signed by FFmpeg's release key FCF9 86EA 15E6 E293 A564 4F10 B432 2F04 D676 58D8,
# without the file VERSION, which build.lua writes from RELEASE as the archive has it.
[source]
git = "https://github.com/FFmpeg/FFmpeg"
commit = "946fcce07b6dcd0331c8cc609192aeff5e1924f8"
tag = "n9.0.2"
# libswscale compiles libavfilter's frame pool too: under names of its own, so that the static libraries do not both
# define them
patches = ["patches/0001-swscale-framepool-names.patch"]

[platforms]
supported = ["linux"]
build-on = ["linux/gcc", "linux/clang"]

[options.dav1d]
type = "bool"
default = true
doc = "AV1 decoding with dav1d (the decoder libdav1d), much faster than FFmpeg's own AV1 decoder."

[deps.zlib]
version = ">= 1.2"
default-recipe = "apotocki/zlib"

[deps.dav1d]
version = ">= 1.0"
default-recipe = "apotocki/dav1d"
when = { option = "dav1d" }

[toolchains]
make = { version = ">= 3.81", default-recipe = "apotocki/make" }
pkg-config = { version = ">= 1", default-recipe = "apotocki/pkgconf" }  # configure finds dav1d through it
nasm = { version = ">= 2.13", default-recipe = "apotocki/nasm", when = { arch = ["x86_64"] } }  # the assembly of x86_64

[[product]]
name = "FFmpeg"
libraries = ["avfilter", "avformat", "avcodec", "swscale", "swresample", "avutil"]
headers = "avutil"
link = { libraries = ["m", "atomic", "dl", "pthread"] }