|
|
@@ -29,6 +29,13 @@ class FfmpegVideoProducer(VideoProducer): |
|
|
|
"""Produce videos using ffmpeg""" |
|
|
|
# TODO: consider output filename options |
|
|
|
|
|
|
|
def _run_no_output(self, cmd: list, cwd:str=".") -> None: |
|
|
|
"""Run a command and return the output as a string |
|
|
|
|
|
|
|
Defined to be mocked out in tests via unittest.mock.patch |
|
|
|
""" |
|
|
|
subprocess.run(cmd, stdout=None, stderr=None, cwd=cwd) |
|
|
|
|
|
|
|
def __init__(self, features): |
|
|
|
if not features: |
|
|
|
raise ValueError("No features provided") |
|
|
@@ -50,9 +57,10 @@ class FfmpegVideoProducer(VideoProducer): |
|
|
|
# TODO: adjustable encoding options |
|
|
|
seek = ["-ss", str(feature.interval.start)] |
|
|
|
duration = ["-t", str(feature.interval.duration)] |
|
|
|
ffmpeg_args = ffmpeg_prefix + seek + ["-i"] + [feature.path] + duration + ffmpeg_suffix + [output_filepath] |
|
|
|
ffmpeg_args = ffmpeg_prefix + seek + ["-i"] + [feature.source.path] +\ |
|
|
|
duration + ffmpeg_suffix + [output_filepath] |
|
|
|
logging.info(f"ffmpeg_args: {ffmpeg_args}") |
|
|
|
subprocess.run(ffmpeg_args, stdout=None, stderr=None) |
|
|
|
self._run_no_output(ffmpeg_args) |
|
|
|
|
|
|
|
def _ffmpeg_concat_clips(self, clips=None, output_filepath=None): |
|
|
|
"""use ffmpeg to concatenate clips into a single video""" |
|
|
@@ -78,7 +86,7 @@ class FfmpegVideoProducer(VideoProducer): |
|
|
|
|
|
|
|
ffmpeg_args = ffmpeg_prefix + [join_file.name] + ["-c", "copy", output_filepath] |
|
|
|
logging.info(f"ffmpeg_args: {ffmpeg_args}") |
|
|
|
subprocess.run(ffmpeg_args, stdout=None, stderr=None) |
|
|
|
self._run_no_output(ffmpeg_args) |
|
|
|
join_file.close() |
|
|
|
|
|
|
|
def produce(self): |
|
|
|