apotocki/ffmpeg
FFmpeg's libraries (avutil, avcodec, avformat, avfilter, swscale, swresample) under the LGPL.
- Library
- ffmpeg
- Newest
- 9.0.2 (r2, android)
- Targets
- android, apple, linux, windows
- License
- LGPL-2.1-or-later
- Homepage
- https://ffmpeg.org
- Documentation
- https://ffmpeg.org/documentation.html
- Keywords
- video, audio, codec, multimedia, ffmpeg
Use it
In otok.toml:
[deps.ffmpeg]
recipe = "apotocki/ffmpeg"
version = "~> 9.0.2"
Versions
| Version | Target | Channel | Published | Status |
|---|---|---|---|---|
| 9.0.2 (r2, android) | android | stable | 2026-11-10 | |
| 9.0.2 (r1, android) | android | stable | 2026-11-09 | |
| 9.0.2 (r1, apple) | apple | stable | 2026-11-09 | |
| 9.0.2 (r1, linux) | linux | stable | 2026-11-09 | |
| 9.0.2 (r1, windows) | windows | stable | 2026-11-09 |
9.0.2 (r2, android)
Platforms
android
Options
| Option | Type | Default | Description |
|---|---|---|---|
dav1d |
bool | true |
AV1 decoding with dav1d (the decoder libdav1d), much faster than FFmpeg's own AV1 decoder. |
Dependencies
| Library | Version | Recipe | Details |
|---|---|---|---|
| dav1d | >= 1.0 |
apotocki/dav1d | when = { option = "dav1d" } |
Toolchains
make { default-recipe = "apotocki/make", version = ">= 3.81" }nasm { default-recipe = "apotocki/nasm", version = ">= 2.13", when = { arch = ["x86_64"] } }pkg-config { default-recipe = "apotocki/pkgconf", version = ">= 1" }
Recipe files
build.lua
-- FFmpeg's own configure (not autoconf: no --host, its own --cc, --arch, --target-os) and make, out of the tree in
-- slice.build, cross-compiling every slice. Nothing is detected on the machine: --disable-autodetect turns off every
-- library configure would find, the threads too, and what the recipe wants is enabled by name.
local libraries = { "avutil", "avcodec", "avformat", "avfilter", "swscale", "swresample" }
-- FFmpeg's names of the ABIs' architectures, and their CPUs
local arch = { ["arm64-v8a"] = "aarch64", ["armeabi-v7a"] = "arm", x86_64 = "x86_64", x86 = "x86" }
local cpu = { ["armeabi-v7a"] = "armv7-a" }
-- 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"))
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",
"--enable-cross-compile", "--target-os=android", "--arch=" .. assert(arch[slice.arch], slice.arch),
"--disable-programs", "--disable-doc", "--disable-avdevice", "--disable-stripping",
"--disable-autodetect", "--enable-pthreads", "--enable-zlib", "--enable-jni", "--enable-mediacodec",
-- 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, "--dep-cc=" .. t.cc,
"--ar=" .. t.ar, "--ranlib=" .. t.ranlib, "--nm=" .. t.nm, "--strip=" .. t.strip,
"--pkg-config=" .. slice.toolchains["pkg-config"],
"--extra-cflags=" .. joined(t.cflags),
"--extra-cxxflags=" .. joined(t.cxxflags),
"--extra-ldflags=" .. joined(t.ldflags),
-- No program of the machine is built: its compiler would be needed, and Windows has none for the NDK. Host
-- programs are the tables of --enable-hardcoded-tables (off) and the generator of the AArch64 kernels of
-- swscale's unstable backends, which only SWS_UNSTABLE selects ("for testing and debugging purposes only")
"--disable-unstable",
-- the compiler of the machine, which configure checks (C11) all the same: the slice's, the same on every
-- machine, with no compiler of the machine in the build
"--host-cc=" .. t.cc,
"--host-cflags=" .. joined(t.cflags),
"--host-ldflags=" .. joined(t.ldflags),
}
if cpu[slice.arch] then args[#args + 1] = "--cpu=" .. cpu[slice.arch] end
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
elseif slice.arch == "x86" then
-- the assembly of 32-bit x86, NASM's and inline, is not position-independent (text relocations, which Android
-- refuses), and the inline one needs more registers than the PIC code leaves; --disable-asm would also make the
-- architecture "c" and leave out the unaligned accesses, so that avconfig.h would differ between the ABIs
args[#args + 1] = "--disable-x86asm"
args[#args + 1] = "--disable-inline-asm"
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)
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
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
# The otok recipe of FFmpeg (https://github.com/apotocki/otok): libavutil, libavcodec, libavformat, libavfilter,
# libswscale and libswresample for Android, LGPL only (no GPL or nonfree parts), with FFmpeg's own configure and make;
# MediaCodec (with JNI), the NDK's zlib, dav1d from its recipe; static or dynamic.
[recipe]
api = 1
library = "ffmpeg"
name = "ffmpeg"
version = "9.0.2"
revision = 2
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 = ["android"]
build-on = ["*/ndk"]
[options.dav1d]
type = "bool"
default = true
doc = "AV1 decoding with dav1d (the decoder libdav1d), much faster than FFmpeg's own AV1 decoder."
[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 = ["mediandk", "android", "z", "m", "atomic"] }