jbilcke-hf HF staff commited on
Commit
fb04e43
1 Parent(s): 634ff01

working on the new version

Browse files
package-lock.json CHANGED
@@ -137,9 +137,9 @@
137
  }
138
  },
139
  "node_modules/@huggingface/inference": {
140
- "version": "2.5.2",
141
- "resolved": "https://registry.npmjs.org/@huggingface/inference/-/inference-2.5.2.tgz",
142
- "integrity": "sha512-v2f4mRgumisTOkelYPCZQRBzh5K0l2vexH8b88CevWv+KgzeC0oPeQhDiSNisCpE6hK+UC6KQ/FxF265kcd6FA==",
143
  "engines": {
144
  "node": ">=18"
145
  }
@@ -184,11 +184,6 @@
184
  "split2": "^4.1.0"
185
  }
186
  },
187
- "node_modules/@kararty/dank-twitch-irc/node_modules/ms": {
188
- "version": "2.1.3",
189
- "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
190
- "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="
191
- },
192
  "node_modules/@puppeteer/browsers": {
193
  "version": "1.4.3",
194
  "resolved": "https://registry.npmjs.org/@puppeteer/browsers/-/browsers-1.4.3.tgz",
@@ -308,9 +303,9 @@
308
  "integrity": "sha512-YATxVxgRqNH6nHEIsvg6k2Boc1JHI9ZbH5iWFFv/MTkchz3b1ieGDa5T0a9RznNdI0KhVbdbWSN+KWWrQZRxTw=="
309
  },
310
  "node_modules/@types/node": {
311
- "version": "20.3.2",
312
- "resolved": "https://registry.npmjs.org/@types/node/-/node-20.3.2.tgz",
313
- "integrity": "sha512-vOBLVQeCQfIcF/2Y7eKFTqrMnizK5lRNQ7ykML/5RuwVXVWxYkgwS7xbt4B6fKCUPgbSL5FSsjHQpaGQP/dQmw=="
314
  },
315
  "node_modules/@types/qs": {
316
  "version": "6.9.7",
@@ -368,9 +363,9 @@
368
  }
369
  },
370
  "node_modules/acorn": {
371
- "version": "8.9.0",
372
- "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.9.0.tgz",
373
- "integrity": "sha512-jaVNAFBHNLXspO543WnNNPZFRtavh3skAkITqD0/2aeMkKZTN+254PyhwxFYrk3vQ1xfY+2wbesJMs/JC8/PwQ==",
374
  "bin": {
375
  "acorn": "bin/acorn"
376
  },
@@ -712,11 +707,11 @@
712
  "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ=="
713
  },
714
  "node_modules/cross-fetch": {
715
- "version": "3.1.6",
716
- "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.6.tgz",
717
- "integrity": "sha512-riRvo06crlE8HiqOwIpQhxwdOk4fOeR7FVM/wXoxchFEqMNUjvbs3bfo4OTgMEMHzppd4DxFBDbyySj8Cv781g==",
718
  "dependencies": {
719
- "node-fetch": "^2.6.11"
720
  }
721
  },
722
  "node_modules/cross-fetch/node_modules/node-fetch": {
@@ -770,6 +765,11 @@
770
  "debug": "^2.1.0"
771
  }
772
  },
 
 
 
 
 
773
  "node_modules/deep-is": {
774
  "version": "0.1.4",
775
  "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz",
@@ -1627,9 +1627,9 @@
1627
  "integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A=="
1628
  },
1629
  "node_modules/ms": {
1630
- "version": "2.0.0",
1631
- "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
1632
- "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A=="
1633
  },
1634
  "node_modules/negotiator": {
1635
  "version": "0.6.3",
@@ -1943,27 +1943,27 @@
1943
  }
1944
  },
1945
  "node_modules/puppeteer": {
1946
- "version": "20.7.4",
1947
- "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-20.7.4.tgz",
1948
- "integrity": "sha512-4JLZeRLXQAjQwWa6yv8cpjEgVapgrvDjBBcI/UCJ+EM6na6aR7hQFnQV4ffjFlUKPpvB2Y1vztVqOEhjfC+yUQ==",
1949
  "hasInstallScript": true,
1950
  "dependencies": {
1951
  "@puppeteer/browsers": "1.4.3",
1952
  "cosmiconfig": "8.2.0",
1953
- "puppeteer-core": "20.7.4"
1954
  },
1955
  "engines": {
1956
  "node": ">=16.3.0"
1957
  }
1958
  },
