Skip to content

programmatic video rendering framework that is actually fast

feat: Download prebuilt Skia and FFmpeg instead of compiling them (#159)

Dmitriy Kovalenko32c8e43c36d9
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index df6d4f10..509e404d 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -105,7 +105,8 @@ jobs:
os: [ubuntu-latest]
env:
DEBIAN_FRONTEND: noninteractive
- # Skia and FFmpeg are built from source and every example is compiled
+ # FFmpeg is built from source (the workspace unifies the codecs of every
+ # example, no prebuilt matches that) and every example is compiled
# twice (check + test); debuginfo and incremental artifacts alone push
# the target dir past the runner's disk.
CARGO_INCREMENTAL: 0
diff --git a/Cargo.lock b/Cargo.lock
index fdbd2c45..cbf8a85b 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -286,6 +286,12 @@ version = "0.22.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
+[[package]]
+name = "base64"
+version = "0.23.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ac07cdecf99051d9a5238b80f35af32cdeba5b336e55d957b318b50137e18da5"
+
[[package]]
name = "beta-editor-bridge"
version = "1.0.2"
@@ -1083,10 +1089,10 @@ dependencies = [
]
[[package]]
-name = "ffmpeg-sys-next"
+name = "ffmpeg-sys-fframes"
version = "9.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9b939bf79dd5949412a4b81cfe21a07f48ea21b47fcbb5f57816c8c2de5ae30b"
+checksum = "cfc8123240ea935f4d766323979843650afd6d00b475c561d3bb8a59a2e6e31f"
dependencies = [
"bindgen",
"cc",
@@ -1163,7 +1169,7 @@ version = "1.0.2"
dependencies = [
"base64 0.22.1",
"bytemuck",
- "ffmpeg-sys-next",
+ "ffmpeg-sys-fframes",
"image",
"itoa",
"kamadak-exif",
@@ -1188,37 +1194,6 @@ dependencies = [
"syn 2.0.100",
]
-[[package]]
-name = "fframes-skia-bindings"
-version = "0.91.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "05df6915f25d413d30e5003b7f98c12d79b3490c70affcce3b30caaf4384b750"
-dependencies = [
- "bindgen",
- "cc",
- "flate2",
- "heck",
- "pkg-config",
- "regex",
- "serde_json",
- "tar",
- "toml 0.9.8",
-]
-
-[[package]]
-name = "fframes-skia-safe"
-version = "0.91.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "aef6f090c160ed785fa8a5239f6b761785db70c0cb49a448e427f493211c4cc0"
-dependencies = [
- "base64 0.22.1",
- "bitflags 2.13.2",
- "fframes-skia-bindings",
- "percent-encoding",
- "skia-svg-macros",
- "windows",
-]
-
[[package]]
name = "fframes_native_player"
version = "1.0.2"
@@ -1237,11 +1212,11 @@ version = "1.0.2"
dependencies = [
"ash",
"fframes",
- "fframes-skia-safe",
"foreign-types-shared",
"low-poly-art-example",
"metal",
"png",
+ "skia-safe",
"svgr",
"thingbuf",
"uuid",
@@ -1518,9 +1493,9 @@ dependencies = [
[[package]]
name = "hashbrown"
-version = "0.16.0"
+version = "0.17.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5419bdc4f6a9207fbeba6d11b604d481addf78ecd10c11ad51e76c2f6482748d"
+checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a"
[[package]]
name = "heck"
@@ -1593,12 +1568,12 @@ checksum = "d0263a3d970d5c054ed9312c0057b4f3bde9c0b33836d3637361d4a9e6e7a408"
[[package]]
name = "indexmap"
-version = "2.12.0"
+version = "2.14.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6717a8d2a5a929a1a2eb43a12812498ed141a0bcfb7e8f7844fbdbe4303bba9f"
+checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855"
dependencies = [
"equivalent",
- "hashbrown 0.16.0",
+ "hashbrown 0.17.1",
]
[[package]]
@@ -3057,9 +3032,9 @@ dependencies = [
[[package]]
name = "regex"
-version = "1.11.1"
+version = "1.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
+checksum = "f020237b6c8eed93db2e2cb53c00c60a8e1bc73da7d073199a1180401450218d"
dependencies = [
"aho-corasick",
"memchr",
@@ -3069,9 +3044,9 @@ dependencies = [
[[package]]
name = "regex-automata"
-version = "0.4.9"
+version = "0.4.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
+checksum = "ad8553b9b26413251cbf30e620595c7a41b3887f03da04579c0e6b0d6a06b4b2"
dependencies = [
"aho-corasick",
"memchr",
@@ -3080,9 +3055,9 @@ dependencies = [
[[package]]
name = "regex-syntax"
-version = "0.8.5"
+version = "0.8.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
+checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4"
[[package]]
name = "render-bench"
@@ -3093,7 +3068,6 @@ dependencies = [
"clap",
"conference-splash-screen-example",
"fframes",
- "fframes-skia-safe",
"fframes_skia_renderer",
"hello-world-example",
"low-poly-art-example",
@@ -3105,6 +3079,7 @@ dependencies = [
"rand 0.8.5",
"serde",
"serde_json",
+ "skia-safe",
"svgr",
"teej_podcast_example",
"tiktok-example",
@@ -3324,9 +3299,9 @@ dependencies = [
[[package]]
name = "serde_spanned"
-version = "1.0.3"
+version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e24345aa0fe688594e73770a5f6d1b216508b4f93484c0026d521acd30134392"
+checksum = "6662b5879511e06e8999a8a235d848113e942c9124f211511b16466ee2995f26"
dependencies = [
"serde_core",
]
@@ -3431,15 +3406,46 @@ version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d"
+[[package]]
+name = "skia-bindings"
+version = "0.153.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "eb325787c91b3f6c34a7c6f2b8a2297b20292d733ca53a08c233e5028aec49af"
+dependencies = [
+ "bindgen",
+ "cc",
+ "flate2",
+ "heck",
+ "pkg-config",
+ "regex",
+ "serde_json",
+ "tar",
+ "toml 1.1.6+spec-1.1.0",
+]
+
+[[package]]
+name = "skia-safe"
+version = "0.153.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c61cb643dac43067f3eb76c866635a74377ac0abca0ff2590674e1e295514c3d"
+dependencies = [
+ "base64 0.23.1",
+ "bitflags 2.13.2",
+ "percent-encoding",
+ "skia-bindings",
+ "skia-svg-macros",
+ "windows",
+]
+
[[package]]
name = "skia-svg-macros"
-version = "0.1.0"
+version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "044dd2233c9717a74f75197f3e7f0a966db2127c0ffb5e05013b480a9b75b2c7"
+checksum = "fec38aa7a389d249e1ce357b050ae5bdb302fd9943661fa650f39cf6ea51be97"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.100",
+ "syn 3.0.6",
]
[[package]]
@@ -3645,9 +3651,9 @@ dependencies = [
[[package]]
name = "tar"
-version = "0.4.44"
+version = "0.4.46"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1d863878d212c87a19c1a610eb53bb01fe12951c0501cf5a0d65f724914a667a"
+checksum = "3f6221d9a6003c78398e3b239969f352578258df48c8eb051caadae0015bc840"
dependencies = [
"filetime",
"libc",
@@ -3843,17 +3849,17 @@ dependencies = [
[[package]]
name = "toml"
-version = "0.9.8"
+version = "1.1.6+spec-1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f0dc8b1fb61449e27716ec0e1bdf0f6b8f3e8f6b05391e8497b8b6d7804ea6d8"
+checksum = "920602543f0911ab71da12c50d59701da54c196d1a2bf5cb4b75667f137a406a"
dependencies = [
"indexmap",
"serde_core",
- "serde_spanned 1.0.3",
- "toml_datetime 0.7.3",
+ "serde_spanned 1.1.1",
+ "toml_datetime 1.1.1+spec-1.1.0",
"toml_parser",
"toml_writer",
- "winnow",
+ "winnow 1.0.4",
]
[[package]]
@@ -3867,9 +3873,9 @@ dependencies = [
[[package]]
name = "toml_datetime"
-version = "0.7.3"
+version = "1.1.1+spec-1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f2cdb639ebbc97961c51720f858597f7f24c4fc295327923af55b74c3c724533"
+checksum = "3165f65f62e28e0115a00b2ebdd37eb6f3b641855f9d636d3cd4103767159ad7"
dependencies = [
"serde_core",
]
@@ -3884,23 +3890,23 @@ dependencies = [
"serde",
"serde_spanned 0.6.8",
"toml_datetime 0.6.8",
- "winnow",
+ "winnow 0.7.13",
]
[[package]]
name = "toml_parser"
-version = "1.0.4"
+version = "1.1.3+spec-1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c0cbe268d35bdb4bb5a56a2de88d0ad0eb70af5384a99d648cd4b3d04039800e"
+checksum = "1d38ac1cf9b95face32296c0a3ede1fdc270627c9d9c02a7274dd6d960dc4d56"
dependencies = [
- "winnow",
+ "winnow 1.0.4",
]
[[package]]
name = "toml_writer"
-version = "1.0.4"
+version = "1.1.2+spec-1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "df8b2b54733674ad286d16267dcfc7a71ed5c776e4ac7aa3c3e2561f7c637bf2"
+checksum = "7d56353a2a665ad0f41a421187180aab746c8c325620617ad883a99a1cbe66d2"
[[package]]
name = "tracing"
@@ -4623,6 +4629,12 @@ dependencies = [
"memchr",
]
+[[package]]
+name = "winnow"
+version = "1.0.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "23b97319f7b8343df12cc98938e5c3eb436064524c8d2b4e30a1d3a36eecdf81"
+
[[package]]
name = "wit-bindgen-rt"
version = "0.39.0"
diff --git a/Cargo.toml b/Cargo.toml
index bcf3a3c9..d5a4cf12 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -100,7 +100,8 @@ float_cmp = "allow"
# usvgr = { path = "../svgr/crates/usvgr" }
svgr = "0.46.0"
usvgr = "0.46.0"
-ffmpeg-sys-fframes = { package = "ffmpeg-sys-next", version = "9.0.0" }
+# ffmpeg-sys-next with prebuilt FFmpeg binaries: https://github.com/dmtrKovalenko/rust-ffmpeg-sys
+ffmpeg-sys-fframes = "9.0.0"
wasm-bindgen = "0.2.100"
kamadak-exif = "0.6.1"
diff --git a/README.md b/README.md
index eb9f3e45..fdd4f447 100644
--- a/README.md
+++ b/README.md
@@ -196,14 +196,16 @@ cd my-video && cargo run --release -- preview
```
`cargo fframes new` takes `--template single-scene|multi-scene`, `--format landscape|portrait|square|uhd`, `--fps`,
-`--title` and `--backend`. The first build compiles Skia and ffmpeg from source and takes a while; later builds take
-seconds. `--backend cpu` skips the Skia build (no preview window, slower renders). To track `main`, install with
+`--title` and `--backend`. On macOS and Linux (arm64, x86_64) the first build downloads prebuilt Skia and ffmpeg
+libraries and takes under a minute on a fast machine; other targets and feature combinations
+compile them from source (up to ~20 minutes). Later builds take seconds. `--backend cpu` skips Skia (no preview window, slower renders). To track `main`, install with
`--git https://github.com/dmtrKovalenko/fframes`.
## Requirements
[Rust](https://www.rust-lang.org/learn/get-started) and, for working on the editor, [NodeJS](https://nodejs.org/en/download/).
-fframes compiles ffmpeg's libav libraries during the build, so the system encoders they link against have to be installed.
+fframes links ffmpeg's libav libraries statically. A prebuilt build is downloaded for macOS and Linux (arm64 and x86_64) and
+compiled from source for other targets or `FFMPEG_FORCE_BUILD=1`; either way the system encoders they link against have to be installed.
<details>
<summary><b>macOS</b></summary>
@@ -274,8 +276,9 @@ troubleshooting please refer the [ffmpeg compilation guide](https://trac.ffmpeg.
<details>
<summary><b>Troubleshooting</b></summary>
-- **Build fails in `ffmpeg-sys-next`:** a system library from the list above is missing (`nasm`, `pkg-config`, the codec packages).
-- **Build fails in the Skia bindings with a bindgen or libclang error:** point `LIBCLANG_PATH` at a working libclang,
+- **Build fails in `ffmpeg-sys-fframes`:** a system library from the list above is missing (`nasm`, `pkg-config`, the codec packages).
+- **Build fails in the Skia bindings with a bindgen or libclang error** (only when Skia is compiled from source, e.g. with
+ both `metal` and `vulkan` enabled): point `LIBCLANG_PATH` at a working libclang,
on macOS Xcode's: `export LIBCLANG_PATH=$(xcode-select -p)/Toolchains/XcodeDefault.xctoolchain/usr/lib`.
- **Text renders in the wrong font:** `inspect` reports `No match for ... font-family`; put the font file in the
project's `media/` folder and use its exact family name.
diff --git a/cargo-fframes/src/main.rs b/cargo-fframes/src/main.rs
index 044d2a33..6b97a606 100644
--- a/cargo-fframes/src/main.rs
+++ b/cargo-fframes/src/main.rs
@@ -38,7 +38,7 @@ enum Command {
enum Backend {
/// Built-in tiny-skia renderer: no GPU and no Skia build, but ~10x slower and no preview window.
Cpu,
- /// Skia on the GPU through Metal (macOS, default there). The first build compiles Skia (~20 min).
+ /// Skia on the GPU through Metal (macOS, default there). Skia is downloaded prebuilt.
SkiaMetal,
/// Skia on the GPU through Vulkan (default on Linux and Windows).
SkiaVulkan,
@@ -272,7 +272,7 @@ fn ask(args: NewArgs) -> Result<Project, String> {
Some(backend) => backend,
None if interactive => {
let items = [
- "skia-metal - GPU on macOS: fast renders + preview window, first build ~20 min",
+ "skia-metal - GPU on macOS: fast renders + preview window",
"skia-vulkan - GPU on Linux/Windows (macOS via MoltenVK)",
"cpu - no Skia build, slower renders, no preview window",
];
@@ -495,7 +495,7 @@ fn new(args: NewArgs) -> Result<(), String> {
("height", project.height.to_string()),
("fps", project.fps.to_string()),
("media_path", media_path),
- // Codec features build ffmpeg from source; Windows links a prebuilt ffmpeg instead.
+ // Codec features link a static ffmpeg (prebuilt or compiled); Windows links a prebuilt ffmpeg DLL.
(
"codecs",
format!(
@@ -581,9 +581,6 @@ fn new(args: NewArgs) -> Result<(), String> {
if workspace.is_some() {
println!("Added it to the fframes workspace members.");
}
- if project.backend != Backend::Cpu {
- println!("The first build compiles Skia from source, which takes a while.");
- }
println!(
"\nNext:\n {cd}\n {run} timeline\n {run} frame 1s,50%,end # writes frames/*.png\n {run} strip -n 12 # writes strip.png{preview}\n {run} render # writes out.mp4\n cargo test # frame snapshots",
preview = if project.backend == Backend::Cpu {
diff --git a/fframes-media/Cargo.toml b/fframes-media/Cargo.toml
index 5d21ef90..0371c821 100644
--- a/fframes-media/Cargo.toml
+++ b/fframes-media/Cargo.toml
@@ -31,12 +31,14 @@ image = { version = "0.25.6", default-features = false, features = [
usvgr.workspace = true
libc = "0.2.159"
-# FFmpeg is compiled from source and linked statically everywhere except Windows, where
-# building it needs an MSYS2 + MSVC toolchain. There it is linked from a prebuilt
+# FFmpeg is linked statically everywhere except Windows. ffmpeg-sys-fframes downloads a
+# prebuilt static FFmpeg for the target and codec features from its GitHub releases and
+# compiles it from source only when there is none (FFMPEG_FORCE_BUILD=1 forces that). On
+# Windows building it needs an MSYS2 + MSVC toolchain, so there it is linked from a prebuilt
# FFmpeg 9 distribution found through FFMPEG_DIR or vcpkg (see README).
#
# `fframes_docsrs` is set by the docs.rs build (see [package.metadata.docs.rs] below). docs.rs has no
-# network access, so the from-source build is skipped there and ffmpeg-sys-next falls back to
+# network access, so the from-source build is skipped there and ffmpeg-sys-fframes falls back to
# the FFmpeg headers of the docs.rs image through pkg-config. It is a project cfg on purpose:
# `--cfg docsrs` in RUSTFLAGS would also reach every dependency, and some enable removed
# nightly features under it.
diff --git a/fframes-skia-renderer/Cargo.toml b/fframes-skia-renderer/Cargo.toml
index 51aca0ea..950fe161 100644
--- a/fframes-skia-renderer/Cargo.toml
+++ b/fframes-skia-renderer/Cargo.toml
@@ -9,9 +9,14 @@ authors = ["Dmitriy Kovalenko <[email protected]>"]
[lib]
doctest = false
[dependencies]
-skia-safe = { version = "0.91.0", package = "fframes-skia-safe", features = [
- "svg",
-] }
+# Upstream rust-skia publishes prebuilt Skia binaries (downloaded by its build script) for a
+# fixed set of feature combinations. The features below are chosen to match one of them for
+# every GPU backend, otherwise Skia is compiled from source (~20 minutes, needs libclang):
+# macOS metal: ganesh, gl, metal, svg, textlayout
+# macOS vulkan (MoltenVK): ganesh, gl, svg, textlayout, vulkan
+# Linux/Windows vulkan: ganesh, svg, textlayout, vulkan, webp
+# See https://github.com/rust-skia/skia-binaries/releases for the available keys.
+skia-safe = { version = "0.153.3", features = ["svg"] }
thingbuf = "0.1.6"
fframes.workspace = true
ash = { version = "0.38.0", optional = true }
@@ -19,6 +24,13 @@ metal-rs = { package = "metal", version = "0.32.0", optional = true }
uuid = "1.12.1"
foreign-types-shared = "0.3.1"
+# Cargo merges these features into the skia-safe dependency above.
+[target.'cfg(target_os = "macos")'.dependencies]
+skia-safe = { version = "0.153.3", features = ["svg", "gl"] }
+
+[target.'cfg(not(target_os = "macos"))'.dependencies]
+skia-safe = { version = "0.153.3", features = ["svg", "webp"] }
+
[dev-dependencies]
fframes = { workspace = true, features = ["compile-time-svgtree"] }
png = "0.17"
@@ -28,9 +40,9 @@ low-poly-art-example = { path = "../examples/low-poly-art" }
[features]
default = ["gpu", "binary-cache"]
binary-cache = ["skia-safe/binary-cache"]
-gpu = ["skia-safe/gpu"]
-metal = ["skia-safe/metal", "metal-rs"]
-vulkan = ["skia-safe/vulkan", "ash"]
+gpu = ["skia-safe/ganesh"]
+metal = ["gpu", "skia-safe/metal", "metal-rs"]
+vulkan = ["gpu", "skia-safe/vulkan", "ash"]
d3d = ["skia-safe/d3d"]
gl = ["skia-safe/gl"]
x11 = ["skia-safe/x11"]
diff --git a/fframes-skia-renderer/src/backends/vulkan.rs b/fframes-skia-renderer/src/backends/vulkan.rs
index 1775da4d..ab7ed165 100644
--- a/fframes-skia-renderer/src/backends/vulkan.rs
+++ b/fframes-skia-renderer/src/backends/vulkan.rs
@@ -201,13 +201,15 @@ impl SkiaBackend for SkiaVulkanCtx {
% self.queues.len()];
// Initialize Skia Vulkan backend context
- let backend_context = gpu::vk::BackendContext::new(
+ let backend_context = gpu::vk::BackendContext::new_builder(
self.instance.handle().as_raw() as _,
self.physical_device.as_raw() as _,
self.device.handle().as_raw() as _,
(queue.as_raw() as _, self.queue_family_index as usize),
- &get_proc as _,
- );
+ &get_proc,
+ None,
+ )
+ .build();
// Configure context options (same as in Metal implementation)
let mut gpu_context_opts = gpu::ContextOptions::new();
diff --git a/fframes-skia-renderer/src/render/convert.rs b/fframes-skia-renderer/src/render/convert.rs
index 53c24487..5cfbc85b 100644
--- a/fframes-skia-renderer/src/render/convert.rs
+++ b/fframes-skia-renderer/src/render/convert.rs
@@ -104,14 +104,11 @@ fn convert_linear_gradient(
let start = skia_safe::Point::new(gradient.x1(), gradient.y1());
let end = skia_safe::Point::new(gradient.x2(), gradient.y2());
- skia_safe::Shader::linear_gradient(
- (start, end),
- skia_safe::gradient_shader::GradientShaderColors::Colors(&colors),
- Some(positions.as_slice()),
- mode,
- None,
- Some(&transform),
- )
+ let colors = skia_safe::gradient::Colors::new(&colors, Some(&positions), mode, None);
+ let gradient =
+ skia_safe::gradient::Gradient::new(colors, skia_safe::gradient::Interpolation::default());
+
+ skia_safe::gradient::shaders::linear_gradient((start, end), &gradient, &transform)
}
fn convert_radial_gradient(
@@ -125,34 +122,35 @@ fn convert_radial_gradient(
let center = skia_safe::Point::new(gradient.cx(), gradient.cy());
let focal = skia_safe::Point::new(gradient.fx(), gradient.fy());
- skia_safe::Shader::two_point_conical_gradient(
- focal,
- 0.0,
- center,
- gradient.r().get(),
- skia_safe::gradient_shader::GradientShaderColors::Colors(&colors),
- Some(positions.as_slice()),
- mode,
- None,
- Some(&transform),
+ let radius = gradient.r().get();
+ let colors = skia_safe::gradient::Colors::new(&colors, Some(&positions), mode, None);
+ let gradient =
+ skia_safe::gradient::Gradient::new(colors, skia_safe::gradient::Interpolation::default());
+
+ skia_safe::gradient::shaders::two_point_conical_gradient(
+ (focal, 0.0),
+ (center, radius),
+ &gradient,
+ &transform,
)
}
fn convert_gradient_stops(
gradient: &usvgr::BaseGradient,
opacity: usvgr::Opacity,
-) -> (Vec<skia_safe::Color>, Vec<f32>) {
+) -> (Vec<skia_safe::Color4f>, Vec<f32>) {
let mut colors = Vec::with_capacity(gradient.stops().len());
let mut positions = Vec::with_capacity(gradient.stops().len());
for stop in gradient.stops() {
let alpha = stop.opacity() * opacity;
- colors.push(skia_safe::Color::from_argb(
+ // Quantized to 8 bits per channel like the CPU renderer, so both draw the same pixels.
+ colors.push(skia_safe::Color4f::from(skia_safe::Color::from_argb(
alpha.to_u8(),
stop.color().red,
stop.color().green,
stop.color().blue,
- ));
+ )));
positions.push(stop.offset().get());
}
diff --git a/fframes/src/lib.rs b/fframes/src/lib.rs
index 17db6b44..1ce960a8 100644
--- a/fframes/src/lib.rs
+++ b/fframes/src/lib.rs
@@ -92,10 +92,12 @@
//!
//! # `FFmpeg`
//!
-//! Decoding, encoding and muxing use the `FFmpeg` libraries through `ffmpeg-sys-next`, re-exported
-//! as [`ffmpeg_sys_fframes`]. On Linux and macOS `FFmpeg` is compiled from source during
-//! `cargo build` and linked statically, so the toolchain listed in the repository README (nasm,
-//! yasm, clang, the codec dev packages) must be installed. On Windows a prebuilt `FFmpeg` 9 is
+//! Decoding, encoding and muxing use the `FFmpeg` libraries through `ffmpeg-sys-fframes`, re-exported
+//! as [`ffmpeg_sys_fframes`]. On Linux and macOS `FFmpeg` is linked statically: a prebuilt build
+//! for the target and codec features is downloaded during `cargo build`, and compiled from source
+//! when there is none, which needs the toolchain listed in the repository README (nasm, clang).
+//! The codec features link the system codec libraries (x264, x265, ...), so their dev packages
+//! must be installed either way. On Windows a prebuilt `FFmpeg` 9 is
//! linked through `FFMPEG_DIR` or vcpkg and the codec features are not available.
//!
mod audio_analysis;
diff --git a/render-bench/Cargo.toml b/render-bench/Cargo.toml
index af684f1a..b0561e12 100644
--- a/render-bench/Cargo.toml
+++ b/render-bench/Cargo.toml
@@ -9,7 +9,7 @@ publish = false
clap = { version = "4.3.4", features = ["derive"] }
fframes = { workspace = true, features = ["compile-time-svgtree", "h264", "libav-agree-gpl"] }
fframes_skia_renderer = { workspace = true, features = ["vulkan"] }
-skia-safe = { version = "0.91.0", package = "fframes-skia-safe" }
+skia-safe = "0.153.3"
svgr.workspace = true
rand = "0.8.5"
serde = { version = "1", features = ["derive"] }
diff --git a/skills/fframes-video/SKILL.md b/skills/fframes-video/SKILL.md
index a85c5e3f..b53aac8d 100644
--- a/skills/fframes-video/SKILL.md
+++ b/skills/fframes-video/SKILL.md
@@ -66,15 +66,16 @@ fonts and decorations with a design made for the video the user asked for.
**Use the Skia GPU backend (the default).** `cargo fframes new` picks Skia on Metal (macOS) or
Vulkan (Linux, Windows). It renders about 10x faster than the CPU backend and gives you the
-real-time `preview` window. The first build compiles Skia and ffmpeg from source and takes
-about 20 minutes, so start it right away and write the video while it runs:
+real-time `preview` window. On macOS and Linux the first build downloads prebuilt Skia and ffmpeg
+and only compiles the Rust dependencies (about a minute; other targets, or `metal` and `vulkan`
+together, compile Skia from source for ~20 minutes). Start it right away and write the video
+while it runs:
```bash
-cd my-video && cargo build --release # run in the background, it is slow only once
+cd my-video && cargo build --release # run in the background, the first build is the slow one
```
-`--backend cpu` needs no Skia build but has no preview window; pick it only when there is no
-GPU or no time for the first build.
+`--backend cpu` needs no Skia but has no preview window; pick it only when there is no GPU.
The project renders as generated:
@@ -246,20 +247,19 @@ command to watch it.
## Troubleshooting
-- Build fails in `ffmpeg-sys-next`: a system library from step 1 is missing (`nasm`,
+- Build fails in `ffmpeg-sys-fframes`: a system library from step 1 is missing (`nasm`,
`pkg-config`, the codec `-dev` packages).
-- Build fails in the Skia bindings (`fframes-skia-bindings`) with bindgen or libclang errors: point `LIBCLANG_PATH` at a
+- Build fails in the Skia bindings (`skia-bindings`) with bindgen or libclang errors (Skia
+ is only compiled from source when no prebuilt matches, e.g. `metal` and `vulkan` together): point `LIBCLANG_PATH` at a
working libclang (on macOS Xcode's:
`export LIBCLANG_PATH=$(xcode-select -p)/Toolchains/XcodeDefault.xctoolchain/usr/lib`).
- Skia bindings fail to compile on macOS 27 / Xcode 27 with ``cannot find type `_Traits` ``
- in `std___hash_table___node_allocator`: Xcode 27's libc++ needs a bindgen rule that
- `fframes-skia-bindings` 0.91.1 does not have yet (rust-skia fixed it in
- [#1335](https://github.com/rust-skia/rust-skia/pull/1335)). Until a release includes it, patch a
- local copy: copy `~/.cargo/registry/src/*/fframes-skia-bindings-0.91.1` to
- `vendor/fframes-skia-bindings`, add `"std::__hash_table.*",` after `"std::__tree.*",` in
- `OPAQUE_TYPES` in its `build_support/skia_bindgen.rs`, and add to the project's own `Cargo.toml`:
- `[patch.crates-io]` `fframes-skia-bindings = { path = "vendor/fframes-skia-bindings" }`.
- The compiled Skia build is reused, so the rebuild takes minutes.
+ in `std___hash_table___node_allocator`: only happens when Skia is compiled from source (the
+ prebuilt binaries ship their bindings). `skia-bindings` 0.153.3 lacks the bindgen rule
+ (rust-skia [#1335](https://github.com/rust-skia/rust-skia/pull/1335)); use one GPU backend so
+ the prebuilt download matches, or patch a copy of `skia-bindings-0.153.3` (add
+ `"std::__hash_table.*",` after `"std::__tree.*",` in `OPAQUE_TYPES` in
+ `build_support/skia_bindgen.rs`) through `[patch.crates-io]`.
- ``can't find crate for `fframes_media_dir_macro` `` on macOS 27 while the file exists: the
proc macro was linked by an older Rust whose output the macOS 27 loader rejects (a "LINKEDIT
string pool" error). Update Rust (`rustup update`; 1.98 works) and rebuild.