From 69bfa79e24a78cad6db6d1a4298fed76607ac295 Mon Sep 17 00:00:00 2001 From: Mike Lang Date: Tue, 20 Aug 2024 14:21:14 +1000 Subject: [PATCH] Make video transition durations floats, not intervals Almost all code was already expecting this. --- DATABASE.md | 2 +- cutter/cutter/main.py | 8 ++++---- postgres/schema.sql | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/DATABASE.md b/DATABASE.md index 938f3d0..9b3b0cd 100644 --- a/DATABASE.md +++ b/DATABASE.md @@ -180,7 +180,7 @@ columns | type | role `upload_location` | `TEXT` | edit input | The upload location to upload the cut video to. This is used by the cutter, and must match one of the cutter's configured upload locations. If it does not, the cutter will not claim the event. `public` | `BOOLEAN NOT NULL DEFAULT TRUE` | edit input | Whether the uploaded video should be public or not, if the upload location supports that distinction. For example, on youtube, non-public videos are "unlisted". It also controls whether the video will be added to playlists, only public videos are added to playlists. `video_ranges` | `{start TIMESTAMP, end TIMESTAMP}[]` | edit input | A non-zero number of start and end times, describing the ranges of video to cut. They will be cut back-to-back in the given order, with the transitions between as per `video_transitions`. If already set, used as the default range settings when editing. -`video_transitions` | `{type TEXT, duration INTERVAL}[]` | edit input | Defines how to transition between each range defined in `video_ranges`, and must be exactly the length of `video_ranges` minus 1. Each index in `video_transitions` defines the transition between the range with the same index in `video_ranges` and the next one. Transitions either specify a transition type as understood by `ffmpeg`'s `xfade` filter and a duration (amount of overlap), or can be NULL to indicate a hard cut. +`video_transitions` | `{type TEXT, duration DOUBLE PRECISION}[]`| edit input | Defines how to transition between each range defined in `video_ranges`, and must be exactly the length of `video_ranges` minus 1. Each index in `video_transitions` defines the transition between the range with the same index in `video_ranges` and the next one. Transitions either specify a transition type as understood by `ffmpeg`'s `xfade` filter and a duration (amount of overlap), or can be NULL to indicate a hard cut. `video_title` | `TEXT` | edit input | The title of the video. If already set, used as the default title when editing instead of `description`. `video_description` | `TEXT` | edit input | The description field of the video. If already set, used as the default description when editing instead of `description`. `video_tags` | `TEXT[]` | edit input | Custom tags to annotate the video with. If already set, used as the default when editing instead of `tags`. diff --git a/cutter/cutter/main.py b/cutter/cutter/main.py index 225edc2..100f5de 100644 --- a/cutter/cutter/main.py +++ b/cutter/cutter/main.py @@ -89,15 +89,15 @@ def get_duration(job): # Each range overlaps the previous by duration, so we add all the ranges # then subtract all the durations. without_transitions = sum([ - range.end - range.start + (range.end - range.start).total_seconds() for range in job.video_ranges - ], datetime.timedelta()) + ]) overlap = sum([ transition.duration for transition in job.video_transitions if transition is not None - ], datetime.timedelta()) - return (without_transitions - overlap).total_seconds() + ]) + return without_transitions - overlap def format_job(job): diff --git a/postgres/schema.sql b/postgres/schema.sql index 35fd18a..e08b113 100644 --- a/postgres/schema.sql +++ b/postgres/schema.sql @@ -16,7 +16,7 @@ CREATE TYPE video_range as ( CREATE TYPE video_transition as ( type TEXT, - duration INTERVAL + duration DOUBLE PRECISON ); CREATE TYPE thumbnail_mode as ENUM (