1959
  "node_modules/puppeteer-core": {
1960
- "version": "20.7.4",
1961
- "resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-20.7.4.tgz",
1962
- "integrity": "sha512-7YZ1LmTo+5yM9uBNFTMJpE+lJjcIoNjKVarsYIk7o5WhgQNI9o5XgiQK5f71y1vWwr7sT/eGG75HXAehjnTBTg==",
1963
  "dependencies": {
1964
  "@puppeteer/browsers": "1.4.3",
1965
  "chromium-bidi": "0.4.16",
1966
- "cross-fetch": "3.1.6",
1967
  "debug": "4.3.4",
1968
  "devtools-protocol": "0.0.1135028",
1969
  "ws": "8.13.0"
@@ -2161,11 +2161,6 @@
2161
  "node": ">= 0.8.0"
2162
  }
2163
  },
2164
- "node_modules/send/node_modules/ms": {
2165
- "version": "2.1.3",
2166
- "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
2167
- "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="
2168
- },
2169
  "node_modules/serve-static": {
2170
  "version": "1.15.0",
2171
  "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.15.0.tgz",
@@ -2419,9 +2414,9 @@
2419
  }
2420
  },
2421
  "node_modules/tar-stream": {
2422
- "version": "3.1.5",
2423
- "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-3.1.5.tgz",
2424
- "integrity": "sha512-i+IP13ZyzEOOEkuPrvYokgzW3zcL3rdjmIk0O4veDoegHzySYG4xa2NzKb5pYc/8a8K49iBVMyavS6HT72VMSQ==",
2425
  "dependencies": {
2426
  "b4a": "^1.6.4",
2427
  "fast-fifo": "^1.2.0",
 
137
  }
138
  },
139
  "node_modules/@huggingface/inference": {
140
+ "version": "2.6.1",
141
+ "resolved": "https://registry.npmjs.org/@huggingface/inference/-/inference-2.6.1.tgz",
142
+ "integrity": "sha512-qFYchgOCPeEkZJKiSr7Kz62QwukJtgkeQCT7Q0SSKUcvHpTQVNJp6i/JrJMR4dBdzQysJ1SZDC0pLBBnnskTag==",
143
  "engines": {
144
  "node": ">=18"
145
  }
 
184
  "split2": "^4.1.0"
185
  }
186
  },
 
 
 
 
 
187
  "node_modules/@puppeteer/browsers": {
188
  "version": "1.4.3",
189
  "resolved": "https://registry.npmjs.org/@puppeteer/browsers/-/browsers-1.4.3.tgz",
 
303
  "integrity": "sha512-YATxVxgRqNH6nHEIsvg6k2Boc1JHI9ZbH5iWFFv/MTkchz3b1ieGDa5T0a9RznNdI0KhVbdbWSN+KWWrQZRxTw=="
304
  },
305
  "node_modules/@types/node": {
306
+ "version": "20.4.1",
307
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-20.4.1.tgz",
308
+ "integrity": "sha512-JIzsAvJeA/5iY6Y/OxZbv1lUcc8dNSE77lb2gnBH+/PJ3lFR1Ccvgwl5JWnHAkNHcRsT0TbpVOsiMKZ1F/yyJg=="
309
  },
310
  "node_modules/@types/qs": {
311
  "version": "6.9.7",
 
363
  }
364
  },
365
  "node_modules/acorn": {
366
+ "version": "8.10.0",
367
+ "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.10.0.tgz",
368
+ "integrity": "sha512-F0SAmZ8iUtS//m8DmCTA0jlh6TDKkHQyK6xc6V4KDTyZKA9dnvX9/3sRTVQrWm79glUAZbnmmNcdYwUIHWVybw==",
369
  "bin": {
370
  "acorn": "bin/acorn"
371
  },
 
707
  "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ=="
708
  },
709
  "node_modules/cross-fetch": {
710
+ "version": "4.0.0",
711
+ "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-4.0.0.tgz",
712
+ "integrity": "sha512-e4a5N8lVvuLgAWgnCrLr2PP0YyDOTHa9H/Rj54dirp61qXnNq46m82bRhNqIA5VccJtWBvPTFRV3TtvHUKPB1g==",
713
  "dependencies": {
714
+ "node-fetch": "^2.6.12"
715
  }
716
  },
717
  "node_modules/cross-fetch/node_modules/node-fetch": {
 
765
  "debug": "^2.1.0"
766
  }
