( videoId: string, userId: string, rawFileKey: string, _bucketId: string | null, )
| 222 | } |
| 223 | |
| 224 | async function processVideoOnMediaServer( |
| 225 | videoId: string, |
| 226 | userId: string, |
| 227 | rawFileKey: string, |
| 228 | _bucketId: string | null, |
| 229 | ): Promise<MediaServerProcessResult> { |
| 230 | "use step"; |
| 231 | |
| 232 | const mediaServerUrl = serverEnv().MEDIA_SERVER_URL; |
| 233 | const webhookBaseUrl = |
| 234 | serverEnv().MEDIA_SERVER_WEBHOOK_URL || serverEnv().WEB_URL; |
| 235 | if (!mediaServerUrl) { |
| 236 | throw new FatalError("MEDIA_SERVER_URL is not configured"); |
| 237 | } |
| 238 | |
| 239 | const [video] = await db() |
| 240 | .select() |
| 241 | .from(videos) |
| 242 | .where(eq(videos.id, Video.VideoId.make(videoId))); |
| 243 | |
| 244 | if (!video) { |
| 245 | throw new FatalError("Video does not exist"); |
| 246 | } |
| 247 | |
| 248 | const videoDomain = decodeStorageVideo(video); |
| 249 | |
| 250 | const [bucket] = |
| 251 | await Storage.getAccessForVideo(videoDomain).pipe(runPromise); |
| 252 | |
| 253 | const rawVideoUrl = await bucket |
| 254 | .getInternalSignedObjectUrl(rawFileKey, { |
| 255 | expiresIn: MEDIA_SERVER_PRESIGNED_GET_EXPIRES_SECONDS, |
| 256 | }) |
| 257 | .pipe(runPromise); |
| 258 | |
| 259 | const outputKey = `${userId}/${videoId}/result.mp4`; |
| 260 | const thumbnailKey = `${userId}/${videoId}/screenshot/screen-capture.jpg`; |
| 261 | const previewGifKey = `${userId}/${videoId}/preview/animated-preview.gif`; |
| 262 | |
| 263 | const outputPresignedUrl = await bucket |
| 264 | .getInternalPresignedPutUrl( |
| 265 | outputKey, |
| 266 | { |
| 267 | ContentType: "video/mp4", |
| 268 | }, |
| 269 | { expiresIn: MEDIA_SERVER_PRESIGNED_PUT_EXPIRES_SECONDS }, |
| 270 | ) |
| 271 | .pipe(runPromise); |
| 272 | |
| 273 | const thumbnailPresignedUrl = await bucket |
| 274 | .getInternalPresignedPutUrl( |
| 275 | thumbnailKey, |
| 276 | { |
| 277 | ContentType: "image/jpeg", |
| 278 | }, |
| 279 | { expiresIn: MEDIA_SERVER_PRESIGNED_PUT_EXPIRES_SECONDS }, |
| 280 | ) |
| 281 | .pipe(runPromise); |
no test coverage detected