Skip to content

Conversation

@Loufe
Copy link

@Loufe Loufe commented Jan 1, 2026

Add --log-interval option to control progress logging frequency when running non-interactively (stderr not a TTY).

Accepts:

  • Duration: --log-interval 30s
  • Percentage: --log-interval 2%

Default behavior (exponential backoff) unchanged when flag is omitted.

The current exponential backoff (16s, 32s, 64s, 128s...) creates very long gaps for large encodes, making it difficult for wrapper applications to provide responsive progress feedback.

Passes linting, automated tests, and I built a windows .exe and ran it successfully multiple times without issue with my project.

Thanks for the project, Alex, it's been such a joy building a wrapper around it.

@alexheretic
Copy link
Owner

Hmmm logging isn't for machine reading though, they're for humans. I think there should probably be a machine output, like sample-encode's json output, that includes progress updates too. This would be designed to output all state changes and be appropriate for a machine usage.

If we had that there probably won't be a use case for tweaking logging frequency.

@Loufe
Copy link
Author

Loufe commented Jan 3, 2026

Good point. Happy to provide either a new PR or a modification of this PR with a draft format.

I'm not sure this would change the need for log frequency changes, though. I often manually review the logs, so having some degree of control over the speed of logging frequency still feels like a plus. I would argue both together constitute my ideal scenario.

What's your thinking?

Comment on lines 40 to 43
/// Interval between progress log messages when running non-interactively.
/// Accepts duration (e.g., "30s", "1m") or percentage (e.g., "2%").
#[arg(long)]
pub log_interval: Option<LogInterval>,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does make sense to define this in multiple places, indeed this arg would apply to all commands that log progress updates which is pretty much all of them so it should be defined once and included with clap(flatten) like the encode args are.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created shared ProgressLog struct in args.rs, flattened into encode and auto_encode.

(None, key) => {
let b = Instant::now();
let mut logger = ProgressLogger::new(module_path!(), b);
let mut logger = ProgressLogger::new(module_path!(), b, None);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

log control args should affect this, and all other, loggers.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added --log-interval to vmaf and xpsnr commands. Left sample_encode on exponential backoff — it runs many short (~20s) samples during CRF search where percentage logging would create noise.

Comment on lines 41 to 42
/// Interval between progress log messages when running non-interactively.
/// Accepts duration (e.g., "30s", "1m") or percentage (e.g., "2%").
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docs should mention the default is logging exponentially increasing gaps

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, good point

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added: "Default: exponentially increasing intervals (16s, 32s, 64s, ...)"

src/log.rs Outdated
Comment on lines 37 to 41
let secs: u64 = s
.parse()
.map_err(|_| anyhow::anyhow!("invalid interval: {s}"))?;
ensure!(secs > 0, "interval must be greater than 0");
Ok(Self::Duration(Duration::from_secs(secs)))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think plain integers should be interpreted as seconds, should just be the humantime format or fail.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed. Now requires explicit format: 30s, 1m, or 5%.

@alexheretic
Copy link
Owner

I don't see much use for this myself, but I'm ok with merging if you think it is useful.

I've left some comments, in particular I think the arg should be available in all commands that log progress updates.


/// Interval between progress log messages when running non-interactively.
/// Accepts duration (e.g., "30s", "1m") or percentage (e.g., "2%").
#[arg(long)]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this should also have an associated env var too? E.g. AB_AV1_LOG_INTERVAL ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added AB_AV1_LOG_INTERVAL.

@Loufe
Copy link
Author

Loufe commented Jan 3, 2026

I'll start work right now, thanks, Alex!

Would you like the machine-readable format change in a separate PR or merged?

@alexheretic
Copy link
Owner

Would you like the machine-readable format change in a separate PR

Yeah I think the machine format should be separate. There was some discussion in #313 (comment) it might be good to propose a json structure for crf-search output and updates there first.

Address maintainer feedback on --log-interval implementation:

- Consolidate log_interval into shared ProgressLog struct (clap flatten)
- Add --log-interval to vmaf and xpsnr commands
- Add AB_AV1_LOG_INTERVAL env var support
- Remove plain integer parsing; require explicit format (30s, 1m, 5%)
- Document default exponential backoff behavior in help text

sample_encode retains exponential backoff for its short batch operations.
@Loufe
Copy link
Author

Loufe commented Jan 3, 2026

Should be good to go, Alex, passes tests/formatting on my end.

@hashhar
Copy link

hashhar commented Jan 5, 2026

I added streaming JSON output for crf-search recently in a PR (see #336), would that be a better approach long term?

I'll be happy to add it for the other commands too - I only tackled crf-search for now since that's one of the "building block" commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants