Spaces:
Build error
Build error
Commit
·
6156cfb
1
Parent(s):
624938d
working on new structure
Browse files- database.json +1 -1
- package.json +3 -3
- scripts/channel_comedy.sh +13 -0
- scripts/channel_community.sh +13 -0
- scripts/channel_random.sh +13 -0
- scripts/channel_random_twitch.sh +15 -0
- scripts/channel_sorter.sh +0 -0
- scripts/init.sh +0 -43
- scripts/stream1.sh +0 -8
- scripts/stream2.sh +0 -9
- scripts/stream3.sh +0 -10
- scripts/stream3_twitch.sh +0 -10
- scripts/stream4.sh +0 -9
- scripts/video1.sh +0 -27
- scripts/video2.sh +0 -28
- scripts/video3.sh +0 -28
- scripts/video4.sh +0 -27
- src/{postprod → batch}/README.md +0 -0
- src/{postprod → batch}/interpolate.txt +0 -0
- src/{postprod → batch}/interpolateVideoCLI.txt +0 -0
- src/{postprod → batch}/interpolateVideoCLILegacy.mts +0 -0
- src/{postprod → batch}/interpolate_legacy.mts +0 -0
- src/{postprod → batch}/sharpen.sh +0 -0
- src/batch/updatePlaylists.mts +95 -0
- src/index.mts +5 -3
- start.sh +4 -2
database.json
CHANGED
@@ -158,7 +158,7 @@
|
|
158 |
},
|
159 |
{
|
160 |
"sequenceId": "46e94a7b-dc27-4949-819e-bb9bce60c460",
|
161 |
-
"skip":
|
162 |
"lastGenerationAt": "",
|
163 |
"videoPrompt": "a photorealistic compilation of various computer renderings and simulation featuring classical 3D animation of torus, cube, phong, shading, cast shadow in a minimal textured setting, a teapot, a monkey head",
|
164 |
"audioPrompt": "electronic goal music from the 90s",
|
|
|
158 |
},
|
159 |
{
|
160 |
"sequenceId": "46e94a7b-dc27-4949-819e-bb9bce60c460",
|
161 |
+
"skip": true,
|
162 |
"lastGenerationAt": "",
|
163 |
"videoPrompt": "a photorealistic compilation of various computer renderings and simulation featuring classical 3D animation of torus, cube, phong, shading, cast shadow in a minimal textured setting, a teapot, a monkey head",
|
164 |
"audioPrompt": "electronic goal music from the 90s",
|
package.json
CHANGED
@@ -5,9 +5,9 @@
|
|
5 |
"main": "src/index.mts",
|
6 |
"scripts": {
|
7 |
"start": "node --loader ts-node/esm src/index.mts",
|
8 |
-
"
|
9 |
-
"
|
10 |
-
"
|
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"
|
|
|
5 |
"main": "src/index.mts",
|
6 |
"scripts": {
|
7 |
"start": "node --loader ts-node/esm src/index.mts",
|
8 |
+
"batch:updatePlaylists": "node --loader ts-node/esm src/batch/updatePlaylists.mts",
|
9 |
+
"batch:interpolate": "node --loader ts-node/esm src/batch/interpolate_legacy.mts",
|
10 |
+
"batch:interpolate_legacy": "node --loader ts-node/esm src/batch/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/channel_comedy.sh
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/bin/bash
|
2 |
+
|
3 |
+
echo "Starting FFMPEG live stream for channel comedy"
|
4 |
+
while true; do
|
5 |
+
if [ -f channel_comedy.txt ] && [ -f channel_1_audio.txt ]; then
|
6 |
+
echo "Files exist, starting stream"
|
7 |
+
# Note: for now we also use channel 1 for audio!
|
8 |
+
ffmpeg -y -nostdin -re -f concat -safe 0 -i channel_comedy.txt -stream_loop -1 -safe 0 -i channel_1_audio.txt -loglevel error -c:v libx264 -preset veryfast -tune zerolatency -c:a aac -ar 44100 -shortest -f flv rtmp://localhost/live/comedy
|
9 |
+
else
|
10 |
+
echo "Files do not exist, waiting for files"
|
11 |
+
sleep 1 # check every second
|
12 |
+
fi
|
13 |
+
done
|
scripts/channel_community.sh
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/bin/bash
|
2 |
+
|
3 |
+
echo "Starting FFMPEG live stream for channel community"
|
4 |
+
while true; do
|
5 |
+
if [ -f channel_community.txt ] && [ -f channel_1_audio.txt ]; then
|
6 |
+
echo "Files exist, starting stream"
|
7 |
+
# Note: for now we also use channel 1 for audio!
|
8 |
+
ffmpeg -y -nostdin -re -f concat -safe 0 -i channel_community.txt -stream_loop -1 -safe 0 -i channel_1_audio.txt -loglevel error -c:v libx264 -preset veryfast -tune zerolatency -c:a aac -ar 44100 -shortest -f flv rtmp://localhost/live/community
|
9 |
+
else
|
10 |
+
echo "Files do not exist, waiting for files"
|
11 |
+
sleep 1 # check every second
|
12 |
+
fi
|
13 |
+
done
|
scripts/channel_random.sh
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/bin/bash
|
2 |
+
|
3 |
+
echo "Starting FFMPEG live stream for channel random"
|
4 |
+
while true; do
|
5 |
+
if [ -f channel_random.txt ] && [ -f channel_1_audio.txt ]; then
|
6 |
+
echo "Files exist, starting stream"
|
7 |
+
# Note: for now we also use channel 1 for audio!
|
8 |
+
ffmpeg -y -nostdin -re -f concat -safe 0 -i channel_random.txt -stream_loop -1 -safe 0 -i channel_1_audio.txt -loglevel error -c:v libx264 -preset veryfast -tune zerolatency -c:a aac -ar 44100 -shortest -f flv rtmp://localhost/live/random
|
9 |
+
else
|
10 |
+
echo "Files do not exist, waiting for files"
|
11 |
+
sleep 1 # check every second
|
12 |
+
fi
|
13 |
+
done
|
scripts/channel_random_twitch.sh
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/bin/bash
|
2 |
+
|
3 |
+
echo "Starting FFMPEG live stream for channel random"
|
4 |
+
while true; do
|
5 |
+
if [ -f channel_random.txt ] && [ -f channel_1_audio.txt ]; then
|
6 |
+
echo "Files exist, starting stream"
|
7 |
+
# Note: for now we also use channel 1 for audio!
|
8 |
+
ffmpeg -y -nostdin -re -f concat -safe 0 -i channel_random.txt -stream_loop -1 -safe 0 -i channel_1_audio.txt -loglevel error -c:v libx264 -preset veryfast -tune zerolatency -c:a aac -ar 44100 -shortest -f flv rtmp://cdg02.contribute.live-video.net/app/$WEBTV_TWITCH_API_KEY
|
9 |
+
sleep 1
|
10 |
+
else
|
11 |
+
echo "Files do not exist, waiting for files"
|
12 |
+
sleep 1 # check every second
|
13 |
+
fi
|
14 |
+
done
|
15 |
+
|
scripts/channel_sorter.sh
DELETED
File without changes
|
scripts/init.sh
CHANGED
@@ -1,46 +1,3 @@
|
|
1 |
#!/bin/bash
|
2 |
-
|
3 |
-
# ------------- CHANNEL 1 --------------
|
4 |
-
echo "creating the storage folders for channel 1.."
|
5 |
-
mkdir -p $WEBTV_VIDEO_STORAGE_PATH_CHANNEL_1
|
6 |
mkdir -p $WEBTV_AUDIO_STORAGE_PATH_CHANNEL_1
|
7 |
-
|
8 |
-
echo "creating the playlists for channel 1.."
|
9 |
-
echo "ffconcat version 1.0" > channel_1_video.txt
|
10 |
-
echo "ffconcat version 1.0" > channel_1_audio.txt
|
11 |
-
|
12 |
-
# ------------- CHANNEL 2 --------------
|
13 |
-
echo "creating the storage folders for channel 2.."
|
14 |
-
mkdir -p $WEBTV_VIDEO_STORAGE_PATH_CHANNEL_2
|
15 |
-
mkdir -p $WEBTV_AUDIO_STORAGE_PATH_CHANNEL_2
|
16 |
-
|
17 |
-
mkdir -p $WEBTV_VIDEO_ARCHIVE_PATH_CHANNEL_2
|
18 |
-
|
19 |
-
|
20 |
-
echo "creating the playlists for channel 2.."
|
21 |
-
echo "ffconcat version 1.0" > channel_2_video.txt
|
22 |
-
echo "ffconcat version 1.0" > channel_2_video.txt
|
23 |
-
|
24 |
-
|
25 |
-
# ------------- CHANNEL 3 --------------
|
26 |
-
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 |
-
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
|
35 |
-
|
36 |
-
|
37 |
-
# ------------- CHANNEL 4 --------------
|
38 |
-
echo "creating the storage folders for channel 4.."
|
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
|
|
|
1 |
#!/bin/bash
|
|
|
|
|
|
|
|
|
2 |
mkdir -p $WEBTV_AUDIO_STORAGE_PATH_CHANNEL_1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
mkdir -p $WEBTV_VIDEO_STORAGE_PATH_CHANNEL_3
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scripts/stream1.sh
DELETED
@@ -1,8 +0,0 @@
|
|
1 |
-
#!/bin/bash
|
2 |
-
|
3 |
-
COUNT=0
|
4 |
-
|
5 |
-
echo "Starting FFMPEG live stream for channel 1"
|
6 |
-
while true; do
|
7 |
-
ffmpeg -y -nostdin -re -f concat -safe 0 -i channel_1_video.txt -stream_loop -1 -safe 0 -i channel_1_audio.txt -loglevel error -c:v libx264 -preset veryfast -tune zerolatency -c:a aac -ar 44100 -shortest -f flv rtmp://localhost/live/legacy
|
8 |
-
done
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scripts/stream2.sh
DELETED
@@ -1,9 +0,0 @@
|
|
1 |
-
#!/bin/bash
|
2 |
-
|
3 |
-
COUNT=0
|
4 |
-
|
5 |
-
echo "Starting FFMPEG live stream for channel 2"
|
6 |
-
while true; do
|
7 |
-
# Note: for now we also use channel 1 for audio!
|
8 |
-
ffmpeg -y -nostdin -re -f concat -safe 0 -i channel_2_video.txt -stream_loop -1 -safe 0 -i channel_1_audio.txt -loglevel error -c:v libx264 -preset veryfast -tune zerolatency -c:a aac -ar 44100 -shortest -f flv rtmp://localhost/live/hdtv
|
9 |
-
done
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scripts/stream3.sh
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
#!/bin/bash
|
2 |
-
|
3 |
-
COUNT=0
|
4 |
-
|
5 |
-
echo "Starting FFMPEG live stream for channel 3"
|
6 |
-
while true; do
|
7 |
-
# Note: for now we also use channel 1 for audio!
|
8 |
-
ffmpeg -y -nostdin -re -f concat -safe 0 -i channel_3_video.txt -stream_loop -1 -safe 0 -i channel_1_audio.txt -loglevel error -c:v libx264 -preset veryfast -tune zerolatency -c:a aac -ar 44100 -shortest -f flv rtmp://localhost/live/smooth
|
9 |
-
sleep 1
|
10 |
-
done
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scripts/stream3_twitch.sh
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
#!/bin/bash
|
2 |
-
|
3 |
-
COUNT=0
|
4 |
-
|
5 |
-
echo "Starting FFMPEG live stream of channel 3 to Twitch"
|
6 |
-
while true; do
|
7 |
-
# Note: for now we also use channel 1 for audio!
|
8 |
-
ffmpeg -y -nostdin -re -f concat -safe 0 -i channel_3_video.txt -stream_loop -1 -safe 0 -i channel_1_audio.txt -loglevel error -c:v libx264 -preset veryfast -tune zerolatency -c:a aac -ar 44100 -shortest -f flv rtmp://cdg02.contribute.live-video.net/app/$WEBTV_TWITCH_API_KEY
|
9 |
-
sleep 1
|
10 |
-
done
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scripts/stream4.sh
DELETED
@@ -1,9 +0,0 @@
|
|
1 |
-
#!/bin/bash
|
2 |
-
|
3 |
-
COUNT=0
|
4 |
-
|
5 |
-
echo "Starting FFMPEG live stream for channel 4"
|
6 |
-
while true; do
|
7 |
-
# Note: for now we also use channel 1 for audio!
|
8 |
-
ffmpeg -y -nostdin -re -f concat -safe 0 -i channel_4_video.txt -stream_loop -1 -safe 0 -i channel_1_audio.txt -loglevel error -c:v libx264 -preset veryfast -tune zerolatency -c:a aac -ar 44100 -shortest -f flv rtmp://localhost/live/interactive
|
9 |
-
done
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scripts/video1.sh
DELETED
@@ -1,27 +0,0 @@
|
|
1 |
-
#!/bin/bash
|
2 |
-
|
3 |
-
echo "Starting the video collection stream for channel 1.."
|
4 |
-
echo "listing files in $WEBTV_VIDEO_STORAGE_PATH_CHANNEL_1*.mp4"
|
5 |
-
current_count=0
|
6 |
-
|
7 |
-
while true; do
|
8 |
-
new_count=$(ls $WEBTV_VIDEO_STORAGE_PATH_CHANNEL_1*.mp4 2> /dev/null | wc -l)
|
9 |
-
|
10 |
-
if [ $new_count -ne $current_count ]; then
|
11 |
-
echo "there are $new_count videos files for channel 1"
|
12 |
-
|
13 |
-
echo "Updating playlists for channel 1.."
|
14 |
-
current_count=$new_count
|
15 |
-
files=($WEBTV_VIDEO_STORAGE_PATH_CHANNEL_1*.mp4)
|
16 |
-
|
17 |
-
echo "ffconcat version 1.0" > channel_1_video_tmp.txt
|
18 |
-
for (( i=0; i<${#files[@]}; i++ )); do
|
19 |
-
echo "file '${files[$i]}'" >> channel_1_video_tmp.txt
|
20 |
-
done
|
21 |
-
mv channel_1_video_tmp.txt channel_1_video.txt
|
22 |
-
fi
|
23 |
-
|
24 |
-
# the new playlist will only be updated after the current playlist ended
|
25 |
-
# so there is no emergency here
|
26 |
-
sleep 60
|
27 |
-
done
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scripts/video2.sh
DELETED
@@ -1,28 +0,0 @@
|
|
1 |
-
#!/bin/bash
|
2 |
-
|
3 |
-
echo "Starting the video collection stream for channel 2.."
|
4 |
-
echo "listing files in $WEBTV_VIDEO_STORAGE_PATH_CHANNEL_2*.mp4"
|
5 |
-
current_count=0
|
6 |
-
|
7 |
-
while true; do
|
8 |
-
new_count=$(ls $WEBTV_VIDEO_STORAGE_PATH_CHANNEL_2*.mp4 2> /dev/null | wc -l)
|
9 |
-
|
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 |
-
|
17 |
-
echo "ffconcat version 1.0" > channel_2_video_tmp.txt
|
18 |
-
for (( i=0; i<${#files[@]}; i++ )); do
|
19 |
-
echo "file '${files[$i]}'" >> channel_2_video_tmp.txt
|
20 |
-
done
|
21 |
-
rm channel_2_video.txt
|
22 |
-
mv channel_2_video_tmp.txt channel_2_video.txt
|
23 |
-
fi
|
24 |
-
|
25 |
-
# the new playlist will only be updated after the current playlist ended
|
26 |
-
# so there is no emergency here
|
27 |
-
sleep 60
|
28 |
-
done
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scripts/video3.sh
DELETED
@@ -1,28 +0,0 @@
|
|
1 |
-
#!/bin/bash
|
2 |
-
|
3 |
-
echo "Starting the video collection stream for channel 3.."
|
4 |
-
echo "listing files in $WEBTV_VIDEO_STORAGE_PATH_CHANNEL_3*.mp4"
|
5 |
-
current_count=0
|
6 |
-
|
7 |
-
while true; do
|
8 |
-
new_count=$(ls $WEBTV_VIDEO_STORAGE_PATH_CHANNEL_3*.mp4 2> /dev/null | wc -l)
|
9 |
-
|
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 |
-
|
17 |
-
echo "ffconcat version 1.0" > channel_3_video_tmp.txt
|
18 |
-
for (( i=0; i<${#files[@]}; i++ )); do
|
19 |
-
echo "file '${files[$i]}'" >> channel_3_video_tmp.txt
|
20 |
-
done
|
21 |
-
rm channel_3_video.txt
|
22 |
-
mv channel_3_video_tmp.txt channel_3_video.txt
|
23 |
-
fi
|
24 |
-
|
25 |
-
# the new playlist will only be updated after the current playlist ended
|
26 |
-
# so there is no emergency here
|
27 |
-
sleep 60
|
28 |
-
done
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scripts/video4.sh
DELETED
@@ -1,27 +0,0 @@
|
|
1 |
-
#!/bin/bash
|
2 |
-
|
3 |
-
echo "Starting the video collection stream for channel 4.."
|
4 |
-
echo "listing files in $WEBTV_VIDEO_STORAGE_PATH_CHANNEL_4*.mp4"
|
5 |
-
current_count=0
|
6 |
-
|
7 |
-
while true; do
|
8 |
-
new_count=$(ls $WEBTV_VIDEO_STORAGE_PATH_CHANNEL_4*.mp4 2> /dev/null | wc -l)
|
9 |
-
|
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 |
-
|
17 |
-
echo "ffconcat version 1.0" > channel_4_video_tmp.txt
|
18 |
-
for (( i=0; i<${#files[@]}; i++ )); do
|
19 |
-
echo "file '${files[$i]}'" >> channel_4_video_tmp.txt
|
20 |
-
done
|
21 |
-
rm channel_4_video.txt
|
22 |
-
mv channel_4_video_tmp.txt channel_4_video.txt
|
23 |
-
fi
|
24 |
-
|
25 |
-
# channel 4 is an interactive channel, so we have tighter delays
|
26 |
-
sleep 20
|
27 |
-
done
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/{postprod → batch}/README.md
RENAMED
File without changes
|
src/{postprod → batch}/interpolate.txt
RENAMED
File without changes
|
src/{postprod → batch}/interpolateVideoCLI.txt
RENAMED
File without changes
|
src/{postprod → batch}/interpolateVideoCLILegacy.mts
RENAMED
File without changes
|
src/{postprod → batch}/interpolate_legacy.mts
RENAMED
File without changes
|
src/{postprod → batch}/sharpen.sh
RENAMED
File without changes
|
src/batch/updatePlaylists.mts
ADDED
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import fs from "fs"
|
2 |
+
import path from "path"
|
3 |
+
|
4 |
+
import { Database } from "../types.mts"
|
5 |
+
|
6 |
+
export const updatePlaylists = async (db: Database) => {
|
7 |
+
// TODO we should DROP THE CHANNEL 3 name,
|
8 |
+
// and only keep WEBTV_VIDEO_STORAGE_PATH
|
9 |
+
const directoryPath = process.env.WEBTV_VIDEO_STORAGE_PATH_CHANNEL_3
|
10 |
+
|
11 |
+
// Record of file paths categorized by tags
|
12 |
+
const categoryToFilePaths: Record<string, string[]> = {}
|
13 |
+
|
14 |
+
// Read JSON sequences
|
15 |
+
for (const sequence of db.sequences) {
|
16 |
+
// Read sequence tags and create empty category list if not already present
|
17 |
+
for (const tag of sequence.tags) {
|
18 |
+
if (!categoryToFilePaths[tag]) {
|
19 |
+
categoryToFilePaths[tag] = []
|
20 |
+
}
|
21 |
+
}
|
22 |
+
|
23 |
+
// Read files from the sequence
|
24 |
+
for (const shot of sequence.shots) {
|
25 |
+
const shotId = shot.shotId;
|
26 |
+
const mp4FileName = `${shotId}.mp4`
|
27 |
+
const shotFilePath = path.join(directoryPath, mp4FileName)
|
28 |
+
|
29 |
+
// Check if file exists
|
30 |
+
if (fs.existsSync(shotFilePath)) {
|
31 |
+
// Add the file path to the categories
|
32 |
+
for (const tag of sequence.tags) {
|
33 |
+
categoryToFilePaths[tag].push(shotFilePath)
|
34 |
+
}
|
35 |
+
}
|
36 |
+
}
|
37 |
+
}
|
38 |
+
|
39 |
+
// Print the stats
|
40 |
+
for (const [category, filePaths] of Object.entries(categoryToFilePaths)) {
|
41 |
+
console.log(
|
42 |
+
`Category: ${category}; Number of Files: ${filePaths.length}; Files: ${filePaths.join(
|
43 |
+
", "
|
44 |
+
)}`
|
45 |
+
)
|
46 |
+
}
|
47 |
+
|
48 |
+
// create the new playlists
|
49 |
+
for (const [category, filePaths] of Object.entries(categoryToFilePaths)) {
|
50 |
+
if (filePaths.length > 0) {
|
51 |
+
console.log(`creating playlist for ${category}..`)
|
52 |
+
|
53 |
+
let data = 'ffconcat version 1.0\n'
|
54 |
+
filePaths.forEach((filePath) => {
|
55 |
+
data += `file '${filePath}'\n`
|
56 |
+
})
|
57 |
+
|
58 |
+
// write file data synchronously
|
59 |
+
fs.writeFileSync(`channel_${category}.txt`, data)
|
60 |
+
console.log(`Created playlist channel_${category}.txt`)
|
61 |
+
}
|
62 |
+
}
|
63 |
+
|
64 |
+
// Get all the file paths in the directory
|
65 |
+
const allFiles = await fs.promises.readdir(directoryPath)
|
66 |
+
const allFilePaths = allFiles
|
67 |
+
.map(file => path.join(directoryPath, file))
|
68 |
+
.filter(filePath => filePath.endsWith('.mp4'))
|
69 |
+
|
70 |
+
// Create channel_random.txt with all files
|
71 |
+
let randomData = 'ffconcat version 1.0\n'
|
72 |
+
allFilePaths.forEach(filePath => {
|
73 |
+
randomData += `file '${filePath}'\n`
|
74 |
+
})
|
75 |
+
await fs.promises.writeFile("channel_random.txt", randomData)
|
76 |
+
console.log("Created playlist channel_random.txt")
|
77 |
+
|
78 |
+
// Filter the list for the last 400 updated files
|
79 |
+
const lastUpdatedFilePaths = allFilePaths
|
80 |
+
.map(filePath => ({
|
81 |
+
filePath,
|
82 |
+
mtime: fs.statSync(filePath).mtime
|
83 |
+
}))
|
84 |
+
.sort((a, b) => b.mtime.getTime() - a.mtime.getTime())
|
85 |
+
.slice(0, 400)
|
86 |
+
.map(file => file.filePath)
|
87 |
+
|
88 |
+
// Create channel_fresh.txt
|
89 |
+
let freshData = 'ffconcat version 1.0\n'
|
90 |
+
lastUpdatedFilePaths.forEach(filePath => {
|
91 |
+
freshData += `file '${filePath}'\n`
|
92 |
+
})
|
93 |
+
await fs.promises.writeFile("channel_fresh.txt", freshData)
|
94 |
+
console.log("Created playlist channel_fresh.txt")
|
95 |
+
}
|
src/index.mts
CHANGED
@@ -9,6 +9,7 @@ import { downloadVideo } from './downloadVideo.mts'
|
|
9 |
import { getDatabase } from './getDatabase.mts'
|
10 |
import { callMusicgen } from './callMusicgen.mts'
|
11 |
import { interpolateVideo } from './interpolateVideo.mts'
|
|
|
12 |
|
13 |
let hasReachedStartingPoint = false
|
14 |
|
@@ -21,6 +22,9 @@ console.log(`Web TV server status: ${status}`)
|
|
21 |
// to add more diversity to the stream, let's cut down on the length
|
22 |
const maxShotsPerSequence = 10
|
23 |
|
|
|
|
|
|
|
24 |
const main = async () => {
|
25 |
console.log('Reading persistent file structure..')
|
26 |
const stats = await getStats()
|
@@ -34,9 +38,7 @@ const main = async () => {
|
|
34 |
return
|
35 |
}
|
36 |
|
37 |
-
|
38 |
-
console.log('Reading prompt database..')
|
39 |
-
const db = await getDatabase('./database.json')
|
40 |
|
41 |
const nbTotalShots = db.sequences.reduce((a, s) => a + s.shots.length, 0)
|
42 |
console.log(`Prompt database version: ${db.version}`)
|
|
|
9 |
import { getDatabase } from './getDatabase.mts'
|
10 |
import { callMusicgen } from './callMusicgen.mts'
|
11 |
import { interpolateVideo } from './interpolateVideo.mts'
|
12 |
+
import { updatePlaylists } from './batch/updatePlaylists.mts'
|
13 |
|
14 |
let hasReachedStartingPoint = false
|
15 |
|
|
|
22 |
// to add more diversity to the stream, let's cut down on the length
|
23 |
const maxShotsPerSequence = 10
|
24 |
|
25 |
+
console.log('Reading prompt database..')
|
26 |
+
const db = await getDatabase('./database.json')
|
27 |
+
|
28 |
const main = async () => {
|
29 |
console.log('Reading persistent file structure..')
|
30 |
const stats = await getStats()
|
|
|
38 |
return
|
39 |
}
|
40 |
|
41 |
+
await updatePlaylists(db)
|
|
|
|
|
42 |
|
43 |
const nbTotalShots = db.sequences.reduce((a, s) => a + s.shots.length, 0)
|
44 |
console.log(`Prompt database version: ${db.version}`)
|
start.sh
CHANGED
@@ -15,13 +15,15 @@ bash ./scripts/init.sh
|
|
15 |
|
16 |
# ------ background processes ---------
|
17 |
|
18 |
-
bash scripts/interpolate.sh &
|
19 |
-
|
20 |
# starts the streaming server first, otherwise ffmpeg won't find it
|
21 |
node ./media-server.js &
|
22 |
|
23 |
sleep 1
|
24 |
|
|
|
|
|
|
|
|
|
25 |
# background process that creates an audio stream from audio files
|
26 |
bash scripts/audio1.sh &
|
27 |
# bash scripts/audio2.sh &
|
|
|
15 |
|
16 |
# ------ background processes ---------
|
17 |
|
|
|
|
|
18 |
# starts the streaming server first, otherwise ffmpeg won't find it
|
19 |
node ./media-server.js &
|
20 |
|
21 |
sleep 1
|
22 |
|
23 |
+
bash scripts/interpolate.sh &
|
24 |
+
|
25 |
+
sleep 1
|
26 |
+
|
27 |
# background process that creates an audio stream from audio files
|
28 |
bash scripts/audio1.sh &
|
29 |
# bash scripts/audio2.sh &
|