-
Notifications
You must be signed in to change notification settings - Fork 19
fix: derive timelapse duration from compiled video #192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -246,7 +246,8 @@ export const realizeJobWorker = new Worker<RealizeJobInputs, RealizeJobOutputs>( | |
| ]); | ||
|
|
||
| // Thumbnail generation - we opt for a simple approach where we just get the frame in the middle of the video. | ||
| const thumbnailTimestamp = (await measureVideoDuration(outputPath)) / 2; | ||
| const videoDuration = await measureVideoDuration(outputPath); | ||
| const thumbnailTimestamp = videoDuration / 2; | ||
|
|
||
| // Arguments to generate thumbnails regardless of output format | ||
| let thumbnailContentType = "image/avif"; | ||
|
|
@@ -344,7 +345,8 @@ export const realizeJobWorker = new Worker<RealizeJobInputs, RealizeJobOutputs>( | |
| return { | ||
| timelapseId, | ||
| videoKey, | ||
| thumbnailKey | ||
| thumbnailKey, | ||
| realTimeDuration: videoDuration * TIMELAPSE_FACTOR | ||
| }; | ||
|
Comment on lines
347
to
352
|
||
| } | ||
| finally { | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -242,7 +242,7 @@ export const adminRouterContract = { | |||||
| })), | ||||||
|
|
||||||
| recalculateDurations: contract("POST", "/admin/recalculateDurations") | ||||||
| .route({ description: "Recalculates the duration of every timelapse from its snapshots. Requires administrator permissions and an `elevated` grant." }) | ||||||
| .route({ description: "Recalculates the duration of unrealized timelapses (those still processing, without a compiled video) from their snapshots. Realized timelapses are skipped because their duration is derived from the compiled video. Requires administrator permissions and an `elevated` grant." }) | ||||||
|
||||||
| .route({ description: "Recalculates the duration of unrealized timelapses (those still processing, without a compiled video) from their snapshots. Realized timelapses are skipped because their duration is derived from the compiled video. Requires administrator permissions and an `elevated` grant." }) | |
| .route({ description: "Recalculates the duration of unrealized timelapses (those without a compiled video, where `s3Key` is null) from their snapshots. Realized timelapses are skipped because their duration is derived from the compiled video. Requires administrator permissions and an `elevated` grant." }) |
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -50,7 +50,15 @@ export const RealizeJobOutputsSchema = z.object({ | |||||||||||||
| /** | ||||||||||||||
| * The S3 key for the thumbnail, stored in the public S3 bucket, shared by both the server and the worker. | ||||||||||||||
| */ | ||||||||||||||
| thumbnailKey: z.string() | ||||||||||||||
| thumbnailKey: z.string(), | ||||||||||||||
|
|
||||||||||||||
| /** | ||||||||||||||
| * The real-time duration of the timelapse in seconds (i.e. `videoDuration * TIMELAPSE_FACTOR`), | ||||||||||||||
| * as measured by ffprobe on the compiled output video. This value can be stored directly as the | ||||||||||||||
| * timelapse `duration` without further conversion. | ||||||||||||||
|
||||||||||||||
| * The real-time duration of the timelapse in seconds (i.e. `videoDuration * TIMELAPSE_FACTOR`), | |
| * as measured by ffprobe on the compiled output video. This value can be stored directly as the | |
| * timelapse `duration` without further conversion. | |
| * The real-time duration of the timelapse in seconds, derived as | |
| * `videoDuration * TIMELAPSE_FACTOR` from the compiled output video's duration measured by ffprobe. | |
| * This value can be stored directly as the timelapse `duration` without further conversion. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This endpoint now explicitly skips realized timelapses (
where: { s3Key: null }), but the public admin contract/docs still describe it as “recalculates the duration of every timelapse from its snapshots”. Please update the API contract description (and/or rename/add params) so callers aren’t misled about what will be updated.