767
  },
768
+ "node_modules/debug/node_modules/ms": {
769
+ "version": "2.0.0",
770
+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
771
+ "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A=="
772
+ },
773
  "node_modules/deep-is": {
774
  "version": "0.1.4",
775
  "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz",
 
1627
  "integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A=="
1628
  },
1629
  "node_modules/ms": {
1630
+ "version": "2.1.3",
1631
+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
1632
+ "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="
1633
  },
1634
  "node_modules/negotiator": {
1635
  "version": "0.6.3",
 
1943
  }
1944
  },
1945
  "node_modules/puppeteer": {
1946
+ "version": "20.8.0",
1947
+ "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-20.8.0.tgz",
1948
+ "integrity": "sha512-DnTwtQMUzWGkJYN3rvUW8y2LciFMnM0YR9cgwWmYmMLhUnYQw1XX+Q+5cAO8+AADglVuJCz0kaopd0lMI5j04g==",
1949
  "hasInstallScript": true,
1950
  "dependencies": {
1951
  "@puppeteer/browsers": "1.4.3",
1952
  "cosmiconfig": "8.2.0",
1953
+ "puppeteer-core": "20.8.0"
1954
  },
1955
  "engines": {
1956
  "node": ">=16.3.0"
1957
  }
1958
  },
1959
  "node_modules/puppeteer-core": {
1960
+ "version": "20.8.0",
1961
+ "resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-20.8.0.tgz",
1962
+ "integrity": "sha512-sQcuH6nv9jnFiaaePk53+C0O9BaJP6OaPmYKqJ3sWhziThv6uaaosK49Kg3g1HUUEP9KYhbOhedPIUCXJSQUxw==",
1963
  "dependencies": {
1964
  "@puppeteer/browsers": "1.4.3",
1965
  "chromium-bidi": "0.4.16",
1966
+ "cross-fetch": "4.0.0",
1967
  "debug": "4.3.4",
1968
  "devtools-protocol": "0.0.1135028",
1969
  "ws": "8.13.0"
 
2161
  "node": ">= 0.8.0"
2162
  }
2163
  },
 
 
 
 
 
2164
  "node_modules/serve-static": {
2165
  "version": "1.15.0",
2166
  "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.15.0.tgz",
 
2414
  }
2415
  },
