GithubHelp home page GithubHelp logo

slyedoc / bevy_capture_media Goto Github PK

View Code? Open in Web Editor NEW

This project forked from commander-lol/bevy_capture_media

0.0 0.0 0.0 69 KB

Event based image & video capture for Bevy

License: Apache License 2.0

Rust 100.00%

bevy_capture_media's Introduction

bevy_capture_media

Event based image & video capture for Bevy

Bevy tracking Crates.io docs.rs

Features

  • Track any number of cameras for recording
  • Dispatch events to control the recording lifecycle
  • Keep a frame buffer of the past X frames for each recorder (Where X is any user supplied Duration)
  • Pick and choose the formats you want to record with features
  • wasm support

Supported Formats

  • PNG screenshots
  • GIF recordings
    • GIF Recordings are functional but require work

Roadmap

  • Perspective camera support
  • Support for viewports
  • Support for resizing cameras
  • More formats
  • More control over frame smuggling
  • Screenshot watermarks
  • Improved web performance

A Simple Example

use std::time::Duration;
use bevy::prelude::*;
use bevy_capture_media::{MediaCapture, BevyCapturePlugin};

pub fn spawn_cameras(
    mut commands: Commands,
    mut capture: MediaCapture,
) {
    let camera_entity = commands
        .spawn_bundle(Camera2dBundle::default())
        .id();
        
    // The tracking ID (1357) is arbitrary, but uniquely identifies this tracker
    capture.start_tracking_camera(1357, camera_entity, Duration::from_secs(5));
}

pub fn take_screenshot(
    input: Res<Input<KeyCode>>,
    mut capture: MediaCapture,
) {
    if input.just_released(KeyCode::RShift) {
        // If you have many cameras, consider storing their IDs
        // in a resource
        capture.capture_png(1357);
    }
}

fn main() {
    App::new()
        .add_plugin(DefaultPlugins)
        .add_plugin(bevy_capture_media::BevyCapturePlugin)
        .add_startup_system(spawn_cameras)
        .add_system(take_screenshot)
        .run();
}
2022-08-12.22-36-28.mp4

Contributing

All suggestions, issues, and pull requests are welcome. Any contributions must be licensed compatibly with this repository.

I want to add a new format!

Yes! This is great! There is a small checklist that any new format will need to meet to be included:

  • Encoding must happen in pure rust. No compiled C libraries, no bindings to other languages.
  • The format must perform well for a web target - if there is a very good reason to circumvent this, the format may still be accepted.
  • By default, the format and any dependencies must be optional and opt-in.
  • No patent-encumbered or closed formats will be accepted unless there is a free and permissive license grant for this project and any end users.

Asset Licenses

The git repository contains some assets for the examples. They are licensed from their original creators with the following licenses:

bevy_capture_media's People

Contributors

commander-lol avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.