jbilcke-hf HF staff commited on
Commit
977a154
·
1 Parent(s): 105d641
Files changed (1) hide show
  1. src/index.mts +17 -0
src/index.mts CHANGED
@@ -3,6 +3,7 @@ import path from "node:path"
3
 
4
  import { validate as uuidValidate } from "uuid"
5
  import express from "express"
 
6
 
7
  import { Video, VideoStatus, VideoAPIRequest } from "./types.mts"
8
  import { parseVideoRequest } from "./utils/parseVideoRequest.mts"
@@ -19,6 +20,8 @@ import { hasValidAuthorization } from "./utils/hasValidAuthorization.mts"
19
  import { getAllVideosForOwner } from "./scheduler/getAllVideosForOwner.mts"
20
  import { initFolders } from "./initFolders.mts"
21
  import { sortVideosByYoungestFirst } from "./utils/sortVideosByYoungestFirst.mts"
 
 
22
 
23
  initFolders()
24
  // to disable all processing (eg. to debug)
@@ -30,6 +33,19 @@ const port = 7860
30
 
31
  app.use(express.json())
32
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  app.post("/:ownerId", async (req, res) => {
34
  const request = req.body as VideoAPIRequest
35
 
@@ -79,6 +95,7 @@ app.post("/:ownerId", async (req, res) => {
79
  }
80
  })
81
 
 
82
  app.get("/:ownerId/:videoId\.mp4", async (req, res) => {
83
 
84
  /*
 
3
 
4
  import { validate as uuidValidate } from "uuid"
5
  import express from "express"
6
+ import querystring from "node:querystring"
7
 
8
  import { Video, VideoStatus, VideoAPIRequest } from "./types.mts"
9
  import { parseVideoRequest } from "./utils/parseVideoRequest.mts"
 
20
  import { getAllVideosForOwner } from "./scheduler/getAllVideosForOwner.mts"
21
  import { initFolders } from "./initFolders.mts"
22
  import { sortVideosByYoungestFirst } from "./utils/sortVideosByYoungestFirst.mts"
23
+ import { generateVideo } from "./production/generateVideo.mts"
24
+ import { generateSeed } from "./utils/generateSeed.mts"
25
 
26
  initFolders()
27
  // to disable all processing (eg. to debug)
 
33
 
34
  app.use(express.json())
35
 
36
+ // a "fast track" pipeline
37
+ app.post("/render", async (req, res) => {
38
+ const url = await generateVideo(req.body as string, {
39
+ seed: generateSeed(),
40
+ nbFrames: 16,
41
+ nbSteps: 10,
42
+ })
43
+
44
+ res.status(200)
45
+ res.write(JSON.stringify({ url }))
46
+ res.end()
47
+ })
48
+
49
  app.post("/:ownerId", async (req, res) => {
50
  const request = req.body as VideoAPIRequest
51
 
 
95
  }
96
  })
97
 
98
+
99
  app.get("/:ownerId/:videoId\.mp4", async (req, res) => {
100
 
101
  /*