bevy_video

Crates.iobevy_video
lib.rsbevy_video
version0.9.1
sourcesrc
created_at2023-01-18 20:31:35.449166
updated_at2023-01-18 20:39:10.166302
descriptionDecode and render h264 video in Bevy
homepage
repositoryhttps://github.com/PortalCloudInc/bevy_video
max_upload_size
id762027
size9,645
Brandon Dyer (BrandonDyer64)

documentation

README

Bevy Video

Stream or play video in your Bevy app!

use bevy::prelude::*;
use bevy_video::prelude::*;

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_plugin(VideoPlugin)
        .add_startup_system(setup)
        .add_system(push_frame)
        .run();
}

fn setup(
    mut commands: Commands,
    mut images: ResMut<Assets<Image>>,
) {
    let (image_handle, video_decoder) = VideoDecoder::create(&mut images);

    // decoder
    commands.spawn(video_decoder);

    // ...
}

fn push_frame(
    decoders: Query<&VideoDecoder>,
    mut materials: ResMut<Assets<MaterialThatUsesTheImage>>,
) {
    for _ in materials.iter_mut() {
        // otherwise the image on screen wont update
    }

    for decoder in decoders.iter() {
        decoder.add_video_packet(/* Vec<u8> representing an H.264 packet */);

        // Note: packets are decoded asynchronously in another thread
        // The Images will update automatically
    }
}
Commit count: 6

cargo fmt