-
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 1 commit
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 |
|---|---|---|
|
|
@@ -516,13 +516,16 @@ export default os.router({ | |
| .use(requiredAuth("ADMIN")) | ||
| .use(requiredScopes("elevated")) | ||
| .handler(async () => { | ||
| // Only recalculate durations for timelapses that haven't been realized yet. | ||
| // Realized timelapses have their duration set from the compiled video, which is the source of truth. | ||
| const PAGE_SIZE = 100; | ||
| let updated = 0; | ||
| let cursor: string | undefined; | ||
|
|
||
| while (true) { | ||
| const batch = await database().timelapse.findMany({ | ||
| select: { id: true, snapshots: true }, | ||
| where: { s3Key: null }, | ||
|
Comment on lines
+519
to
+528
|
||
| take: PAGE_SIZE, | ||
| orderBy: { id: "asc" }, | ||
| ...(cursor ? { skip: 1, cursor: { id: cursor } } : {}) | ||
|
|
@@ -549,7 +552,7 @@ export default os.router({ | |
| } | ||
| } | ||
|
|
||
| logInfo(`Recalculated durations for ${updated} timelapses.`); | ||
| logInfo(`Recalculated durations for ${updated} unrealized timelapses (skipped realized timelapses).`); | ||
|
|
||
| return apiOk({ updated }); | ||
| }), | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -50,7 +50,13 @@ 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 duration of the compiled output video in seconds, as measured by ffprobe. | ||||||
| * Optional for backwards compatibility with in-flight jobs that predate this field. | ||||||
| */ | ||||||
| videoDuration: z.number().nonnegative().optional() | ||||||
|
||||||
| videoDuration: z.number().nonnegative().optional() | |
| videoDuration: z.number().finite().positive().optional() |
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.
Duration is derived using a runtime
TIMELAPSE_FACTORimport. Since the server and worker ship as separate images, a version-skew deploy could result in the worker encoding with one factor while the server multiplies by another, permanently storing the wrongduration. To make this robust, consider having the worker return the factor used (or the already-multiplied real-time duration) and use that value for the DB update.