bevy-capture
Skill16 starsChanged 3 months agoMITView on GitHub
Use when adding `CapturePlugin`, attaching `CaptureBundle` and `RenderTarget::target_headless` to a camera, starting or stopping `Capture`, choosing `Mp4Openh264Encoder`/`Mp4FfmpegCliPipeEncoder`/`FramesEncoder`, or diagnosing empty off-screen recordings in Bevy 0.19.
In this repository33 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- bevy-a11ySkill
- bevy-animationSkill
- bevy-assetsSkill
- bevy-audioSkill
- bevy-camerasSkill
- bevy-cargo-featuresSkill
- bevy-core-conceptsSkill
- bevy-custom-assetsSkill
- bevy-diagnostics-profilingSkill
- bevy-ecs-componentsSkill
- bevy-ecs-queriesSkill
- bevy-ecs-systemsSkill
- bevy-fluentSkill
- bevy-input-actionsSkill
- bevy-migration-0-17-to-0-18Skill
- bevy-migration-0-18-to-0-19Skill
- bevy-pbr-materialsSkill
- bevy-physicsSkill
- bevy-portingSkill
- bevy-renderingSkill
- bevy-save-loadSkill
- bevySkill
- bevy-testingSkill
- bevy-uiSkill
- bevy-vfxSkill
- bevy-voxel-dataSkill
- bevy-voxel-pipelineSkill
- bevy-voxel-runtimeSkill
- bevy-wasm-webgpuSkill
- similarity-rsSkill
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 123
Wait at least one frame before starting.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
bevy-capture — recording Bevy 0.19 cameras
When to use this skill
- Record deterministic gameplay, cinematics, or render-test evidence.
- Capture a headless
Camera2d/Camera3dto MP4, GIF, or numbered PNGs. - Choose between in-process OpenH264, ffmpeg, and lossless frame output.
- Diagnose a missing encoder module, an empty output, or an unflushed recording.
bevy_capture = "0.6" natively targets Bevy 0.19. Do not carry forward the
0.4.x Bevy patch or its old CameraTargetHeadless API.
Canonical pattern
[dependencies]
bevy = "0.19"
bevy_capture = { version = "0.6", features = ["mp4_openh264"] }use bevy::{
app::{RunMode, ScheduleRunnerPlugin},
camera::RenderTarget,
prelude::*,
render::RenderPlugin,
winit::WinitPlugin,
};
use bevy_capture::{
encoder::mp4_openh264::Mp4Openh264Encoder,
Capture, CaptureBundle, CapturePlugin, RenderTargetHeadless,
};
use std::fs::{self, File};
const WIDTH: u16 = 1280;
const HEIGHT: u16 = 720;
fn main() -> AppExit {
App::new()
.add_plugins((
DefaultPlugins.build().disable::<WinitPlugin>().set(RenderPlugin {
synchronous_pipeline_compilation: true,
..default()
}),
ScheduleRunnerPlugin {
run_mode: RunMode::Loop { wait: None },
},
CapturePlugin,
))
.add_systems(Startup, setup)
.add_systems(Update, record)
.run()
}
fn setup(mut commands: Commands, mut images: ResMut<Assets<Image>>) {
commands.spawn((
Camera2d,
RenderTarget::target_headless(WIDTH.into(), HEIGHT.into(), &mut images),
CaptureBundle::default(),
));
}
fn record(
mut captures: Query<&mut Capture>,
mut waited_for_pipeline: Local<bool>,
mut frame: Local<u32>,
) {
// Allow the render pipeline one frame to become ready.
if !*waited_for_pipeline {
*waited_for_pipeline = true;
return;
}
let Ok(mut capture) = captures.single_mut() else { return };
if !capture.is_capturing() && *frame == 0 {
fs::create_dir_all("captures").expect("create captures directory");
let encoder = Mp4Openh264Encoder::new(
File::create("captures/run.mp4").expect("create output"),
WIDTH,
HEIGHT,
)
.expect("initialize OpenH264");
capture.start(encoder);
}
*frame += 1;
if *frame == 300 {
capture.stop(); // drops the encoder and finalizes the MP4
}
}Encoder choice
| Encoder | Feature | External program | Best fit |
Mp4Openh264Encoder | mp4_openh264 | No | In-process H.264 |
Mp4FfmpegCliEncoder | mp4_ffmpeg_cli | ffmpeg | Short/offline clips |
Mp4FfmpegCliPipeEncoder | mp4_ffmpeg_cli_pipe | ffmpeg | Long streaming captures |
GifEncoder | gif | No | Small previews |
FramesEncoder | none | No | Lossless PNG sequence |
See encoder details before choosing a production codec or distribution model.
Gotchas
RenderTargetHeadlessis implemented forRenderTarget; callRenderTarget::target_headless(...). The old helper onCamerais stale.- Attach
Camera2d/Camera3d, the headlessRenderTarget, andCaptureBundleto the same entity. - Wait at least one frame before starting. Synchronous pipeline compilation improves deterministic batch capture but can increase startup time.
- Encoder modules are feature-gated. Enable exactly the features you import.
Capture::stop()or droppingCapturefinalizes encoders. Abrupt process termination can leave an invalid MP4 or GIF.- The ffmpeg encoders require
ffmpegonPATH; constructors returnResult. - Match the encoder dimensions to the headless target. OpenH264 takes
u16. - Browser WASM has no ordinary filesystem or child processes. Design an explicit JS download/streaming path instead of assuming these encoders work.
See also
bevy-cameras— cameras and render targets.bevy-cargo-features— feature selection.bevy-wasm-webgpu— browser constraints.- Encoder comparison.
- 0.19 compatibility.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

