Crates.io | mjpeg_rs |
lib.rs | mjpeg_rs |
version | 0.0.1 |
source | src |
created_at | 2021-10-07 14:26:16.731128 |
updated_at | 2021-10-07 14:26:16.731128 |
description | rust编写的mjpeg服务器 |
homepage | https://github.com/t924417424/mjpeg_rs |
repository | https://github.com/t924417424/mjpeg_rs |
max_upload_size | |
id | 461811 |
size | 7,783 |
rust mjpeg server
// examples
use std::{sync::Arc, thread};
use mjpeg_rs::MJpeg;
use rascam::*;
fn main() {
let info = info().unwrap();
if info.cameras.len() < 1 {
println!("Found 0 cameras. Exiting");
// note that this doesn't run destructors
::std::process::exit(1);
}
println!("{}", info);
let info = &info.cameras[0];
let mut camera = SimpleCamera::new(info.clone()).unwrap();
let settings = CameraSettings {
encoding: MMAL_ENCODING_JPEG,
width: 600,
height: 600,
iso: ISO_AUTO,
zero_copy: false,
use_encoder: true,
};
camera.configure(settings);
camera.activate().unwrap();
let m = Arc::new(MJpeg::new());
let mrc = m.clone();
thread::spawn(move || mrc.run("0.0.0.0:8088").unwrap());
loop {
let b = camera.take_one().unwrap();
m.update_jpeg(b).unwrap();
}
}