configure encoder
This commit is contained in:
parent
87fd8c63eb
commit
34c19268df
1 changed files with 8 additions and 2 deletions
|
@ -3,7 +3,7 @@ use std::{net::SocketAddr, result, sync::Arc, thread::{self, sleep}, time::Durat
|
||||||
use image::{ImageBuffer, Rgb};
|
use image::{ImageBuffer, Rgb};
|
||||||
use nokhwa::{pixel_format::RgbFormat, utils::{ApiBackend, RequestedFormat, RequestedFormatType, Resolution}, Camera};
|
use nokhwa::{pixel_format::RgbFormat, utils::{ApiBackend, RequestedFormat, RequestedFormatType, Resolution}, Camera};
|
||||||
use anyhow::{Context, Ok, Result};
|
use anyhow::{Context, Ok, Result};
|
||||||
use openh264::{encoder::Encoder, formats::{RgbSliceU8, YUVBuffer}, nal_units};
|
use openh264::{encoder::{Encoder, EncoderConfig, UsageType}, formats::{RgbSliceU8, YUVBuffer}, nal_units, OpenH264API};
|
||||||
use tokio::{io::AsyncWriteExt, net::{TcpListener, TcpStream}, runtime::Runtime, sync::{Notify, RwLock}, task::LocalSet};
|
use tokio::{io::AsyncWriteExt, net::{TcpListener, TcpStream}, runtime::Runtime, sync::{Notify, RwLock}, task::LocalSet};
|
||||||
|
|
||||||
fn main() -> Result<()>{
|
fn main() -> Result<()>{
|
||||||
|
@ -58,7 +58,13 @@ async fn camera_manager(await_frame: Arc<Notify>, latest_frame: Arc<RwLock<YUVBu
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn stream_video(await_frame: Arc<Notify>, latest_frame: Arc<RwLock<YUVBuffer>>, mut client: TcpStream) -> Result<()>{
|
async fn stream_video(await_frame: Arc<Notify>, latest_frame: Arc<RwLock<YUVBuffer>>, mut client: TcpStream) -> Result<()>{
|
||||||
let mut encoder = Encoder::new()?;
|
|
||||||
|
let mut encoder = Encoder::with_api_config(
|
||||||
|
OpenH264API::from_source(),
|
||||||
|
EncoderConfig::new()
|
||||||
|
.usage_type(UsageType::CameraVideoRealTime
|
||||||
|
))?;
|
||||||
|
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
await_frame.notified().await;
|
await_frame.notified().await;
|
||||||
|
|
Loading…
Reference in a new issue