Skip to content

Commit

Permalink
Speed factor for transcode can be floating point
Browse files Browse the repository at this point in the history
  • Loading branch information
williamyang98 committed Jul 23, 2024
1 parent 63d56c4 commit f1011e4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/ffmpeg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ pub struct TranscodeProgress {
pub size_bytes: Option<usize>,
pub total_time_transcoded: Option<Time>,
pub speed_bits: Option<usize>,
pub speed_factor: Option<u32>,
pub speed_factor: Option<f32>,
}

#[derive(Clone,Copy,Debug,Default)]
Expand All @@ -150,7 +150,7 @@ pub enum ParsedStderrLine {
pub fn parse_stderr_line(line: &str) -> Option<ParsedStderrLine> {
lazy_static! {
static ref PROGRESS_REGEX: Regex = Regex::new(format!(
r"size\s*=\s*(\d+)({0})\s+time\s*=\s*({1})\s+bitrate\s*=\s*({2})({3})\/s\s+speed\s*=\s*(\d+)\s*x",
r"size\s*=\s*(\d+)({0})\s+time\s*=\s*({1})\s+bitrate\s*=\s*({2})({3})\/s\s+speed\s*=\s*({2})\s*x",
BYTES_REGEX, TIME_REGEX, FLOAT32_REGEX, BITS_LONG_REGEX,
).as_str()).unwrap();
static ref SOURCE_INFO_REGEX: Regex = Regex::new(format!(
Expand All @@ -177,7 +177,7 @@ pub fn parse_stderr_line(line: &str) -> Option<ParsedStderrLine> {
_ => None,
}
};
let speed_factor: Option<u32> = captures.get(6).and_then(|m| m.as_str().parse().ok());
let speed_factor: Option<f32> = captures.get(6).and_then(|m| m.as_str().parse().ok());
let result = TranscodeProgress {
size_bytes,
total_time_transcoded,
Expand Down
2 changes: 1 addition & 1 deletion src/worker_transcode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub struct TranscodeState {
pub transcode_duration_milliseconds: Option<u64>,
pub transcode_size_bytes: Option<usize>,
pub transcode_speed_bits: Option<usize>,
pub transcode_speed_factor: Option<u32>,
pub transcode_speed_factor: Option<f32>,
}

impl Default for TranscodeState {
Expand Down
2 changes: 1 addition & 1 deletion static/fragments/transcode_progress.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export const TranscodeProgress = {
table.transcode_size = `${size_bytes.toFixed(2)} ${size_bytes_unit}bytes`;
let [bitrate, bitrate_units] = convert_to_short_standard_prefix(this.progress.transcode_speed_bits);
table.transcode_bitrate = `${bitrate.toFixed(2)} ${bitrate_units}b/s`;
table.transcode_speed_factor = this.progress.transcode_speed_factor;
table.transcode_speed_factor = this.progress.transcode_speed_factor.toFixed(2);
}
return table;
},
Expand Down

0 comments on commit f1011e4

Please sign in to comment.