From c1ec2adb9f9b93ab4d51b5c11fa62f4f744d87f0 Mon Sep 17 00:00:00 2001 From: Rob Hallam <0504004h@student.gla.ac.uk> Date: Sun, 15 Sep 2024 23:17:46 +0100 Subject: [PATCH] feat: [VP] make compiling clips into a video optional --- pipeline/producers.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/pipeline/producers.py b/pipeline/producers.py index 8575719..5f64901 100644 --- a/pipeline/producers.py +++ b/pipeline/producers.py @@ -28,6 +28,14 @@ class VideoProducer(Producer): class FfmpegVideoProducer(VideoProducer): """Produce videos using ffmpeg""" # TODO: consider output filename options + _CONFIG_COMPILE_CLIPS = True + + def __init__(self, features, compile_clips=_CONFIG_COMPILE_CLIPS) -> None: + if not features: + raise ValueError("No features provided") + # TODO: consider if we want to permit empty features (producing no video) + self.features = features + self._compile_clips = compile_clips def _run_no_output(self, cmd: list, cwd:str=".") -> None: """Run a command and return the output as a string @@ -36,12 +44,6 @@ class FfmpegVideoProducer(VideoProducer): """ subprocess.run(cmd, stdout=None, stderr=None, cwd=cwd) - def __init__(self, features): - if not features: - raise ValueError("No features provided") - # TODO: consider if we want to permit empty features (producing no video) - self.features = features - def _ffmpeg_feature_to_clip(self, feature=None, output_filepath=None): """use ffmpeg to produve a video clip from a feature""" OVERWRITE = True # TODO: consider making this a config option @@ -99,9 +101,10 @@ class FfmpegVideoProducer(VideoProducer): clips.append(output_filepath) # concatenate the clips - output_filepath = f"{OUTPUT_DIR}/highlights.mp4" - self._ffmpeg_concat_clips(clips, output_filepath) - logging.info(f"Produced video: {output_filepath}") + if self._compile_clips: + output_filepath = f"{OUTPUT_DIR}/highlights.mp4" + self._ffmpeg_concat_clips(clips, output_filepath) + logging.info(f"Produced video: {output_filepath}") class VisualisationProducer(Producer): """Visualisation producer -- illustrate the features we have extracted"""