From 5e6034452276197b0a4115ba411614a984b383c0 Mon Sep 17 00:00:00 2001 From: Mike Lang Date: Sun, 31 Oct 2021 13:12:29 +1100 Subject: [PATCH] cutter: Fix errors due to unsupported cut type not being handled correctly Previously, determining the correct cut type and setting up the cut iterator wasn't an operation we expected to be able to fail. It happened outside all error handling blocks. However, due to the multi-range work, this can now fail if we are requesting an unsupported combination of transitions and cut type. In order to correctly handle this like other cut errors, ie. set to UNEDITED and set error column, we move this logic into the upload_wrapper right before we iterate through the resulting cut. --- cutter/cutter/main.py | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/cutter/cutter/main.py b/cutter/cutter/main.py index 5b7f5ed..fb6dd58 100644 --- a/cutter/cutter/main.py +++ b/cutter/cutter/main.py @@ -325,24 +325,6 @@ class Cutter(object): upload_backend = self.upload_locations[job.upload_location] self.logger.info("Cutting and uploading job {} to {}".format(format_job(job), upload_backend)) - if upload_backend.encoding_settings is None: - 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) - else: - self.logger.debug("Using encoding settings for {} cut: {}".format( - "streamable" if upload_backend.encoding_streamable else "non-streamable", - upload_backend.encoding_settings, - )) - if len(job.video_ranges) > 1: - raise ValueError("Full cuts do not support multiple ranges") - range = job.video_ranges[0] - cut = full_cut_segments( - job.segment_ranges[0], range.start, range.end, - upload_backend.encoding_settings, stream=upload_backend.encoding_streamable, - ) - # This flag tracks whether we've told requests to finalize the upload, # and serves to detect whether errors from the request call are recoverable. finalize_begun = False @@ -389,6 +371,24 @@ class Cutter(object): nonlocal finalize_begun try: + if upload_backend.encoding_settings is None: + 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) + else: + self.logger.debug("Using encoding settings for {} cut: {}".format( + "streamable" if upload_backend.encoding_streamable else "non-streamable", + upload_backend.encoding_settings, + )) + if len(job.video_ranges) > 1: + raise ValueError("Full cuts do not support multiple ranges") + range = job.video_ranges[0] + cut = full_cut_segments( + job.segment_ranges[0], range.start, range.end, + upload_backend.encoding_settings, stream=upload_backend.encoding_streamable, + ) + for chunk in cut: yield chunk except Exception as ex: