download speed improvement
Browse files- App/Worker.py +53 -11
- Remotion-app/remotion.config.js +2 -2
App/Worker.py
CHANGED
@@ -10,7 +10,8 @@ from celery.signals import worker_process_init
|
|
10 |
from asgiref.sync import async_to_sync
|
11 |
import json
|
12 |
import os
|
13 |
-
from pydantic import BaseModel
|
|
|
14 |
from App.utilis import upload_file
|
15 |
|
16 |
import subprocess
|
@@ -46,12 +47,32 @@ def concatenate_videos(input_dir):
|
|
46 |
|
47 |
class YouTubeUploadTask(BaseModel):
|
48 |
filename: str
|
49 |
-
title: str =
|
50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
category_id: str = "22" # Default to a generic category, update as needed
|
52 |
privacy: str = "private"
|
53 |
-
tags: str =
|
54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
|
56 |
|
57 |
# celery = Celery()
|
@@ -140,7 +161,12 @@ def change_playback_speed(input_path, speed_factor):
|
|
140 |
os.replace(temp_output_path, input_path)
|
141 |
|
142 |
|
143 |
-
def download_with_wget(
|
|
|
|
|
|
|
|
|
|
|
144 |
headers = [
|
145 |
"--header",
|
146 |
"Cookie: __Host-session=63EQahvTpHuoFSkEW75hC",
|
@@ -149,7 +175,10 @@ def download_with_wget(link, download_dir, filename):
|
|
149 |
]
|
150 |
|
151 |
# Construct the full command
|
152 |
-
|
|
|
|
|
|
|
153 |
|
154 |
# Run the command
|
155 |
subprocess.run(command)
|
@@ -209,10 +238,19 @@ def upload_video_to_youtube(task_data: dict):
|
|
209 |
# @celery.task(name="DownloadAssets")
|
210 |
def download_assets(links: List[LinkInfo], temp_dir: str):
|
211 |
public_dir = f"{temp_dir}/public"
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
216 |
|
217 |
|
218 |
# @celery.task(name="RenderFile")
|
@@ -269,6 +307,10 @@ async def celery_task(video_task: EditorRequest):
|
|
269 |
render_video(temp_dir, output_dir)
|
270 |
change_playback_speed(output_dir, 1.2)
|
271 |
# unsilence(temp_dir)
|
|
|
|
|
|
|
|
|
272 |
await cleanup_temp_directory(temp_dir, output_dir, video_task)
|
273 |
|
274 |
# chain(
|
|
|
10 |
from asgiref.sync import async_to_sync
|
11 |
import json
|
12 |
import os
|
13 |
+
from pydantic import BaseModel, Field
|
14 |
+
from App.Generate.utils.GroqInstruct import tagger
|
15 |
from App.utilis import upload_file
|
16 |
|
17 |
import subprocess
|
|
|
47 |
|
48 |
class YouTubeUploadTask(BaseModel):
|
49 |
filename: str
|
50 |
+
title: str = Field(
|
51 |
+
...,
|
52 |
+
min_length=100,
|
53 |
+
max_length=500,
|
54 |
+
description="A good title for the video",
|
55 |
+
)
|
56 |
+
description: str = Field(
|
57 |
+
...,
|
58 |
+
min_length=100,
|
59 |
+
max_length=500,
|
60 |
+
description="A brief summary of the video's content",
|
61 |
+
)
|
62 |
category_id: str = "22" # Default to a generic category, update as needed
|
63 |
privacy: str = "private"
|
64 |
+
tags: str = Field(
|
65 |
+
...,
|
66 |
+
min_length=100,
|
67 |
+
max_length=500,
|
68 |
+
description="Best seo tags for youtube based on the story",
|
69 |
+
)
|
70 |
+
thumbnail: str = Field(
|
71 |
+
...,
|
72 |
+
min_length=100,
|
73 |
+
max_length=500,
|
74 |
+
description="""Best image prompt based on the image description: here is an """,
|
75 |
+
)
|
76 |
|
77 |
|
78 |
# celery = Celery()
|
|
|
161 |
os.replace(temp_output_path, input_path)
|
162 |
|
163 |
|
164 |
+
def download_with_wget(
|
165 |
+
link=None,
|
166 |
+
download_dir=None,
|
167 |
+
filename=None,
|
168 |
+
links_file_path=None,
|
169 |
+
):
|
170 |
headers = [
|
171 |
"--header",
|
172 |
"Cookie: __Host-session=63EQahvTpHuoFSkEW75hC",
|
|
|
175 |
]
|
176 |
|
177 |
# Construct the full command
|
178 |
+
if links_file_path:
|
179 |
+
command = ["aria2c", "-i", links_file_path, "--dir", download_dir]
|
180 |
+
else:
|
181 |
+
command = ["aria2c"] + headers + [link, "-d", download_dir, "-o", filename]
|
182 |
|
183 |
# Run the command
|
184 |
subprocess.run(command)
|
|
|
238 |
# @celery.task(name="DownloadAssets")
|
239 |
def download_assets(links: List[LinkInfo], temp_dir: str):
|
240 |
public_dir = f"{temp_dir}/public"
|
241 |
+
os.makedirs(public_dir, exist_ok=True)
|
242 |
+
|
243 |
+
links_file_path = os.path.join(temp_dir, "download_links.txt")
|
244 |
+
|
245 |
+
with open(links_file_path, "w") as links_file:
|
246 |
+
for link in links:
|
247 |
+
file_link = link.link
|
248 |
+
file_name = link.file_name
|
249 |
+
# Write each link to the file in the format required by aria2c
|
250 |
+
links_file.write(
|
251 |
+
f"{file_link}\n out={os.path.join(public_dir, file_name)}\n"
|
252 |
+
)
|
253 |
+
download_with_wget(links_file_path=links_file_path, download_dir=public_dir)
|
254 |
|
255 |
|
256 |
# @celery.task(name="RenderFile")
|
|
|
307 |
render_video(temp_dir, output_dir)
|
308 |
change_playback_speed(output_dir, 1.2)
|
309 |
# unsilence(temp_dir)
|
310 |
+
response: YouTubeUploadTask = tagger(narration="", response_model=YouTubeUploadTask)
|
311 |
+
|
312 |
+
response.filename = output_dir
|
313 |
+
upload_video_to_youtube()
|
314 |
await cleanup_temp_directory(temp_dir, output_dir, video_task)
|
315 |
|
316 |
# chain(
|
Remotion-app/remotion.config.js
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
// Note: When using the Node.JS APIs, the config file doesn't apply. Instead, pass options directly to the APIs
|
5 |
|
6 |
import {Config} from '@remotion/cli/config';
|
7 |
-
|
8 |
import {enableTailwind} from '@remotion/tailwind';
|
9 |
Config.overrideWebpackConfig((currentConfiguration) => {
|
10 |
return enableTailwind(currentConfiguration);
|
@@ -12,4 +12,4 @@ Config.overrideWebpackConfig((currentConfiguration) => {
|
|
12 |
|
13 |
//Config.setBrowserExecutable("/usr/bin/chrome-headless-shell");
|
14 |
Config.setVideoImageFormat('jpeg');
|
15 |
-
Config.setConcurrency(
|
|
|
4 |
// Note: When using the Node.JS APIs, the config file doesn't apply. Instead, pass options directly to the APIs
|
5 |
|
6 |
import {Config} from '@remotion/cli/config';
|
7 |
+
|
8 |
import {enableTailwind} from '@remotion/tailwind';
|
9 |
Config.overrideWebpackConfig((currentConfiguration) => {
|
10 |
return enableTailwind(currentConfiguration);
|
|
|
12 |
|
13 |
//Config.setBrowserExecutable("/usr/bin/chrome-headless-shell");
|
14 |
Config.setVideoImageFormat('jpeg');
|
15 |
+
Config.setConcurrency(1);
|