2416
  "node_modules/tar-stream": {
2417
+ "version": "3.1.6",
2418
+ "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-3.1.6.tgz",
2419
+ "integrity": "sha512-B/UyjYwPpMBv+PaFSWAmtYjwdrlEaZQEhMIBFNC5oEG8lpiW8XjcSdmEaClj28ArfKScKHs2nshz3k2le6crsg==",
2420
  "dependencies": {
2421
  "b4a": "^1.6.4",
2422
  "fast-fifo": "^1.2.0",
scripts/censorship.sh CHANGED
@@ -7,4 +7,4 @@ echo "removing inappropriate videos.."
7
  rm -f $WEBTV_VIDEO_STORAGE_PATH_CHANNEL_2*2f6806a9-5cee-4892-adba-83548122309f*
8
  rm -f $WEBTV_VIDEO_STORAGE_PATH_CHANNEL_2*6741315d-9b5e-43ef-ab6d-e14e6f93897a*
9
  rm -f $WEBTV_VIDEO_STORAGE_PATH_CHANNEL_2*e756d6ea-c424-4a05-b553-4be80ec68513*
10
- rm -f $WEBTV_VIDEO_STORAGE_PATH_CHANNEL_2*d6bb4dcf-65ce-4e73-b39d-e5f6d58001fc*
 
7
  rm -f $WEBTV_VIDEO_STORAGE_PATH_CHANNEL_2*2f6806a9-5cee-4892-adba-83548122309f*
8
  rm -f $WEBTV_VIDEO_STORAGE_PATH_CHANNEL_2*6741315d-9b5e-43ef-ab6d-e14e6f93897a*
9
  rm -f $WEBTV_VIDEO_STORAGE_PATH_CHANNEL_2*e756d6ea-c424-4a05-b553-4be80ec68513*
10
+ rm -f $WEBTV_VIDEO_STORAGE_PATH_CHANNEL_2*d6bb4dcf-65ce-4e73-b39d-e5f6d58001fc*
scripts/channel_sorter.sh ADDED
File without changes
scripts/{archive_old_videos.sh → decimate_content.sh} RENAMED
@@ -1,15 +1,11 @@
1
  #!/bin/bash
2
 
3
- # Directory containing .mp4 files
4
- VIDEO_DIR=$WEBTV_VIDEO_STORAGE_PATH_CHANNEL_2
5
-
6
- # Target directory for old files
7
- ARCHIVE_DIR=$WEBTV_VIDEO_ARCHIVE_PATH_CHANNEL_2
8
 
9
  # Calculate the number of .mp4 files
10
- TOTAL_VIDEO_COUNT=$(ls -l ${VIDEO_DIR}*.mp4 | wc -l)
11
 
12
- # Calculate the number of files to move (10%)
13
  VIDEO_COUNT_TO_MOVE=$((TOTAL_VIDEO_COUNT / 10))
14
 
15
  # If there are no videos to move then exit the script
@@ -19,10 +15,20 @@ if [ "$VIDEO_COUNT_TO_MOVE" -le 0 ]; then
19
  fi
20
 
21
  # List all .mp4 files in the directory, sorted by modification date, take the oldest 10%
22
- FILES_TO_MOVE=$(ls -ltr ${VIDEO_DIR}*.mp4 | head -n ${VIDEO_COUNT_TO_MOVE})
23
 
24
  # Move the old files to the archive directory
25
  for file in $FILES_TO_MOVE
26
  do
27
- mv "${file}" "${ARCHIVE_DIR}"
 
 
 
 
 
 
 
 
 
 
28
  done
 
1
  #!/bin/bash
2
 
3
+ # this script will destroy (well, move to the archives) 15% of the videos
 
 
 
 
4
 
5
  # Calculate the number of .mp4 files
6
+ TOTAL_VIDEO_COUNT=$(ls -l "${VIDEO_DIR}"*.mp4 | wc -l)
7
 
8
+ # Calculate the number of files to move (15%)
9
  VIDEO_COUNT_TO_MOVE=$((TOTAL_VIDEO_COUNT / 10))
10
 
11
  # If there are no videos to move then exit the script
 
15
  fi
16
 
17
  # List all .mp4 files in the directory, sorted by modification date, take the oldest 10%
18
+ FILES_TO_MOVE=$(ls -ltr "${WEBTV_VIDEO_STORAGE_PATH_CHANNEL_2}*.mp4" | head -n ${VIDEO_COUNT_TO_MOVE})
19
 
20
  # Move the old files to the archive directory
21
  for file in $FILES_TO_MOVE
22
  do
23
+ mv "${file}" "${WEBTV_VIDEO_ARCHIVE_PATH_CHANNEL_2}"
24
+
25
+ OPTIONAL: remove from channel 3 as well
26
+
27
+ # Extract the base filename
28
+ BASENAME=$(basename ${file})
29
+
30
+ # Check whether file of the same name is in CHANNEL_3 and move if it is
31
+ if [[ -f "${WEBTV_VIDEO_STORAGE_PATH_CHANNEL_3}/${BASENAME}" ]]; then
32
+ mv "${WEBTV_VIDEO_STORAGE_PATH_CHANNEL_3}/${BASENAME}" "${WEBTV_VIDEO_ARCHIVE_PATH_CHANNEL_3}"
33
+ fi
34
  done
scripts/init.sh CHANGED
@@ -27,6 +27,8 @@ echo "creating the storage folders for channel 3.."
27
  mkdir -p $WEBTV_VIDEO_STORAGE_PATH_CHANNEL_3
28
  mkdir -p $WEBTV_AUDIO_STORAGE_PATH_CHANNEL_3
29
 
 
 
30
  echo "creating the playlists for channel 3.."
31
  echo "ffconcat version 1.0" > channel_3_video.txt
32
  echo "ffconcat version 1.0" > channel_3_video.txt
@@ -37,6 +39,8 @@ echo "creating the storage folders for channel 4.."
37
  mkdir -p $WEBTV_VIDEO_STORAGE_PATH_CHANNEL_4
38
  mkdir -p $WEBTV_AUDIO_STORAGE_PATH_CHANNEL_4
39
 
 
 
40
  echo "creating the playlists for channel 4.."
41
  echo "ffconcat version 1.0" > channel_4_video.txt
42
  echo "ffconcat version 1.0" > channel_4_video.txt
 
27
  mkdir -p $WEBTV_VIDEO_STORAGE_PATH_CHANNEL_3
28
  mkdir -p $WEBTV_AUDIO_STORAGE_PATH_CHANNEL_3
29
 
30
+ mkdir -p $WEBTV_VIDEO_ARCHIVE_PATH_CHANNEL_3
31
+
32
  echo "creating the playlists for channel 3.."
33
  echo "ffconcat version 1.0" > channel_3_video.txt
34
  echo "ffconcat version 1.0" > channel_3_video.txt
 
39
  mkdir -p $WEBTV_VIDEO_STORAGE_PATH_CHANNEL_4
40
  mkdir -p $WEBTV_AUDIO_STORAGE_PATH_CHANNEL_4
41
 
42
+ mkdir -p $WEBTV_VIDEO_ARCHIVE_PATH_CHANNEL_4
43
+
44
  echo "creating the playlists for channel 4.."
45
  echo "ffconcat version 1.0" > channel_4_video.txt
46
  echo "ffconcat version 1.0" > channel_4_video.txt
scripts/video2.sh CHANGED
@@ -10,7 +10,7 @@ while true; do
10
  if [ $new_count -ne $current_count ]; then
11
  echo "there are $new_count videos files for channel 2"
12
 
13
- echo "Updating playliss for channel 2.."
14
  current_count=$new_count
15
  files=($WEBTV_VIDEO_STORAGE_PATH_CHANNEL_2*.mp4)
16
 
 
10
  if [ $new_count -ne $current_count ]; then
11
  echo "there are $new_count videos files for channel 2"
12
 
13
+ echo "Updating playlist for channel 2.."
14
  current_count=$new_count
15
  files=($WEBTV_VIDEO_STORAGE_PATH_CHANNEL_2*.mp4)
16
 
scripts/video3.sh CHANGED
@@ -10,7 +10,7 @@ while true; do
10
  if [ $new_count -ne $current_count ]; then
11
  echo "there are $new_count videos files for channel 3"
12
 
13
- echo "Updating playliss for channel 3.."
14
  current_count=$new_count
15
  files=($WEBTV_VIDEO_STORAGE_PATH_CHANNEL_3*.mp4)
16
 
 
10
  if [ $new_count -ne $current_count ]; then
11
  echo "there are $new_count videos files for channel 3"
12
 
13
+ echo "Updating playlist for channel 3.."
14
  current_count=$new_count
15
  files=($WEBTV_VIDEO_STORAGE_PATH_CHANNEL_3*.mp4)
16
 
scripts/video4.sh CHANGED
@@ -10,7 +10,7 @@ while true; do
10
  if [ $new_count -ne $current_count ]; then
11
  echo "there are $new_count videos files for channel 4"
12
 
13
- echo "Updating playliss for channel 4.."
14
  current_count=$new_count
15
  files=($WEBTV_VIDEO_STORAGE_PATH_CHANNEL_4*.mp4)
16
 
 
10
  if [ $new_count -ne $current_count ]; then
11
  echo "there are $new_count videos files for channel 4"
12
 
13
+ echo "Updating playlist for channel 4.."
14
  current_count=$new_count
15
  files=($WEBTV_VIDEO_STORAGE_PATH_CHANNEL_4*.mp4)
16
 
src/downloadVideo.mts CHANGED
@@ -9,6 +9,7 @@ export const downloadVideo = async (remoteUrl: string, fileName: string): Promis
9
 
10
  // download the video
11
  const response = await fetch(remoteUrl)
 
12
 
13
  // write it to the disk
14
  const arrayBuffer = await response.arrayBuffer()
 
9
 
10
  // download the video
11
  const response = await fetch(remoteUrl)
12
+ console.log(`downloading file from ${remoteUrl}`)
13
 
14
  // write it to the disk
15
  const arrayBuffer = await response.arrayBuffer()
src/interpolate/TODO_USE_ME.mts DELETED
@@ -1,27 +0,0 @@
1
- import { promises as fs } from "node:fs"
2
- import path from "node:path"
3
-
4
- import { client } from "@gradio/client"
5
- import tmpDir from "temp-dir"
6
-
7
- const spaceUrl = "https://jbilcke-hf-video-frame-interpolation.hf.space"
8
-
9
- export const interpolateVideo = (fileName: string) {
10
-
11
- const filePath = path.join(tmpDir, fileName)
12
-
13
- const app = await client(spaceUrl)
14
-
15
- const video = await fs.readFile(filePath)
16
-
17
- const result = await app.predict(1, [
18
- video.toString('base64'), // blob in 'parameter_5' Video component
19
- 1, // number (numeric value between 1 and 4) in 'Interpolation Steps' Slider component
20
- "24", // string in 'FPS output' Radio component
21
- ])
22
-
23
- const data = (result as any).data
24
-
25
- console.log(data)
26
-
27
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
src/interpolateVideo.mts CHANGED
@@ -1,65 +1,41 @@
1
- import path from 'node:path'
2
- import fs from 'node:fs'
 
 
3
 
4
- import tmpDir from 'temp-dir'
5
- import puppeteer from 'puppeteer'
6
- import { downloadVideo } from './downloadVideo.mts'
7
-
8
- // TODO we should use an inference endpoint instead
9
- export async function interpolateVideo(fileName: string) {
10
-
11
- const browser = await puppeteer.launch({
12
- // headless: true,
13
- protocolTimeout: 300000,
14
- })
15
 
16
- const spaceUrl = process.env.WEBTV_INTERPOLATION_SPACE_URL
17
 
18
- const page = await browser.newPage()
 
 
19
 
20
- await page.goto(spaceUrl, {
21
- waitUntil: 'networkidle2',
22
- })
23
 
24
  const inputFilePath = path.join(tmpDir, fileName)
25
- // console.log(`local file to upscale: ${inputFilePath}`)
26
-
27
- await new Promise(r => setTimeout(r, 3000))
28
-
29
- const fileField = await page.$('input[type=file]')
30
-
31
- // console.log(`uploading file..`)
32
- await fileField.uploadFile(inputFilePath)
33
 
34
- // console.log('looking for the button to submit')
35
- const submitButton = await page.$('button.lg')
36
 
37
- // console.log('clicking on the button')
38
- await submitButton.click()
39
 
 
40
 
41
- await page.waitForSelector('a[download="interpolated_result.mp4"]', {
42
- timeout: 300000, // need to be large enough in case someone else attemps to use our space
43
- })
 
 
 
 
44
 
45
- const interpolatedFileUrl = await page.$$eval('a[download="interpolated_result.mp4"]', el => el.map(x => x.getAttribute("href"))[0])
46
-
47
- const tmpFileName = `${fileName}_xl`
48
-
49
- // console.log('downloading file from space..')
50
- console.log(`- downloading ${fileName} from ${interpolatedFileUrl}`)
51
-
52
- await downloadVideo(interpolatedFileUrl, tmpFileName)
53
-
54
- const tmpFilePath = path.join(tmpDir, tmpFileName)
55
- const filePath = path.join(tmpDir, fileName)
56
-
57
- await fs.promises.copyFile(tmpFilePath, filePath)
58
- try {
59
- await fs.promises.unlink(tmpFilePath)
60
- } catch (err) {
61
- console.log('failed to cleanup (no big deal..)')
62
- }
63
-
64
- return fileName
65
- }
 
1
+ import { promises as fs } from "node:fs"
2
+ import path from "node:path"
3
+ import { Blob } from "buffer"
4
+ // import { blobFrom } from "fetch-blob"
5
 
6
+ import { client } from "@gradio/client"
7
+ import tmpDir from "temp-dir"
 
 
 
 
 
 
 
 
 
8
 
9
+ import { downloadVideo } from './downloadVideo.mts'
10
 
11
+ const instances: string[] = [
12
+ process.env.WEBTV_INTERPOLATION_SPACE_URL
13
+ ]
14
 
15
+ export const interpolateVideo = async (fileName: string) => {
 
 
16
 
17
  const inputFilePath = path.join(tmpDir, fileName)
 
 
 
 
 
 
 
 
18
 
19
+ const instance = instances.shift()
20
+ instances.push(instance)
21
 
22
+ const app = await client(instance)
 
23
 
24
+ const video = await fs.readFile(inputFilePath)
25
 
26
+ const blob = new Blob([video], { type: 'video/mp4' })
27
+ // const blob = blobFrom(filePath)
28
+ const result = await app.predict(1, [
29
+ blob, // blob in 'parameter_5' Video component
30
+ 1, // number (numeric value between 1 and 4) in 'Interpolation Steps' Slider component
31
+ 24, // string in 'FPS output' Radio component
32
+ ])
33
 
34
+ const data = (result as any).data[0]
35
+ // console.log('raw data:', data)
36
+ const { orig_name, data: remoteFilePath } = data
37
+ const remoteUrl = `${instance}/file=${remoteFilePath}`
38
+ // console.log("remoteUrl:", remoteUrl)
39
+
40
+ await downloadVideo(remoteUrl, fileName)
41
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
src/postprod/interpolate.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { interpolateVideo } from "./interpolateVideoForScript.mts"
2
 
3
  // to test this file:
4
  // npm run postprod:interpolate sandbox/video/1688471841394.mp4 sandbox/video/output.mp4
 
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
src/postprod/interpolateVideoCLI.mts ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { promises as fs } from "node:fs"
2
+ // import path from "node:path"
3
+ import { Blob } from "buffer"
4
+
5
+ import { client } from "@gradio/client"
6
+ // import tmpDir from "temp-dir"
7
+
8
+ const instances: string[] = [
9
+ process.env.WEBTV_INTERPOLATION_SPACE_URL
10
+ ]
11
+
12
+ export const interpolateVideo = async (filePath: string, outputFilePath: string) => {
13
+ const instance = instances.shift()
14
+ instances.push(instance)
15
+
16
+ // const filePath = path.join(tmpDir, fileName)
17
+ console.log('filePath: ', filePath)
18
+ const app = await client(instance)
19
+ console.log('app ready')
20
+ const video = await fs.readFile(filePath)
21
+ console.log('calling app.predict')
22
+
23
+ const blob = new Blob([video], { type: 'video/mp4' })
24
+
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
+
32
+ const data = (result as any).data[0]
33
+ console.log('raw data:', data)
34
+ const { orig_name, data: remoteFilePath } = data
35
+
36
+ const remoteUrl = `${instance}/file=${remoteFilePath}`
37
+
38
+ // download the video
39
+ const response = await fetch(remoteUrl)
40
+
41
+ // write it to the disk
42
+ const arrayBuffer = await response.arrayBuffer()
43
+
44
+ await fs.writeFile(
45
+ outputFilePath,
46
+ Buffer.from(arrayBuffer)
47
+ )
48
+ }
src/postprod/interpolateVideoForScript.mts DELETED
@@ -1,53 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
start.sh CHANGED
@@ -5,13 +5,13 @@ bash ./scripts/init.sh
5
 
6
  # ------------ UPDATE MUSIC ------------
7
  # echo "skipping new music download"
8
- bash scripts/download_fresh_music.sh
9
 
10
  # ---------- CONTENT ALIGNMENT ---------
11
  bash scripts/censorship.sh
12
 
13
- # ----------- ARCHIVE OLD, UNINTERESITNG VIDEOS -------
14
- # bash scripts/archive_old_videos.sh
15
 
16
  # ------ background processes ---------
17
 
@@ -24,18 +24,18 @@ sleep 1
24
 
25
  # background process that creates an audio stream from audio files
26
  bash scripts/audio1.sh &
27
- bash scripts/audio2.sh &
28
 
29
  # background process that creates a video stream from video files
30
  # bash scripts/video1.sh &
31
- bash scripts/video2.sh &
32
  bash scripts/video3.sh &
33
 
34
  sleep 1
35
 
36
  # background process that sends data to the media server
37
  # bash scripts/stream1.sh &
38
- bash scripts/stream2.sh &
39
  bash scripts/stream3.sh &
40
  bash scripts/stream3_twitch.sh &
41
 
 
5
 
6
  # ------------ UPDATE MUSIC ------------
7
  # echo "skipping new music download"
8
+ # bash scripts/download_fresh_music.sh
9
 
10
  # ---------- CONTENT ALIGNMENT ---------
11
  bash scripts/censorship.sh
12
 
13
+ # ----------- ARCHIVE OLD, UNINTERESTING VIDEOS -------
14
+ bash scripts/decimate_content.sh
15
 
16
  # ------ background processes ---------
17
 
 
24
 
25
  # background process that creates an audio stream from audio files
26
  bash scripts/audio1.sh &
27
+ # bash scripts/audio2.sh &
28
 
29
  # background process that creates a video stream from video files
30
  # bash scripts/video1.sh &
31
+ # bash scripts/video2.sh &
32
  bash scripts/video3.sh &
33
 
34
  sleep 1
35
 
36
  # background process that sends data to the media server
37
  # bash scripts/stream1.sh &
38
+ # bash scripts/stream2.sh &
39
  bash scripts/stream3.sh &
40
  bash scripts/stream3_twitch.sh &
41