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);
trace!(
"scaling {:?} to {:?} to fit {:?}",
source,
result,
self.render_size
source, result, self.render_size
);
result
}

View file

@ -92,7 +92,8 @@ fn pixels_video(
) {
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
.streams()
@ -103,7 +104,9 @@ fn pixels_video(
let context_decoder = ffmpeg::codec::context::Context::from_parameters(input.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");
let src_width = decoder.width();
@ -117,7 +120,8 @@ fn pixels_video(
src_width,
src_height,
ffmpeg::software::scaling::Flags::BILINEAR,
).expect("failed to create scaling context");
)
.expect("failed to create scaling context");
let mut frame_index = 0;
@ -128,14 +132,16 @@ fn pixels_video(
let mut decoded = ffmpeg::util::frame::video::Video::empty();
let mut rgb_frame = ffmpeg::util::frame::video::Video::empty();
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");
let image = RgbImage::from_raw(src_width, src_height, rgb_frame.data(0).to_owned())
.expect("could not read rgb data to image");
let image = DynamicImage::from(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");
frame_index += 1;
@ -145,13 +151,13 @@ fn pixels_video(
for (stream, packet) in ictx.packets() {
if stream.index() == video_stream_index {
decoder.send_packet(&packet)
decoder
.send_packet(&packet)
.expect("failed to send video packet");
receive_and_process_decoded_frames(&mut decoder)
.expect("failed to process video packet");
}
}
decoder.send_eof().expect("failed to send eof");
receive_and_process_decoded_frames(&mut decoder)
.expect("failed to eof packet");
receive_and_process_decoded_frames(&mut decoder).expect("failed to eof packet");
}

View file

@ -4,7 +4,9 @@ use servicepoint::*;
use std::thread::sleep;
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 {
connection,
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 scap::{
capturer::{Capturer, Options},
frame::convert_bgra_to_rgb,
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};
pub fn stream_window(