Add automatic aspect matching with explicit ratio overrides.
Keep video output on the still by default, and only force 16:9, 9:16, or 1:1 when a preset is selected.
This commit is contained in:
@@ -1,13 +1,3 @@
|
||||
const ASPECTS: Record<string, { width: number; height: number }> = {
|
||||
'16:9': { width: 1344, height: 768 },
|
||||
'9:16': { width: 768, height: 1344 },
|
||||
'1:1': { width: 1024, height: 1024 }
|
||||
}
|
||||
|
||||
function snap32(value: number) {
|
||||
return Math.max(32, Math.round(value / 32) * 32)
|
||||
}
|
||||
|
||||
function frameLength(seconds: number) {
|
||||
const raw = Math.max(5, Math.round(seconds * 24))
|
||||
return raw + (5 - (raw % 17) + 17) % 17
|
||||
@@ -37,9 +27,7 @@ export default defineEventHandler(async (event) => {
|
||||
throw createError({ statusCode: 400, statusMessage: 'A motion prompt is required' })
|
||||
}
|
||||
|
||||
const aspect = ASPECTS[fields.aspect] || ASPECTS['16:9']
|
||||
const width = snap32(Number(fields.width || aspect.width))
|
||||
const height = snap32(Number(fields.height || aspect.height))
|
||||
const { width, height } = resolveOutputSize(fields.aspect, image.data, Number(fields.width), Number(fields.height))
|
||||
const turbo = fields.turbo !== 'false'
|
||||
const steps = Number(fields.steps || (turbo ? 8 : 20))
|
||||
const seed = fields.seed && fields.seed !== 'random'
|
||||
@@ -64,6 +52,7 @@ export default defineEventHandler(async (event) => {
|
||||
seed,
|
||||
width,
|
||||
height,
|
||||
aspect: fields.aspect || 'auto',
|
||||
steps,
|
||||
turbo
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user