diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 54cd0c1..bfcc17c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -222,6 +222,12 @@ jobs: target/ci/av1an -i tt_sif.y4m -e aom --pix-format yuv420p -y -o "tt_sif.mkv" -v " --cpu-used=10 --rt --threads=4" -c mkvmerge du -h tt_sif.mkv + - name: Testing sc-only + run: | + target/ci/av1an -i tt_sif.y4m --sc-only --sc-method fast -s "tt_sif_scenes.json" + du -h tt_sif_scenes.json + continue-on-error: true + docker: runs-on: ubuntu-latest steps: diff --git a/av1an-cli/src/lib.rs b/av1an-cli/src/lib.rs index 6c22b8f..6661685 100644 --- a/av1an-cli/src/lib.rs +++ b/av1an-cli/src/lib.rs @@ -188,6 +188,12 @@ pub struct CliOpts { #[clap(long, possible_values = &["standard", "fast"], default_value_t = ScenecutMethod::Standard, help_heading = "SCENE DETECTION")] pub sc_method: ScenecutMethod, + /// Run the scene detection only before exiting + /// + /// Requires a scene file with --scenes. + #[clap(long, requires("scenes"), help_heading = "SCENE DETECTION")] + pub sc_only: bool, + /// Perform scene detection with this pixel format #[clap(long, help_heading = "SCENE DETECTION")] pub sc_pix_format: Option, @@ -553,6 +559,7 @@ pub fn parse_cli(args: CliOpts) -> anyhow::Result { scenes: args.scenes, split_method: args.split_method, sc_method: args.sc_method, + sc_only: args.sc_only, sc_downscale_height: args.sc_downscale_height, target_quality: args.target_quality, verbosity: if args.quiet { diff --git a/av1an-core/src/settings.rs b/av1an-core/src/settings.rs index f4cbc2c..657fdf1 100644 --- a/av1an-core/src/settings.rs +++ b/av1an-core/src/settings.rs @@ -81,6 +81,7 @@ pub struct EncodeArgs { pub split_method: SplitMethod, pub sc_pix_format: Option, pub sc_method: ScenecutMethod, + pub sc_only: bool, pub sc_downscale_height: Option, pub extra_splits_len: Option, pub min_scene_len: usize, @@ -1063,6 +1064,16 @@ properly into a mkv file. Specify mkvmerge as the concatenation method by settin let splits = self.split_routine()?; + if self.sc_only { + debug!("scene detection only"); + + if let Err(e) = fs::remove_dir_all(&self.temp) { + warn!("Failed to delete temp directory: {}", e); + } + + exit(0); + } + let (chunk_queue, total_chunks) = self.load_or_gen_chunk_queue(splits)?; if self.resume {