jbilcke-hf HF staff commited on
Commit
95024b3
·
1 Parent(s): b228486

emergency fix

Browse files
package.json CHANGED
@@ -7,6 +7,7 @@
7
  "start": "node --loader ts-node/esm src/index.mts",
8
  "test": "node --loader ts-node/esm src/test.mts",
9
  "postprod:interpolate": "node --loader ts-node/esm src/postprod/interpolate.mts",
 
10
  "docker": "npm run docker:build && npm run docker:run",
11
  "docker:build": "docker build -t media-server .",
12
  "docker:run": "docker run -it -p 7860:7860 media-server"
 
7
  "start": "node --loader ts-node/esm src/index.mts",
8
  "test": "node --loader ts-node/esm src/test.mts",
9
  "postprod:interpolate": "node --loader ts-node/esm src/postprod/interpolate.mts",
10
+ "postprod:interpolate_legacy": "node --loader ts-node/esm src/postprod/interpolate_legacy.mts",
11
  "docker": "npm run docker:build && npm run docker:run",
12
  "docker:build": "docker build -t media-server .",
13
  "docker:run": "docker run -it -p 7860:7860 media-server"
scripts/interpolate.sh CHANGED
@@ -23,7 +23,7 @@ for FILE_PATH in $INPUT_DIR*.mp4; do
23
  # The first attempt has failed, retrying
24
  echo "Attempt 1 failed for $FILE_NAME, retrying..."
25
 
26
- if ! npm run postprod:interpolate "$FILE_PATH" "$TEMP_FILE_PATH"
27
  then
28
  # Both attempts have failed, skipping the file
29
  echo "Both attempts failed for $FILE_NAME, skipping the file..."
 
23
  # The first attempt has failed, retrying
24
  echo "Attempt 1 failed for $FILE_NAME, retrying..."
25
 
26
+ if ! npm run postprod:interpolate_legacy "$FILE_PATH" "$TEMP_FILE_PATH"
27
  then
28
  # Both attempts have failed, skipping the file
29
  echo "Both attempts failed for $FILE_NAME, skipping the file..."
src/postprod/InterpolateVideoCLI_legacy.mts ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import fs from 'node:fs'
2
+
3
+ import puppeteer from 'puppeteer'
4
+
5
+ // TODO we should use an inference endpoint instead
6
+ export async function interpolateVideo(inputFilePath: string, outputFilePath: string) {
7
+
8
+ const browser = await puppeteer.launch({
9
+ headless: true,
10
+ protocolTimeout: 400000,
11
+ })
12
+
13
+ const spaceUrl = process.env.WEBTV_INTERPOLATION_SPACE_URL
14
+
15
+ const page = await browser.newPage()
16
+ await page.goto(spaceUrl, { waitUntil: 'networkidle2' })
17
+
18
+ await new Promise(r => setTimeout(r, 3000))
19
+
20
+ const fileField = await page.$('input[type=file]')
21
+
22
+ // console.log(`uploading file..`)
23
+ await fileField.uploadFile(inputFilePath)
24
+
25
+ // console.log('looking for the button to submit')
26
+ const submitButton = await page.$('button.lg')
27
+
28
+ // console.log('clicking on the button')
29
+ await submitButton.click()
30
+
31
+ await page.waitForSelector('a[download="interpolated_result.mp4"]', {
32
+ timeout: 400000, // need to be large enough in case someone else attemps to use our space
33
+ })
34
+
35
+ const interpolatedFileUrl = await page.$$eval('a[download="interpolated_result.mp4"]', el => el.map(x => x.getAttribute("href"))[0])
36
+
37
+ // console.log('downloading file from space..')
38
+ console.log(`- downloading from ${interpolatedFileUrl}`)
39
+
40
+
41
+ // download the video
42
+ const response = await fetch(interpolatedFileUrl)
43
+ // write it to the disk
44
+ const arrayBuffer = await response.arrayBuffer()
45
+
46
+ await fs.promises.writeFile(
47
+ outputFilePath,
48
+ Buffer.from(arrayBuffer)
49
+ )
50
+ console.log('success! wrote to:', outputFilePath)
51
+
52
+ process.exit()
53
+ }
src/postprod/interpolate.mts CHANGED
@@ -1,7 +1,7 @@
1
  import { interpolateVideo } from "./interpolateVideoCLI.mts"
2
 
3
  // to test this file:
4
- // npm run postprod:interpolate sandbox/video/1688471841394.mp4 sandbox/video/output.mp4
5
 
6
  const inputFilePath = process.argv[2]
7
  const outputFilePath = process.argv[3]
 
1
  import { interpolateVideo } from "./interpolateVideoCLI.mts"
2
 
3
  // to test this file:
4
+ // npm run postprod:interpolate sandbox/video/raccoon.mp4 sandbox/video/output.mp4
5
 
6
  const inputFilePath = process.argv[2]
7
  const outputFilePath = process.argv[3]
src/postprod/interpolateVideoCLI.mts CHANGED
@@ -25,7 +25,7 @@ export const interpolateVideo = async (filePath: string, outputFilePath: string)
25
  const result = await app.predict(1, [
26
  blob, // blob in 'parameter_5' Video component
27
  1, // number (numeric value between 1 and 4) in 'Interpolation Steps' Slider component
28
- 8, // string in 'FPS output' Radio component
29
  ])
30
 
31
 
 
25
  const result = await app.predict(1, [
26
  blob, // blob in 'parameter_5' Video component
27
  1, // number (numeric value between 1 and 4) in 'Interpolation Steps' Slider component
28
+ 24, // string in 'FPS output' Radio component
29
  ])
30
 
31
 
src/postprod/interpolate_legacy.mts ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { interpolateVideo } from "./InterpolateVideoCLI_legacy.mts"
2
+
3
+ // to test this file:
4
+ // npm run postprod:interpolate sandbox/video/1688471841394.mp4 sandbox/video/output.mp4
5
+
6
+ const inputFilePath = process.argv[2]
7
+ const outputFilePath = process.argv[3]
8
+
9
+ console.log('input file path:', inputFilePath)
10
+ console.log('output file path:', outputFilePath)
11
+
12
+ await interpolateVideo(inputFilePath, outputFilePath)