Skip to content

Commit 980bbed

Browse files
committed
feat(video): video request usecases uses aspect ratio
1 parent 96fc116 commit 980bbed

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/video/application/usecases/ProcessVideo.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ export class ProcessVideo {
2626
const imagineVideoGateway = ImagineVideoGatewayFactory.create(input.gateway)
2727
const output = await imagineVideoGateway.imagine({
2828
...batch,
29-
width: input.dimensions.width,
30-
height: input.dimensions.height,
29+
aspectRatio: input.aspectRatio,
3130
imageUrl: input.imageUrl
3231
})
3332
batch.setTaskId(output?.taskId ?? 'none')
@@ -40,8 +39,9 @@ export class ProcessVideo {
4039
const video = output.videos[0]
4140
const path = await this.videoStorage.uploadVideo(video)
4241
const currentVideo = Video.create({
43-
width: input.dimensions.width,
44-
height: input.dimensions.height,
42+
width: output.width,
43+
height: output.height,
44+
aspectRatio: input.aspectRatio,
4545
batchId: batch.id,
4646
path
4747
})

src/video/application/usecases/RequestVideo.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import { type DomainEvent } from '@api/domain/events/DomainEvent'
77
import { type Queue } from '@api/domain/queue/Queue'
88
import { inject } from '@api/infra/dependency-injection/Registry'
99

10+
// Input should be '1:1', '16:9', '9:16', '4:3', '3:4', '21:9' or '9:21'",
11+
1012
export class RequestVideo {
1113
@inject('batchRepository')
1214
private readonly batchRepository!: BatchRepository
@@ -24,7 +26,7 @@ export class RequestVideo {
2426
if (!image) throw new ImageNotFoundError()
2527
imageUrl = `${process.env.FILES_STORAGE}${image?.path}`
2628
}
27-
const batchConfiguration = Batch.getConfigurations(input.gateway)
29+
const batchConfiguration = Batch.configurationFactory({ gateway: input.gateway, aspectRatio: input.aspectRatio })
2830
const batch = Batch.create({
2931
prompt: input.prompt,
3032
author: input.author,
@@ -35,7 +37,7 @@ export class RequestVideo {
3537
repositoryBatch.register('videoRequested', async (domainEvent: DomainEvent) => {
3638
await this.queue.publish(domainEvent.eventName, domainEvent.data)
3739
})
38-
await repositoryBatch.requestVideo({ gateway: input.gateway, dimensions: { width: input.width, height: input.height }, imageUrl })
40+
await repositoryBatch.requestVideo({ gateway: input.gateway, aspectRatio: input.aspectRatio, imageUrl })
3941
return {
4042
batchId: repositoryBatch.id,
4143
batchStatus: batch.status

0 commit comments

Comments
 (0)