Adaptive extra splits (#584)

* Adds adaptive extra splits

* docs

* correction

* squize

* more squize
This commit is contained in:
Zen 2022-03-05 14:43:10 +02:00 committed by GitHub
parent ed289eca66
commit f66a805256
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 12 deletions

View file

@ -88,7 +88,7 @@ With your own parameters:
-s --scenes File to save/read scenes.
-x --extra-split Size of chunk after which it will be split [default: 240]
-x --extra-split Size of chunk after which it will be split [default: fps * 10]
--min-scene-len Specifies the minimum number of frames in each split.

View file

@ -213,13 +213,8 @@ pub struct CliOpts {
/// When a scenecut is found whose distance to the previous scenecut is greater than the value
/// specified by this option, one or more extra splits (scenecuts) are added. Set this option
/// to 0 to disable adding extra splits.
#[clap(
short = 'x',
long,
default_value_t = 240,
help_heading = "SCENE DETECTION"
)]
pub extra_split: usize,
#[clap(short = 'x', long, help_heading = "SCENE DETECTION")]
pub extra_split: Option<usize>,
/// Minimum number of frames for a scenecut
#[clap(long, default_value_t = 24, help_heading = "SCENE DETECTION")]
@ -514,10 +509,14 @@ pub fn parse_cli(args: CliOpts) -> anyhow::Result<EncodeArgs> {
chunk_order: args.chunk_order,
concat: args.concat,
encoder: args.encoder,
extra_splits_len: if args.extra_split > 0 {
Some(args.extra_split)
} else {
None
extra_splits_len: match args.extra_split {
Some(0) => None,
Some(x) => Some(x),
// Make sure it's at least 10 seconds
None => match input.frame_rate() {
Ok(fps) => Some((fps * 10.0) as usize),
Err(_) => Some(240_usize),
},
},
photon_noise: args.photon_noise,
sc_pix_format: args.sc_pix_format,