Преглед на файлове

feat: [VP] make compiling clips into a video optional

main
Rob Hallam преди 1 месец
родител
ревизия
c1ec2adb9f
променени са 1 файла, в които са добавени 12 реда и са изтрити 9 реда
  1. +12
    -9
      pipeline/producers.py

+ 12
- 9
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"""


Зареждане…
Отказ
Запис