nix fmt
All checks were successful
Rust / build (push) Successful in 9m25s

This commit is contained in:
Vinzenz Schroeter 2025-12-04 20:10:21 +01:00
parent 0543c8b3f1
commit fa892558f1
4 changed files with 22 additions and 16 deletions

View file

@ -164,9 +164,7 @@ impl ImageProcessingPipeline {
let result = (width, height); let result = (width, height);
trace!( trace!(
"scaling {:?} to {:?} to fit {:?}", "scaling {:?} to {:?} to fit {:?}",
source, source, result, self.render_size
result,
self.render_size
); );
result result
} }

View file

@ -92,7 +92,8 @@ fn pixels_video(
) { ) {
ffmpeg::init().unwrap(); ffmpeg::init().unwrap();
let mut ictx = ffmpeg::format::input(&options.file_name).expect("failed to open video input file"); let mut ictx =
ffmpeg::format::input(&options.file_name).expect("failed to open video input file");
let input = ictx let input = ictx
.streams() .streams()
@ -103,12 +104,14 @@ fn pixels_video(
let context_decoder = ffmpeg::codec::context::Context::from_parameters(input.parameters()) let context_decoder = ffmpeg::codec::context::Context::from_parameters(input.parameters())
.expect("could not extract video context from parameters"); .expect("could not extract video context from parameters");
let mut decoder = context_decoder.decoder().video() let mut decoder = context_decoder
.decoder()
.video()
.expect("failed to create decoder for video stream"); .expect("failed to create decoder for video stream");
let src_width = decoder.width(); let src_width = decoder.width();
let src_height = decoder.height(); let src_height = decoder.height();
let mut scaler = ffmpeg::software::scaling::Context::get( let mut scaler = ffmpeg::software::scaling::Context::get(
decoder.format(), decoder.format(),
src_width, src_width,
@ -117,7 +120,8 @@ fn pixels_video(
src_width, src_width,
src_height, src_height,
ffmpeg::software::scaling::Flags::BILINEAR, ffmpeg::software::scaling::Flags::BILINEAR,
).expect("failed to create scaling context"); )
.expect("failed to create scaling context");
let mut frame_index = 0; let mut frame_index = 0;
@ -128,14 +132,16 @@ fn pixels_video(
let mut decoded = ffmpeg::util::frame::video::Video::empty(); let mut decoded = ffmpeg::util::frame::video::Video::empty();
let mut rgb_frame = ffmpeg::util::frame::video::Video::empty(); let mut rgb_frame = ffmpeg::util::frame::video::Video::empty();
while decoder.receive_frame(&mut decoded).is_ok() { while decoder.receive_frame(&mut decoded).is_ok() {
scaler.run(&decoded, &mut rgb_frame) scaler
.run(&decoded, &mut rgb_frame)
.expect("failed to scale frame"); .expect("failed to scale frame");
let image = RgbImage::from_raw(src_width, src_height, rgb_frame.data(0).to_owned()) let image = RgbImage::from_raw(src_width, src_height, rgb_frame.data(0).to_owned())
.expect("could not read rgb data to image"); .expect("could not read rgb data to image");
let image = DynamicImage::from(image); let image = DynamicImage::from(image);
let bitmap= processing_pipeline.process(image); let bitmap = processing_pipeline.process(image);
connection.send_command(BitmapCommand::from(bitmap)) connection
.send_command(BitmapCommand::from(bitmap))
.expect("failed to send image command"); .expect("failed to send image command");
frame_index += 1; frame_index += 1;
@ -145,13 +151,13 @@ fn pixels_video(
for (stream, packet) in ictx.packets() { for (stream, packet) in ictx.packets() {
if stream.index() == video_stream_index { if stream.index() == video_stream_index {
decoder.send_packet(&packet) decoder
.send_packet(&packet)
.expect("failed to send video packet"); .expect("failed to send video packet");
receive_and_process_decoded_frames(&mut decoder) receive_and_process_decoded_frames(&mut decoder)
.expect("failed to process video packet"); .expect("failed to process video packet");
} }
} }
decoder.send_eof().expect("failed to send eof"); decoder.send_eof().expect("failed to send eof");
receive_and_process_decoded_frames(&mut decoder) receive_and_process_decoded_frames(&mut decoder).expect("failed to eof packet");
.expect("failed to eof packet");
} }

View file

@ -4,7 +4,9 @@ use servicepoint::*;
use std::thread::sleep; use std::thread::sleep;
pub(crate) fn stream_stdin(connection: &Transport, slow: bool) { pub(crate) fn stream_stdin(connection: &Transport, slow: bool) {
warn!("This mode will break when using multi-byte characters and does not support ANSI escape sequences yet."); warn!(
"This mode will break when using multi-byte characters and does not support ANSI escape sequences yet."
);
let mut app = App { let mut app = App {
connection, connection,
mirror: CharGrid::new(TILE_WIDTH, TILE_HEIGHT), mirror: CharGrid::new(TILE_WIDTH, TILE_HEIGHT),

View file

@ -7,10 +7,10 @@ use image::{DynamicImage, ImageBuffer, Rgb, Rgba};
use log::{debug, error, info, trace, warn}; use log::{debug, error, info, trace, warn};
use scap::{ use scap::{
capturer::{Capturer, Options}, capturer::{Capturer, Options},
frame::convert_bgra_to_rgb,
frame::Frame, frame::Frame,
frame::convert_bgra_to_rgb,
}; };
use servicepoint::{BitmapCommand, CompressionCode, Origin, FRAME_PACING}; use servicepoint::{BitmapCommand, CompressionCode, FRAME_PACING, Origin};
use std::time::{Duration, Instant}; use std::time::{Duration, Instant};
pub fn stream_window( pub fn stream_window(