Skip to content

Commit d39dc08

Browse files
committed
add tracing
1 parent 0bb0c40 commit d39dc08

15 files changed

+249
-44
lines changed

Cargo.lock

+200-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

aurora-cli/Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ edition = "2021"
77
aurora-core = { path = "../aurora-core" }
88
dotenv = "0.15"
99
glob = "0.3"
10+
tracing = "0.1"
11+
tracing-subscriber = "0.3"

aurora-cli/src/lib.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -10,35 +10,35 @@ fn get_j() -> String {
1010

1111
pub fn run(video_filename: &str, target_frame_rate: usize) {
1212
let origin_frame_rate = aurora_core::get_origin_frame_rate(video_filename);
13-
println!("origin_frame_rate: {origin_frame_rate}");
13+
tracing::info!("origin_frame_rate: {origin_frame_rate}");
1414

1515
let frame_multiple = (target_frame_rate as f32 / origin_frame_rate).ceil() as usize;
16-
println!("frame_multiple: {frame_multiple}");
16+
tracing::info!("frame_multiple: {frame_multiple}");
1717
if frame_multiple <= 1 {
18-
println!("frame_multiple <= 1, skip");
18+
tracing::info!("frame_multiple <= 1, skip");
1919
return;
2020
}
2121

2222
let video_extract_audio_filename = aurora_core::extract_audio(video_filename);
23-
println!("video_extract_audio_filename: {video_extract_audio_filename}");
23+
tracing::info!("video_extract_audio_filename: {video_extract_audio_filename}");
2424

2525
let video_frames_dir_name = aurora_core::video_frames_dir_mkdir(video_filename);
26-
println!("video_frames_dir_name: {video_frames_dir_name}");
26+
tracing::info!("video_frames_dir_name: {video_frames_dir_name}");
2727

2828
aurora_core::decode_frames(video_filename, &video_frames_dir_name);
2929

3030
let origin_frame_count = aurora_core::get_origin_frame_count(&video_frames_dir_name);
31-
println!("origin_frame_count: {origin_frame_count}");
31+
tracing::info!("origin_frame_count: {origin_frame_count}");
3232

3333
let target_frame_count = frame_multiple * origin_frame_count;
34-
println!("target_frame_count: {target_frame_count}");
34+
tracing::info!("target_frame_count: {target_frame_count}");
3535

3636
let video_interpolate_frames_dir_name =
3737
aurora_core::video_interpolate_frames_dir_mkdir(video_filename);
38-
println!("video_interpolate_frames_dir_name: {video_interpolate_frames_dir_name}");
38+
tracing::info!("video_interpolate_frames_dir_name: {video_interpolate_frames_dir_name}");
3939

4040
let j = get_j();
41-
println!("j: {j}");
41+
tracing::info!("j: {j}");
4242

4343
aurora_core::interpolate_frame(
4444
target_frame_count,
@@ -48,7 +48,7 @@ pub fn run(video_filename: &str, target_frame_rate: usize) {
4848
);
4949

5050
let target_frame_rate = frame_multiple as f32 * origin_frame_rate;
51-
println!("target_frame_rate: {target_frame_rate}");
51+
tracing::info!("target_frame_rate: {target_frame_rate}");
5252

5353
aurora_core::encode_video(
5454
target_frame_rate,

aurora-cli/src/main.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,27 @@
11
fn main() {
22
dotenv::dotenv().ok();
33

4+
tracing_subscriber::fmt::init();
5+
46
let video_glob = std::env::var("VIDEO_GLOB").expect("VICEO_GLOB must be set");
5-
println!("video_glob: {video_glob}");
7+
tracing::info!("video_glob: {video_glob}");
68

79
let path_list = glob::glob(&video_glob)
810
.expect("failed to read glob pattern")
911
.filter_map(|e| e.ok())
1012
.map(|path| path.to_str().unwrap_or("").to_owned())
1113
.filter(|s| !s.is_empty())
1214
.collect::<Vec<String>>();
13-
println!("path_list: {path_list:?}");
15+
tracing::info!("path_list: {path_list:?}");
1416

1517
for video_filename in path_list {
16-
println!("video_filename: {video_filename}");
18+
tracing::info!("video_filename: {video_filename}");
1719

1820
let target_frame_rate = match std::env::var("TARGET_FRAME_RATE") {
1921
Ok(str) => str.parse::<usize>().unwrap_or(60),
2022
Err(_) => 60,
2123
};
22-
println!("target_frame_rate: {target_frame_rate}");
24+
tracing::info!("target_frame_rate: {target_frame_rate}");
2325

2426
aurora_cli::run(&video_filename, target_frame_rate);
2527
}

aurora-core/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ edition = "2021"
66
[dependencies]
77
regex = "1.7"
88
num_cpus = "1.15"
9+
tracing = "0.1"

aurora-core/src/clean.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@ pub fn clean(
55
) {
66
if !video_extract_audio_filename.is_empty() {
77
let remove_video_extract_audio_result = std::fs::remove_file(video_extract_audio_filename);
8-
println!("remove_video_extract_audio_result: {remove_video_extract_audio_result:?}");
8+
tracing::info!("remove_video_extract_audio_result: {remove_video_extract_audio_result:?}");
99
}
1010

1111
if !video_frames_dir_name.is_empty() {
1212
let remove_video_frames_dir_result = std::fs::remove_dir_all(video_frames_dir_name);
13-
println!("remove_video_frames_dir_result: {remove_video_frames_dir_result:?}");
13+
tracing::info!("remove_video_frames_dir_result: {remove_video_frames_dir_result:?}");
1414
}
1515

1616
if !video_interpolate_frames_dir_name.is_empty() {
1717
let remove_video_interpolate_frames_dir_result =
1818
std::fs::remove_dir_all(video_interpolate_frames_dir_name);
19-
println!("remove_video_interpolate_frames_dir_result: {remove_video_interpolate_frames_dir_result:?}");
19+
tracing::info!("remove_video_interpolate_frames_dir_result: {remove_video_interpolate_frames_dir_result:?}");
2020
}
2121
}

aurora-core/src/decode_frames.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ pub fn decode_frames(video_filename: &str, video_frames_dir_name: &str) {
88
r"ffmpeg/ffmpeg -y -vsync passthrough -i {video_filename} {video_frames_dir_name}/frame_%08d.png"
99
)
1010
};
11-
println!("decode_frames_cmd_str: {decode_frames_cmd_str}");
11+
tracing::info!("decode_frames_cmd_str: {decode_frames_cmd_str}");
1212

1313
let decode_frames_cmd_output = crate::execute_cmd(&decode_frames_cmd_str);
14-
println!("decode_frames_cmd_output: {decode_frames_cmd_output:?}");
14+
tracing::info!("decode_frames_cmd_output: {decode_frames_cmd_output:?}");
1515
}

aurora-core/src/encode_video.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ pub fn encode_video(
77
Ok(str) => str,
88
Err(_) => "libx264".to_owned(),
99
};
10-
println!("video_encoder: {video_encoder}");
10+
tracing::info!("video_encoder: {video_encoder}");
1111
let encode_video_cmd_str = if cfg!(target_os = "windows") {
1212
format!(
1313
r"ffmpeg\ffmpeg.exe -y -framerate {target_frame_rate} -i {video_interpolate_frames_dir_name}/%08d.png -i {video_filename}_audio.m4a -c:a copy -crf 20 -c:v {video_encoder} -pix_fmt yuv420p output_{video_filename}.mp4"
@@ -17,8 +17,8 @@ pub fn encode_video(
1717
r"ffmpeg/ffmpeg -y -framerate {target_frame_rate} -i {video_interpolate_frames_dir_name}/%08d.png -i {video_filename}_audio.m4a -c:a copy -crf 20 -c:v {video_encoder} -pix_fmt yuv420p output_{video_filename}.mp4"
1818
)
1919
};
20-
println!("encode_video_cmd_str: {encode_video_cmd_str}");
20+
tracing::info!("encode_video_cmd_str: {encode_video_cmd_str}");
2121

2222
let encode_video_cmd_output = crate::execute_cmd(&encode_video_cmd_str);
23-
println!("encode_video_cmd_output: {encode_video_cmd_output:?}");
23+
tracing::info!("encode_video_cmd_output: {encode_video_cmd_output:?}");
2424
}

0 commit comments

Comments
 (0)