diff --git a/cutter/cutter/main.py b/cutter/cutter/main.py index 77159aa..9a66c8b 100644 --- a/cutter/cutter/main.py +++ b/cutter/cutter/main.py @@ -17,7 +17,7 @@ from psycopg2 import sql import common from common.database import DBManager, query, get_column_placeholder -from common.segments import get_best_segments, fast_cut_segments, full_cut_segments, extract_frame, ContainsHoles +from common.segments import get_best_segments, fast_cut_segments, full_cut_segments, smart_cut_segments, extract_frame, ContainsHoles from common.images import compose_thumbnail_template from common.stats import timed @@ -396,11 +396,16 @@ class Cutter(object): nonlocal upload_finished try: - if upload_backend.encoding_settings is None: + if upload_backend.encoding_settings in ("fast", "smart"): self.logger.debug("No encoding settings, using fast cut") if any(transition is not None for transition in job.video_transitions): raise ValueError("Fast cuts do not support complex transitions") - cut = fast_cut_segments(job.segment_ranges, job.video_ranges) + + cut_fn = { + "fast": fast_cut_segments, + "smart": smart_cut_segments, + }[upload_backend.encoding_settings] + cut = cut_fn(job.segment_ranges, job.video_ranges) else: self.logger.debug("Using encoding settings for {} cut: {}".format( "streamable" if upload_backend.encoding_streamable else "non-streamable", @@ -934,9 +939,9 @@ def main( else: raise ValueError("Unknown upload backend type: {!r}".format(backend_type)) backend = backend_type(credentials, **backend_config) - if cut_type == 'fast': - # mark for fast cut by clearing encoding settings - backend.encoding_settings = None + if cut_type in ('fast', 'smart'): + # mark for the given cut type by replacing encoding settings + backend.encoding_settings = cut_type elif cut_type != 'full': raise ValueError("Unknown cut type: {!r}".format(cut_type)) upload_locations[location] = backend diff --git a/cutter/cutter/upload_backends.py b/cutter/cutter/upload_backends.py index d5bea32..cb9cdfb 100644 --- a/cutter/cutter/upload_backends.py +++ b/cutter/cutter/upload_backends.py @@ -76,8 +76,10 @@ class UploadBackend(object): The upload backend also determines the encoding settings for the cutting process, this is given as a list of ffmpeg args under the 'encoding_settings' attribute. - If this is None, instead uses the 'fast cut' strategy where nothing + If this is not a list but the string "fast", instead uses the 'fast cut' strategy where nothing is transcoded. + Similarly, the string "smart" uses the 'smart cut' strategy which is a fast cut with an additional + pass to prevent timestamp issues. In addition, if the output format doesn't need a seekable file, you should set encoding_streamable = True so we know we can stream the output directly.