Skip to content

programmatic video rendering framework that is actually fast

feat(preview): add a just command to preview any example

Dmitriy Kovalenkocef7dd6d6a83
diff --git a/AGENTS.md b/AGENTS.md
index 9c5ae33e..4f4d95b2 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -30,6 +30,9 @@ just watch-editor
# Run example with live reload (editor + WASM hot reload)
just run <example-name>
+# Open an example in the native preview window
+just preview <example-name>
+
# Render example to video file
just render <example-name>
```
diff --git a/Cargo.lock b/Cargo.lock
index d3424005..30ddd281 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -85,6 +85,7 @@ name = "anamorphic-video"
version = "1.4.1"
dependencies = [
"fframes",
+ "fframes_native_player",
"fframes_skia_renderer",
]
@@ -512,6 +513,7 @@ name = "captions-example"
version = "1.4.1"
dependencies = [
"fframes",
+ "fframes_native_player",
"fframes_skia_renderer",
"serde",
]
@@ -722,6 +724,7 @@ version = "1.4.1"
dependencies = [
"clap",
"fframes",
+ "fframes_native_player",
"fframes_skia_renderer",
"image",
"rayon",
@@ -1702,6 +1705,7 @@ dependencies = [
"clap",
"fframes",
"fframes-dylib",
+ "fframes_native_player",
"fframes_skia_renderer",
]
@@ -2082,6 +2086,7 @@ name = "lottie"
version = "1.4.1"
dependencies = [
"fframes",
+ "fframes_native_player",
"fframes_skia_renderer",
]
@@ -2099,6 +2104,7 @@ name = "low-poly-art-example"
version = "1.4.1"
dependencies = [
"fframes",
+ "fframes_native_player",
"fframes_skia_renderer",
"fframes_test_utils",
"libm",
@@ -2144,6 +2150,7 @@ name = "marketing-example"
version = "1.4.1"
dependencies = [
"fframes",
+ "fframes_native_player",
"fframes_skia_renderer",
"fframes_test_utils",
"futures",
@@ -3039,6 +3046,7 @@ name = "podcast-example"
version = "1.4.1"
dependencies = [
"fframes",
+ "fframes_native_player",
"fframes_skia_renderer",
]
@@ -3935,6 +3943,7 @@ name = "svg-in-3d-example"
version = "1.4.1"
dependencies = [
"fframes",
+ "fframes_native_player",
"fframes_skia_renderer",
]
@@ -4139,6 +4148,7 @@ name = "tiktok-example"
version = "1.4.1"
dependencies = [
"fframes",
+ "fframes_native_player",
"fframes_skia_renderer",
"libm",
"tiktok-media",
diff --git a/README.md b/README.md
index 9be0a5a6..582f0c74 100644
--- a/README.md
+++ b/README.md
@@ -271,6 +271,13 @@ cargo fframes new my-video
cd my-video && cargo run --release -- preview
```
+From this repository, preview any example with `just preview <example>`:
+
+```sh
+just preview hello-world
+just preview teej-podcast --software-decode
+```
+
The preview timeline sits below landscape and square videos and to the left of portrait videos.
Drag the filmstrip to scrub, or click a scene marker to pause on its first frame. Use `[` and `]`
to jump between scenes and `,` and `.` to step one frame. Press `Space` to play or pause, or `T`
diff --git a/examples/anamorphic-video/Cargo.toml b/examples/anamorphic-video/Cargo.toml
index 3f34fa01..3dccee82 100644
--- a/examples/anamorphic-video/Cargo.toml
+++ b/examples/anamorphic-video/Cargo.toml
@@ -10,9 +10,11 @@ fframes = { workspace = true, features = ["compile-time-svgtree", "cli"] }
# `--renderer cpu|skia-cpu|gpu`: Skia on Metal on macOS, on Vulkan everywhere else
[target.'cfg(target_os = "macos")'.dependencies]
fframes_skia_renderer = { workspace = true, features = ["metal", "cli"] }
+fframes_native_player = { workspace = true, features = ["metal", "audio"] }
[target.'cfg(not(target_os = "macos"))'.dependencies]
fframes_skia_renderer = { workspace = true, features = ["vulkan", "cli"] }
+fframes_native_player = { workspace = true, features = ["vulkan", "audio"] }
# FFmpeg codecs, portable so cached source builds work across CI runner CPUs. Windows
# links a prebuilt FFmpeg instead (see README).
diff --git a/examples/anamorphic-video/src/main.rs b/examples/anamorphic-video/src/main.rs
index 7a303dbb..6fc23838 100644
--- a/examples/anamorphic-video/src/main.rs
+++ b/examples/anamorphic-video/src/main.rs
@@ -20,6 +20,7 @@ fn main() -> ExitCode {
..Default::default()
},
)
+ .preview(fframes_native_player::cli_preview)
.renderers(SkiaRenderers::default())
.run()
}
diff --git a/examples/captions/Cargo.toml b/examples/captions/Cargo.toml
index f519d762..faf7e97e 100644
--- a/examples/captions/Cargo.toml
+++ b/examples/captions/Cargo.toml
@@ -10,13 +10,15 @@ serde = { version = "1", features = ["derive"] }
[features]
default = ["skia"]
-skia = ["dep:fframes_skia_renderer"]
+skia = ["dep:fframes_skia_renderer", "dep:fframes_native_player"]
[target.'cfg(target_os = "macos")'.dependencies]
fframes_skia_renderer = { workspace = true, optional = true, features = ["cli", "metal"] }
+fframes_native_player = { workspace = true, optional = true, features = ["metal", "audio"] }
[target.'cfg(not(any(target_os = "macos", target_arch = "wasm32")))'.dependencies]
fframes_skia_renderer = { workspace = true, optional = true, features = ["cli", "vulkan"] }
+fframes_native_player = { workspace = true, optional = true, features = ["vulkan", "audio"] }
[target.'cfg(not(any(windows, target_arch = "wasm32")))'.dependencies]
fframes = { workspace = true, features = ["h264", "libav-agree-gpl", "build-portable"] }
diff --git a/examples/captions/src/main.rs b/examples/captions/src/main.rs
index 3f48b6d6..99174705 100644
--- a/examples/captions/src/main.rs
+++ b/examples/captions/src/main.rs
@@ -19,6 +19,8 @@ fn main() -> ExitCode {
},
);
#[cfg(feature = "skia")]
- let runner = runner.renderers(fframes_skia_renderer::cli::SkiaRenderers::default());
+ let runner = runner
+ .preview(fframes_native_player::cli_preview)
+ .renderers(fframes_skia_renderer::cli::SkiaRenderers::default());
runner.run()
}
diff --git a/examples/conference-splash-screen/Cargo.toml b/examples/conference-splash-screen/Cargo.toml
index 4b07080d..b8a09866 100644
--- a/examples/conference-splash-screen/Cargo.toml
+++ b/examples/conference-splash-screen/Cargo.toml
@@ -14,9 +14,11 @@ image = "0.25.4"
# `--renderer cpu|skia-cpu|gpu`: Skia on Metal on macOS, on Vulkan everywhere else
[target.'cfg(target_os = "macos")'.dependencies]
fframes_skia_renderer = { workspace = true, features = ["metal", "cli"] }
+fframes_native_player = { workspace = true, features = ["metal", "audio"] }
[target.'cfg(not(any(target_os = "macos", target_arch = "wasm32")))'.dependencies]
fframes_skia_renderer = { workspace = true, features = ["vulkan", "cli"] }
+fframes_native_player = { workspace = true, features = ["vulkan", "audio"] }
# FFmpeg codecs, portable so cached source builds work across CI runner CPUs. Windows
# links a prebuilt FFmpeg instead (see README).
diff --git a/examples/conference-splash-screen/src/main.rs b/examples/conference-splash-screen/src/main.rs
index 437133db..cd842ffa 100644
--- a/examples/conference-splash-screen/src/main.rs
+++ b/examples/conference-splash-screen/src/main.rs
@@ -55,6 +55,7 @@ fn main() -> ExitCode {
)
.args(args)
.backend(talks::backend())
+ .preview(fframes_native_player::cli_preview)
.renderers(SkiaRenderers::default())
.run()
}
diff --git a/examples/hello-world/Cargo.toml b/examples/hello-world/Cargo.toml
index 431d32ae..eb6ac221 100644
--- a/examples/hello-world/Cargo.toml
+++ b/examples/hello-world/Cargo.toml
@@ -12,9 +12,11 @@ clap = { version = "4.3.4", features = ["derive"] }
# `--renderer cpu|skia-cpu|gpu`: Skia on Metal on macOS, on Vulkan everywhere else
[target.'cfg(target_os = "macos")'.dependencies]
fframes_skia_renderer = { workspace = true, features = ["metal", "cli"] }
+fframes_native_player = { workspace = true, features = ["metal", "audio"] }
[target.'cfg(not(any(target_os = "macos", target_arch = "wasm32")))'.dependencies]
fframes_skia_renderer = { workspace = true, features = ["vulkan", "cli"] }
+fframes_native_player = { workspace = true, features = ["vulkan", "audio"] }
# FFmpeg codecs, portable so cached source builds work across CI runner CPUs. Windows
# links a prebuilt FFmpeg instead (see README).
diff --git a/examples/hello-world/src/main.rs b/examples/hello-world/src/main.rs
index 94e7b2b3..3c4433d7 100644
--- a/examples/hello-world/src/main.rs
+++ b/examples/hello-world/src/main.rs
@@ -48,6 +48,7 @@ fn main() -> ExitCode {
},
)
.args(args)
+ .preview(fframes_native_player::cli_preview)
.renderers(SkiaRenderers::default())
.run()
}
diff --git a/examples/lottie/Cargo.toml b/examples/lottie/Cargo.toml
index 853cbf4a..90e7d363 100644
--- a/examples/lottie/Cargo.toml
+++ b/examples/lottie/Cargo.toml
@@ -10,9 +10,11 @@ fframes = { workspace = true, features = ["lottie", "compile-time-svgtree", "cli
# `--renderer cpu|skia-cpu|gpu`: Skia on Metal on macOS, on Vulkan everywhere else
[target.'cfg(target_os = "macos")'.dependencies]
fframes_skia_renderer = { workspace = true, features = ["metal", "cli"] }
+fframes_native_player = { workspace = true, features = ["metal", "audio"] }
[target.'cfg(not(target_os = "macos"))'.dependencies]
fframes_skia_renderer = { workspace = true, features = ["vulkan", "cli"] }
+fframes_native_player = { workspace = true, features = ["vulkan", "audio"] }
# FFmpeg codecs, portable so cached source builds work across CI runner CPUs. Windows
# links a prebuilt FFmpeg instead (see README).
diff --git a/examples/lottie/src/main.rs b/examples/lottie/src/main.rs
index 4414296a..abf603ba 100644
--- a/examples/lottie/src/main.rs
+++ b/examples/lottie/src/main.rs
@@ -35,6 +35,7 @@ fn main() -> ExitCode {
..Default::default()
},
)
+ .preview(fframes_native_player::cli_preview)
.renderers(SkiaRenderers::default())
.run()
}
diff --git a/examples/low-poly-art/Cargo.toml b/examples/low-poly-art/Cargo.toml
index bcca3dd1..bd5f3f36 100644
--- a/examples/low-poly-art/Cargo.toml
+++ b/examples/low-poly-art/Cargo.toml
@@ -14,9 +14,11 @@ fframes_test_utils = { path = "../../fframes-test-utils" }
# `--renderer cpu|skia-cpu|gpu`: Skia on Metal on macOS, on Vulkan everywhere else
[target.'cfg(target_os = "macos")'.dependencies]
fframes_skia_renderer = { workspace = true, features = ["metal", "cli"] }
+fframes_native_player = { workspace = true, features = ["metal", "audio"] }
[target.'cfg(not(any(target_os = "macos", target_arch = "wasm32")))'.dependencies]
fframes_skia_renderer = { workspace = true, features = ["vulkan", "cli"] }
+fframes_native_player = { workspace = true, features = ["vulkan", "audio"] }
# Keep FFmpeg source fallbacks portable across CI runner CPUs (see README).
[target.'cfg(not(any(target_arch = "wasm32", windows)))'.dependencies]
diff --git a/examples/low-poly-art/src/main.rs b/examples/low-poly-art/src/main.rs
index 5c20341a..23d9cc0e 100644
--- a/examples/low-poly-art/src/main.rs
+++ b/examples/low-poly-art/src/main.rs
@@ -29,6 +29,7 @@ fn main() -> ExitCode {
cache_capacity: 5,
..Default::default()
})
+ .preview(fframes_native_player::cli_preview)
.renderers(SkiaRenderers::default())
.run()
}
diff --git a/examples/marketing/Cargo.toml b/examples/marketing/Cargo.toml
index 8f681a11..093400bb 100644
--- a/examples/marketing/Cargo.toml
+++ b/examples/marketing/Cargo.toml
@@ -13,9 +13,11 @@ futures = "0.3.17"
# `--renderer cpu|skia-cpu|gpu`: Skia on Metal on macOS, on Vulkan everywhere else
[target.'cfg(target_os = "macos")'.dependencies]
fframes_skia_renderer = { workspace = true, features = ["metal", "cli"] }
+fframes_native_player = { workspace = true, features = ["metal", "audio"] }
[target.'cfg(not(any(target_os = "macos", target_arch = "wasm32")))'.dependencies]
fframes_skia_renderer = { workspace = true, features = ["vulkan", "cli"] }
+fframes_native_player = { workspace = true, features = ["vulkan", "audio"] }
# FFmpeg codecs, portable so cached source builds work across CI runner CPUs. Windows
# links a prebuilt FFmpeg instead (see README).
diff --git a/examples/marketing/src/main.rs b/examples/marketing/src/main.rs
index 242ccde0..d6e1b8d6 100644
--- a/examples/marketing/src/main.rs
+++ b/examples/marketing/src/main.rs
@@ -26,6 +26,7 @@ fn main() -> ExitCode {
cache_capacity: 30,
..Default::default()
})
+ .preview(fframes_native_player::cli_preview)
.renderers(SkiaRenderers::default())
.run()
}
diff --git a/examples/podcast/Cargo.toml b/examples/podcast/Cargo.toml
index 9480441f..737ad556 100644
--- a/examples/podcast/Cargo.toml
+++ b/examples/podcast/Cargo.toml
@@ -9,9 +9,11 @@ fframes.workspace = true
# `--renderer cpu|skia-cpu|gpu`: Skia on Metal on macOS, on Vulkan everywhere else
[target.'cfg(target_os = "macos")'.dependencies]
fframes_skia_renderer = { workspace = true, features = ["metal", "cli"] }
+fframes_native_player = { workspace = true, features = ["metal", "audio"] }
[target.'cfg(not(any(target_os = "macos", target_arch = "wasm32")))'.dependencies]
fframes_skia_renderer = { workspace = true, features = ["vulkan", "cli"] }
+fframes_native_player = { workspace = true, features = ["vulkan", "audio"] }
# FFmpeg codecs, portable so cached source builds work across CI runner CPUs. Windows
# links a prebuilt FFmpeg instead (see README).
diff --git a/examples/podcast/src/main.rs b/examples/podcast/src/main.rs
index 9e67ee84..8f93eb14 100644
--- a/examples/podcast/src/main.rs
+++ b/examples/podcast/src/main.rs
@@ -23,6 +23,7 @@ fn main() -> ExitCode {
..Default::default()
},
)
+ .preview(fframes_native_player::cli_preview)
.renderers(SkiaRenderers::default())
.run()
}
diff --git a/examples/svg-in-3d/Cargo.toml b/examples/svg-in-3d/Cargo.toml
index 6a9addef..df3e8049 100644
--- a/examples/svg-in-3d/Cargo.toml
+++ b/examples/svg-in-3d/Cargo.toml
@@ -11,10 +11,12 @@ fframes = { workspace = true, features = ["3d", "wgpu"] }
# Skia on Metal on macOS, on Vulkan everywhere else.
[target.'cfg(target_os = "macos")'.dependencies]
fframes_skia_renderer = { workspace = true, features = ["metal"] }
+fframes_native_player = { workspace = true, features = ["metal", "audio"] }
[target.'cfg(not(any(target_os = "macos", target_arch = "wasm32")))'.dependencies]
# `wgpu`: the svgr images and the 3D render on the Vulkan device of Skia and stay on the GPU
fframes_skia_renderer = { workspace = true, features = ["vulkan", "wgpu"] }
+fframes_native_player = { workspace = true, features = ["vulkan", "audio"] }
[features]
default = ["renderer"]
diff --git a/examples/svg-in-3d/src/main.rs b/examples/svg-in-3d/src/main.rs
index 642a3d70..21f452c6 100644
--- a/examples/svg-in-3d/src/main.rs
+++ b/examples/svg-in-3d/src/main.rs
@@ -29,10 +29,12 @@ fn main() -> ExitCode {
..Default::default()
};
+ let preview = matches!(args.command, Some(cli::Command::Preview(_)));
let command = cli::new(&video, options)
.args(args)
+ .preview(fframes_native_player::cli_preview)
.default_output("out.mp4");
- if cpu {
+ if cpu || preview {
return command.run();
}
diff --git a/examples/tiktok/Cargo.toml b/examples/tiktok/Cargo.toml
index 22602c5d..240ed22a 100644
--- a/examples/tiktok/Cargo.toml
+++ b/examples/tiktok/Cargo.toml
@@ -11,9 +11,11 @@ libm="0.2.8"
# `--renderer cpu|skia-cpu|gpu`: Skia on Metal on macOS, on Vulkan everywhere else
[target.'cfg(target_os = "macos")'.dependencies]
fframes_skia_renderer = { workspace = true, features = ["metal", "cli"] }
+fframes_native_player = { workspace = true, features = ["metal", "audio"] }
[target.'cfg(not(any(target_os = "macos", target_arch = "wasm32")))'.dependencies]
fframes_skia_renderer = { workspace = true, features = ["vulkan", "cli"] }
+fframes_native_player = { workspace = true, features = ["vulkan", "audio"] }
# FFmpeg codecs, portable so cached source builds work across CI runner CPUs. Windows
# links a prebuilt FFmpeg instead (see README).
diff --git a/examples/tiktok/src/main.rs b/examples/tiktok/src/main.rs
index d26fc848..c2072856 100644
--- a/examples/tiktok/src/main.rs
+++ b/examples/tiktok/src/main.rs
@@ -34,6 +34,7 @@ fn main() -> ExitCode {
..Default::default()
})
.default_output("out.webm")
+ .preview(fframes_native_player::cli_preview)
.renderers(SkiaRenderers::default())
.run()
}
diff --git a/justfile b/justfile
index 6bc0fead..60b56846 100644
--- a/justfile
+++ b/justfile
@@ -39,6 +39,10 @@ run example:
just start-example {{example}} &
just watch-editor
+# Open the native preview window (extra arguments go to the preview CLI)
+preview example *ARGS:
+ cd examples/{{quote(example)}} && cargo run --release -- preview {{ARGS}}
+
render example *ARGS:
cd examples/{{example}} && cargo run --release {{ARGS}} && just play {{example}}