Skip to content

Commit

Permalink
ci fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
admin committed Jan 13, 2025
1 parent cbf4170 commit 6d5f8d8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 19 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,6 @@ jobs:
- name: Build
run: cargo build --no-default-features --features ffmpeg7 --verbose

- name: Run Test
run: cargo test --verbose

test:
runs-on: ubuntu-latest
container: jrottenberg/ffmpeg:7.1-ubuntu
Expand Down
32 changes: 16 additions & 16 deletions examples/decode_frame.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use image::{ImageBuffer, Rgb};
use rsmedia::decode::Decoder;
use std::error::Error;
use tokio::task;
use url::Url;

// use tokio async runtime
// #[tokio::main]
fn main() -> Result<(), Box<dyn Error>> {
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
rsmedia::init()?;

let source = "https://img.qunliao.info/4oEGX68t_9505974551.mp4"
Expand All @@ -25,8 +25,7 @@ fn main() -> Result<(), Box<dyn Error>> {
let mut frame_count = 0;
let mut elapsed_time = 0.0;

// task holding
// let mut tasks = vec![];
let mut tasks = vec![];

for frame in decoder.decode_iter() {
if let Ok((_timestamp, frame)) = frame {
Expand All @@ -42,13 +41,11 @@ fn main() -> Result<(), Box<dyn Error>> {

let frame_path = format!("{}/frame_{:05}.png", output_folder, frame_count);

// use tokio::task;
// let task = task::spawn_blocking(move || {
// img.save(&frame_path).expect("failed to save frame");
// });
// tasks.push(task);
// or:
img.save(&frame_path).expect("failed to save frame");
let task = task::spawn_blocking(move || {
img.save(&frame_path).expect("failed to save frame");
});

tasks.push(task);

frame_count += 1;
elapsed_time += 1.0 / frame_rate;
Expand All @@ -58,10 +55,13 @@ fn main() -> Result<(), Box<dyn Error>> {
}

// Await all tasks to finish
// for task in tasks {
// task.await.expect("task failed");
// }
for task in tasks {
task.await.expect("task failed");
}

println!("Saved {} frames in the '{}' directory", frame_count, output_folder);
println!(
"Saved {} frames in the '{}' directory",
frame_count, output_folder
);
Ok(())
}

0 comments on commit 6d5f8d8

Please sign in to comment.