Spaces:
Runtime error
Runtime error
Upload 28 files
#1
by
medallo
- opened
- app.py +966 -149
- create_image2_to_video_15.py +196 -0
- create_image_to_video_15.py +157 -0
- create_task.py +29 -2
- create_text_to_video.py +33 -7
- create_text_to_video_15.py +112 -0
- create_video_reference.py +29 -2
- create_video_reference2_15.py +166 -0
- create_video_reference_15.py +195 -0
- headtailimg2video.py +28 -3
- main.py +29 -4
- token_extractor.py +131 -0
- upload/file_uploader.py +17 -3
- upload/file_uploader_with_etag.py +1 -1
- utils/auth.py +18 -2
- utils/delete_task.py +18 -2
- utils/delete_task_upscale.py +16 -2
- utils/fragment.py +4 -4
- utils/process_task.py +2 -2
- utils/process_task_upscale.py +2 -2
- utils/union.py +4 -4
- utils/upscale_task.py +16 -2
- utils/video_fragment.py +1 -1
- vidu_credit.py +2 -2
app.py
CHANGED
@@ -5,74 +5,294 @@ import gradio as gr
|
|
5 |
import cv2
|
6 |
|
7 |
# Codigo creado por IA(Sistema de Interes) https://www.youtube.com/@IA.Sistema.de.Interes
|
8 |
-
|
9 |
-
def run_commands(description, aspect_ratio, enhance_check, model, style, upscale_check, task_type, img=None, is_extend=False, is_recreate=False):
|
10 |
try:
|
11 |
-
|
|
|
|
|
12 |
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
else:
|
18 |
-
|
|
|
|
|
|
|
|
|
19 |
|
20 |
-
if task_type == "video_to_video":
|
21 |
-
commands.append('python /content/Vidu_Studio/utils/video_fragment.py')
|
22 |
-
print("File Uploader...")
|
23 |
-
commands.append('python /content/Vidu_Studio/upload/file_uploader.py --file_info "file_info" --image "img_fragmento"')
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
|
|
|
28 |
|
29 |
-
|
30 |
-
|
31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
|
33 |
-
if
|
34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
commands.append(
|
36 |
-
f'python
|
37 |
)
|
38 |
-
|
39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
commands.append(
|
41 |
-
|
42 |
)
|
43 |
-
|
44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
commands.append(
|
46 |
-
f'python
|
47 |
)
|
48 |
-
|
49 |
-
print("
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
commands.append(
|
51 |
-
f'python
|
52 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
else:
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
print("Generate Upscale...")
|
60 |
-
commands.append('python /content/Vidu_Studio/utils/upscale_task.py')
|
61 |
-
print("Upscale in progress...")
|
62 |
-
commands.append('python /content/Vidu_Studio/utils/process_task_upscale.py')
|
63 |
-
commands.append('python /content/Vidu_Studio/utils/delete_task.py')
|
64 |
-
commands.append('python /content/Vidu_Studio/utils/delete_task_upscale.py')
|
65 |
-
else:
|
66 |
-
commands.append('python /content/Vidu_Studio/utils/delete_task.py')
|
67 |
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
|
74 |
-
video_path = "/content/Vidu_Studio/video.mp4"
|
75 |
-
return output, video_path
|
76 |
except Exception as e:
|
77 |
return f"Excepción: {str(e)}", None
|
78 |
|
@@ -80,82 +300,510 @@ def run_commands(description, aspect_ratio, enhance_check, model, style, upscale
|
|
80 |
|
81 |
|
82 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
|
|
|
|
|
|
|
|
|
84 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
|
86 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
try:
|
88 |
-
|
|
|
|
|
89 |
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
|
97 |
-
|
98 |
-
|
99 |
-
commands.append('python /content/Vidu_Studio/upload/file_uploader.py --file_info "file_info2" --image "img_fragmento2"')
|
100 |
|
101 |
-
|
102 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
103 |
commands.append(
|
104 |
-
f'python
|
105 |
)
|
106 |
-
|
107 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
116 |
else:
|
117 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
else:
|
119 |
-
#
|
120 |
-
|
121 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
else:
|
123 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
|
125 |
-
|
126 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
|
128 |
-
if task_type == "headtailimg2video":
|
129 |
print("Generating video with Image to Video...")
|
130 |
commands.append(
|
131 |
-
f'python
|
132 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
133 |
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
144 |
else:
|
145 |
-
|
|
|
|
|
|
|
|
|
146 |
|
|
|
|
|
147 |
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
153 |
|
154 |
-
video_path = "/content/Vidu_Studio/video.mp4"
|
155 |
-
return output, video_path
|
156 |
except Exception as e:
|
157 |
return f"Excepción: {str(e)}", None
|
158 |
|
|
|
|
|
159 |
# Función para procesar y guardar la imagen automáticamente en formato JPG
|
160 |
def process_and_save_image(image, coordinates_file_path="/tmp/coordinates.txt"):
|
161 |
jpg_path = "/tmp/img_fragmento.jpg"
|
@@ -258,15 +906,15 @@ def run_save_commands():
|
|
258 |
try:
|
259 |
print("Rendering video...")
|
260 |
commands = [
|
261 |
-
"python
|
262 |
-
"python
|
263 |
]
|
264 |
output = ""
|
265 |
for command in commands:
|
266 |
result = subprocess.run(command, shell=True, capture_output=True, text=True)
|
267 |
output += f"Exit:\n{result.stdout}\n"
|
268 |
print(result.stdout)
|
269 |
-
video_path = "
|
270 |
return output, video_path
|
271 |
except Exception as e:
|
272 |
return f"Excepción al guardar: {str(e)}", None
|
@@ -274,7 +922,25 @@ def run_save_commands():
|
|
274 |
# Función para mostrar o ocultar el segundo cuadro de imagen
|
275 |
def activar_end_frame(activar):
|
276 |
return gr.update(visible=activar)
|
277 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
278 |
# Definir la interfaz
|
279 |
with gr.Blocks() as demo:
|
280 |
# Agregar un título en grande al inicio de la interfaz
|
@@ -284,6 +950,12 @@ with gr.Blocks() as demo:
|
|
284 |
with gr.Tab("Image to Video"):
|
285 |
with gr.Row():
|
286 |
with gr.Column():
|
|
|
|
|
|
|
|
|
|
|
|
|
287 |
add_end_frame = gr.Checkbox(label="Add End Frame", value=False)
|
288 |
|
289 |
# Fila para mostrar ambas imágenes cuando se activa
|
@@ -299,12 +971,23 @@ with gr.Blocks() as demo:
|
|
299 |
description_input = gr.Textbox(label="Prompt",
|
300 |
placeholder="Aquí va una caja de texto editable para el prompt",
|
301 |
elem_id="description_input")
|
|
|
302 |
enhance_checkbox = gr.Checkbox(label="Enhance prompt", value=False, elem_id="enhance_checkbox")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
303 |
model_dropdown = gr.Dropdown(
|
304 |
choices=["vidu-1", "vidu-high-performance"],
|
305 |
label="Model",
|
306 |
value="vidu-1",
|
307 |
-
elem_id="model_dropdown"
|
|
|
308 |
)
|
309 |
upscale_checkbox = gr.Checkbox(label="Upscale", value=False, elem_id="upscale_checkbox")
|
310 |
create_button = gr.Button("Create", elem_id="create_button")
|
@@ -335,22 +1018,22 @@ with gr.Blocks() as demo:
|
|
335 |
|
336 |
# Botón "Create" y su salida
|
337 |
create_button.click(
|
338 |
-
fn=lambda desc, enhance, model, upscale, img, add_end:
|
339 |
-
inputs=[description_input, enhance_checkbox, model_dropdown, upscale_checkbox, img1, add_end_frame
|
340 |
-
outputs=[output_textbox, video_output]
|
341 |
-
)
|
342 |
|
343 |
# Botón "Extend" y su salida
|
344 |
extend_button.click(
|
345 |
-
fn=lambda desc, enhance, model, upscale, img:
|
346 |
-
inputs=[description_input, enhance_checkbox, model_dropdown, upscale_checkbox, img1
|
347 |
outputs=[output_textbox, video_output]
|
348 |
)
|
349 |
|
350 |
# Botón "Re-create" y su salida
|
351 |
recreate_button.click(
|
352 |
-
fn=lambda desc, enhance, model, upscale, img:
|
353 |
-
inputs=[description_input, enhance_checkbox, model_dropdown, upscale_checkbox, img1
|
354 |
outputs=[output_textbox, video_output]
|
355 |
)
|
356 |
|
@@ -361,22 +1044,68 @@ with gr.Blocks() as demo:
|
|
361 |
outputs=[output_textbox, video_output]
|
362 |
)
|
363 |
|
|
|
|
|
|
|
|
|
|
|
|
|
364 |
# Segunda pestaña: Reference to Video
|
365 |
with gr.Tab("Reference to Video"):
|
366 |
with gr.Row():
|
367 |
with gr.Column():
|
368 |
-
|
369 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
370 |
description_input2 = gr.Textbox(label="Prompt",
|
371 |
placeholder="Enter text to begin creating a video that aligns with the subject of the image",
|
372 |
elem_id="description_input2")
|
|
|
373 |
enhance_checkbox2 = gr.Checkbox(label="Enhance prompt", value=False, elem_id="enhance_checkbox2")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
374 |
model_dropdown2 = gr.Dropdown(
|
375 |
choices=["vidu-1", "vidu-high-performance"],
|
376 |
label="Model",
|
377 |
value="vidu-1",
|
378 |
-
elem_id="model_dropdown2"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
379 |
)
|
|
|
380 |
upscale_checkbox2 = gr.Checkbox(label="Upscale", value=False, elem_id="upscale_checkbox2")
|
381 |
create_button2 = gr.Button("Create", elem_id="create_button2")
|
382 |
extend_button2 = gr.Button("Extend", elem_id="extend_button2")
|
@@ -387,31 +1116,40 @@ with gr.Blocks() as demo:
|
|
387 |
video_output2 = gr.Video(label="Video Output Reference to Video", height=400, elem_id="video_output_reference_to_video")
|
388 |
output_textbox2 = gr.Textbox(label="Output", interactive=False, elem_id="output_textbox2") # Cambia el nombre del textbox
|
389 |
|
390 |
-
#
|
391 |
-
|
392 |
-
|
393 |
-
|
|
|
|
|
394 |
outputs=[]
|
395 |
)
|
396 |
|
397 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
398 |
create_button2.click(
|
399 |
-
fn=lambda desc, enhance, model, upscale, img:
|
400 |
-
inputs=[description_input2, enhance_checkbox2, model_dropdown2, upscale_checkbox2,
|
401 |
outputs=[output_textbox2, video_output2]
|
402 |
)
|
403 |
|
|
|
404 |
# Botón "Extend" y su salida
|
405 |
extend_button2.click(
|
406 |
-
fn=lambda desc, enhance, model, upscale, img:
|
407 |
-
inputs=[description_input2, enhance_checkbox2, model_dropdown2, upscale_checkbox2,
|
408 |
outputs=[output_textbox2, video_output2]
|
409 |
)
|
410 |
|
411 |
# Botón "Re-create" y su salida
|
412 |
recreate_button2.click(
|
413 |
-
fn=lambda desc, enhance, model, upscale, img:
|
414 |
-
inputs=[description_input2, enhance_checkbox2, model_dropdown2, upscale_checkbox2,
|
415 |
outputs=[output_textbox2, video_output2]
|
416 |
)
|
417 |
|
@@ -422,25 +1160,50 @@ with gr.Blocks() as demo:
|
|
422 |
outputs=[output_textbox2, video_output2]
|
423 |
)
|
424 |
|
|
|
|
|
|
|
|
|
|
|
|
|
425 |
# Tercera pestaña: Text to Video
|
426 |
with gr.Tab("Text to Video"):
|
427 |
with gr.Row():
|
428 |
with gr.Column():
|
|
|
|
|
|
|
|
|
|
|
|
|
429 |
description_input3 = gr.Textbox(label="Prompt",
|
430 |
placeholder="Enter text to begin creating a video",
|
431 |
elem_id="description_input3")
|
|
|
|
|
|
|
432 |
aspect_ratio_dropdown = gr.Dropdown(
|
433 |
choices=["16:9", "9:16", "4:3", "1:1"],
|
434 |
label="Aspect Ratio",
|
435 |
value="16:9",
|
436 |
elem_id="aspect_ratio_dropdown"
|
437 |
)
|
438 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
439 |
model_dropdown3 = gr.Dropdown(
|
440 |
choices=["vidu-1", "vidu-high-performance"],
|
441 |
label="Model",
|
442 |
value="vidu-1",
|
443 |
-
elem_id="model_dropdown3"
|
|
|
444 |
)
|
445 |
style_dropdown3 = gr.Dropdown(
|
446 |
choices=["general", "anime"],
|
@@ -448,6 +1211,12 @@ with gr.Blocks() as demo:
|
|
448 |
value="general",
|
449 |
elem_id="style_dropdown3"
|
450 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
451 |
upscale_checkbox3 = gr.Checkbox(label="Upscale", value=False, elem_id="upscale_checkbox3")
|
452 |
create_button3 = gr.Button("Create", elem_id="create_button3")
|
453 |
extend_button3 = gr.Button("Extend", elem_id="extend_button3")
|
@@ -460,29 +1229,28 @@ with gr.Blocks() as demo:
|
|
460 |
|
461 |
# Botón "Create" y su salida
|
462 |
create_button3.click(
|
463 |
-
fn=lambda desc, ratio, enhance, model, style, upscale:
|
464 |
-
upscale, task_type="text_to_video"),
|
465 |
inputs=[description_input3, aspect_ratio_dropdown, enhance_checkbox3, model_dropdown3, style_dropdown3,
|
466 |
-
upscale_checkbox3],
|
467 |
outputs=[output_textbox3, video_output3]
|
468 |
)
|
469 |
|
470 |
-
|
471 |
extend_button3.click(
|
472 |
-
fn=lambda desc, enhance, model, upscale:
|
473 |
-
inputs=[description_input3, enhance_checkbox3, model_dropdown3, upscale_checkbox3
|
474 |
outputs=[output_textbox3, video_output3]
|
475 |
)
|
476 |
|
477 |
# Botón "Re-create" y su salida
|
478 |
recreate_button3.click(
|
479 |
-
fn=lambda desc,
|
480 |
-
|
481 |
-
inputs=[description_input3, aspect_ratio_dropdown, enhance_checkbox3, model_dropdown3, style_dropdown3,
|
482 |
-
upscale_checkbox3],
|
483 |
outputs=[output_textbox3, video_output3]
|
484 |
)
|
485 |
|
|
|
486 |
# Botón "Save" y su salida
|
487 |
save_button3.click(
|
488 |
fn=run_save_commands,
|
@@ -490,21 +1258,63 @@ with gr.Blocks() as demo:
|
|
490 |
outputs=[output_textbox3, video_output3]
|
491 |
)
|
492 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
493 |
# Cuarta pestaña: Video to Video
|
494 |
with gr.Tab("Video to Video"):
|
495 |
with gr.Row():
|
496 |
with gr.Column():
|
|
|
|
|
|
|
|
|
|
|
|
|
497 |
video_input4 = gr.Video(label="Input Video", height=400, interactive=True) # Agregar entrada de video
|
|
|
498 |
description_input4 = gr.Textbox(label="Prompt",
|
499 |
placeholder="Enter text to begin creating a video",
|
500 |
elem_id="description_input4")
|
501 |
enhance_checkbox4 = gr.Checkbox(label="Enhance prompt", value=False, elem_id="enhance_checkbox4")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
502 |
model_dropdown4 = gr.Dropdown(
|
503 |
choices=["vidu-1", "vidu-high-performance"],
|
504 |
label="Model",
|
505 |
value="vidu-1",
|
506 |
elem_id="model_dropdown4"
|
507 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
508 |
upscale_checkbox4 = gr.Checkbox(label="Upscale", value=False, elem_id="upscale_checkbox4")
|
509 |
create_button4 = gr.Button("Create", elem_id="create_button4")
|
510 |
extend_button4 = gr.Button("Extend", elem_id="extend_button4")
|
@@ -515,12 +1325,12 @@ with gr.Blocks() as demo:
|
|
515 |
video_output4 = gr.Video(label="Video Output Video to Video", height=400, elem_id="video_output_video_to_video")
|
516 |
output_textbox4 = gr.Textbox(label="Output", interactive=False, elem_id="output_textbox4") # Cambia el nombre del textbox
|
517 |
|
518 |
-
# Guardar el video cargado en
|
519 |
def save_uploaded_video(video):
|
520 |
if video is not None:
|
521 |
video_path = video
|
522 |
-
result = subprocess.run(f"cp '{video_path}'
|
523 |
-
print(f"Video guardado en
|
524 |
print(result.stdout)
|
525 |
|
526 |
# Ejecutar save_uploaded_video cuando se carga un video
|
@@ -532,22 +1342,22 @@ with gr.Blocks() as demo:
|
|
532 |
|
533 |
# Botón "Create" y su salida
|
534 |
create_button4.click(
|
535 |
-
fn=lambda desc, enhance, model, upscale:
|
536 |
-
inputs=[description_input4, enhance_checkbox4, model_dropdown4, upscale_checkbox4
|
537 |
outputs=[output_textbox4, video_output4]
|
538 |
)
|
539 |
-
|
540 |
# Botón "Extend" y su salida
|
541 |
extend_button4.click(
|
542 |
-
fn=lambda desc, enhance, model, upscale:
|
543 |
-
inputs=[description_input4, enhance_checkbox4, model_dropdown4, upscale_checkbox4
|
544 |
outputs=[output_textbox4, video_output4]
|
545 |
)
|
546 |
|
547 |
# Botón "Re-create" y su salida
|
548 |
recreate_button4.click(
|
549 |
-
fn=lambda desc, enhance, model, upscale:
|
550 |
-
inputs=[description_input4, enhance_checkbox4, model_dropdown4, upscale_checkbox4
|
551 |
outputs=[output_textbox4, video_output4]
|
552 |
)
|
553 |
|
@@ -558,5 +1368,12 @@ with gr.Blocks() as demo:
|
|
558 |
outputs=[output_textbox4, video_output4]
|
559 |
)
|
560 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
561 |
# Ejecutar la interfaz
|
562 |
demo.launch(inline=False, debug=True, share=True)
|
|
|
5 |
import cv2
|
6 |
|
7 |
# Codigo creado por IA(Sistema de Interes) https://www.youtube.com/@IA.Sistema.de.Interes
|
8 |
+
def run_commands_text_to_video(description, aspect_ratio, enhance_check, model, style, upscale_check, version, movement, task_type, img=None, is_extend=False, is_recreate=False):
|
|
|
9 |
try:
|
10 |
+
# Verifica si la versión es "1.0"
|
11 |
+
if version == "1.0":
|
12 |
+
commands = []
|
13 |
|
14 |
+
if add_end_frame:
|
15 |
+
# Comandos generales según el tipo de tarea
|
16 |
+
if upscale_check:
|
17 |
+
commands.append('python vidu_credit.py --credit 4')
|
18 |
+
else:
|
19 |
+
commands.append('python vidu_credit.py --credit 0')
|
20 |
+
|
21 |
+
print("Generating video: Text to Video...")
|
22 |
+
commands.append(
|
23 |
+
f'python create_text_to_video.py --prompt "{description}" --enhance {str(enhance_check).lower()} --model "{model}" --style "{style}" --aspect_ratio "{aspect_ratio}"'
|
24 |
+
)
|
25 |
+
print("Video in progress...")
|
26 |
+
commands.append('python utils/process_task.py')
|
27 |
+
|
28 |
+
if upscale_check:
|
29 |
+
print("Generate Upscale...")
|
30 |
+
commands.append('python utils/upscale_task.py')
|
31 |
+
print("Upscale in progress...")
|
32 |
+
commands.append('python utils/process_task_upscale.py')
|
33 |
+
commands.append('python utils/delete_task.py')
|
34 |
+
commands.append('python utils/delete_task_upscale.py')
|
35 |
+
else:
|
36 |
+
commands.append('python utils/delete_task.py')
|
37 |
else:
|
38 |
+
# Comandos generales según el tipo de tarea
|
39 |
+
if upscale_check:
|
40 |
+
commands.append('python vidu_credit.py --credit 4')
|
41 |
+
else:
|
42 |
+
commands.append('python vidu_credit.py --credit 0')
|
43 |
|
|
|
|
|
|
|
|
|
44 |
|
45 |
+
print("Generating video: Text to Video...")
|
46 |
+
commands.append(
|
47 |
+
f'python create_text_to_video.py --prompt "{description}" --enhance {str(enhance_check).lower()} --model "{model}" --style "{style}" --aspect_ratio "{aspect_ratio}"'
|
48 |
+
)
|
49 |
|
50 |
+
print("Video in progress...")
|
51 |
+
commands.append('python utils/process_task.py')
|
52 |
+
|
53 |
+
if upscale_check:
|
54 |
+
print("Generate Upscale...")
|
55 |
+
commands.append('python utils/upscale_task.py')
|
56 |
+
print("Upscale in progress...")
|
57 |
+
commands.append('python utils/process_task_upscale.py')
|
58 |
+
commands.append('python utils/delete_task.py')
|
59 |
+
commands.append('python utils/delete_task_upscale.py')
|
60 |
+
else:
|
61 |
+
commands.append('python utils/delete_task.py')
|
62 |
+
|
63 |
+
# Ejecutar todos los comandos
|
64 |
+
output = ""
|
65 |
+
for command in commands:
|
66 |
+
result = subprocess.run(command, shell=True, capture_output=True, text=True)
|
67 |
+
output += f"Exit:\n{result.stdout}\n"
|
68 |
+
print(result.stdout)
|
69 |
+
|
70 |
+
video_path = "video.mp4"
|
71 |
+
return output, video_path
|
72 |
+
|
73 |
+
else:
|
74 |
+
# Si la versión no es "1.0", ejecutamos un bloque similar para edición o ajuste
|
75 |
+
commands = []
|
76 |
+
|
77 |
+
# Los mismos comandos, pero ajustados o editados para la versión que no es "1.0"
|
78 |
+
print("Executing in 1.5 version...")
|
79 |
|
80 |
+
if add_end_frame:
|
81 |
+
# Comandos generales según el tipo de tarea
|
82 |
+
if upscale_check:
|
83 |
+
commands.append('python vidu_credit.py --credit 4')
|
84 |
+
else:
|
85 |
+
commands.append('python vidu_credit.py --credit 0')
|
86 |
+
|
87 |
+
print("Generating video 1.5: Text to Video...")
|
88 |
commands.append(
|
89 |
+
f'python create_text_to_video_15.py --prompt "{description}" --enhance {str(enhance_check).lower()} --style "{style}" --aspect_ratio "{aspect_ratio}" --resolution "512" --movement_amplitude "{movement}"'
|
90 |
)
|
91 |
+
print("Video in progress...")
|
92 |
+
commands.append('python utils/process_task.py')
|
93 |
+
|
94 |
+
if upscale_check:
|
95 |
+
print("Generate Upscale...")
|
96 |
+
commands.append('python utils/upscale_task.py')
|
97 |
+
print("Upscale in progress...")
|
98 |
+
commands.append('python utils/process_task_upscale.py')
|
99 |
+
commands.append('python utils/delete_task.py')
|
100 |
+
commands.append('python utils/delete_task_upscale.py')
|
101 |
+
else:
|
102 |
+
commands.append('python utils/delete_task.py')
|
103 |
+
else:
|
104 |
+
# Comandos generales según el tipo de tarea
|
105 |
+
if upscale_check:
|
106 |
+
commands.append('python vidu_credit.py --credit 4')
|
107 |
+
else:
|
108 |
+
commands.append('python vidu_credit.py --credit 0')
|
109 |
+
|
110 |
+
print("Generating video 1.5: Text to Video...")
|
111 |
+
commands.append(
|
112 |
+
f'python create_text_to_video_15.py --prompt "{description}" --enhance {str(enhance_check).lower()} --style "{style}" --aspect_ratio "{aspect_ratio}" --resolution "512" --movement_amplitude "{movement}"'
|
113 |
+
)
|
114 |
+
|
115 |
+
print("Video in progress...")
|
116 |
+
commands.append('python utils/process_task.py')
|
117 |
+
|
118 |
+
if upscale_check:
|
119 |
+
print("Generate Upscale...")
|
120 |
+
commands.append('python utils/upscale_task.py')
|
121 |
+
print("Upscale in progress...")
|
122 |
+
commands.append('python utils/process_task_upscale.py')
|
123 |
+
commands.append('python utils/delete_task.py')
|
124 |
+
commands.append('python utils/delete_task_upscale.py')
|
125 |
+
else:
|
126 |
+
commands.append('python utils/delete_task.py')
|
127 |
+
|
128 |
+
|
129 |
+
output = ""
|
130 |
+
for command in commands:
|
131 |
+
result = subprocess.run(command, shell=True, capture_output=True, text=True)
|
132 |
+
output += f"Exit:\n{result.stdout}\n"
|
133 |
+
print(result.stdout)
|
134 |
+
|
135 |
+
video_path = "video.mp4"
|
136 |
+
return output, video_path
|
137 |
+
|
138 |
+
except Exception as e:
|
139 |
+
return f"Excepción: {str(e)}", None
|
140 |
+
|
141 |
+
|
142 |
+
|
143 |
+
|
144 |
+
def run_commands_videotovideo(description, aspect_ratio, enhance_check, model, style, upscale_check, task_type, add_end_frame, version, movement, img=None, is_extend=False, is_recreate=False):
|
145 |
+
try:
|
146 |
+
# Verifica si la versión es "1.0"
|
147 |
+
if version == "1.0":
|
148 |
+
commands = []
|
149 |
+
|
150 |
+
if add_end_frame:
|
151 |
+
# Comandos generales según el tipo de tarea
|
152 |
+
if upscale_check:
|
153 |
+
commands.append('python vidu_credit.py --credit 4')
|
154 |
+
else:
|
155 |
+
commands.append('python vidu_credit.py --credit 0')
|
156 |
+
|
157 |
+
commands.append('python utils/video_fragment.py')
|
158 |
+
|
159 |
+
print("File Uploader...")
|
160 |
+
commands.append('python upload/file_uploader.py --file_info "file_info" --image "img_fragmento"')
|
161 |
+
commands.append('python upload/file_uploader.py --file_info "file_info2" --image "img_fragmento2"')
|
162 |
+
|
163 |
+
print("Generating video with headtailimg2video...")
|
164 |
commands.append(
|
165 |
+
f'python headtailimg2video.py --prompt "{description}" --enhance {str(enhance_check).lower()} --model "{model}"'
|
166 |
)
|
167 |
+
print("Video in progress...")
|
168 |
+
commands.append('python utils/process_task.py')
|
169 |
+
|
170 |
+
if upscale_check:
|
171 |
+
print("Generate Upscale...")
|
172 |
+
commands.append('python utils/upscale_task.py')
|
173 |
+
print("Upscale in progress...")
|
174 |
+
commands.append('python utils/process_task_upscale.py')
|
175 |
+
commands.append('python utils/delete_task.py')
|
176 |
+
commands.append('python utils/delete_task_upscale.py')
|
177 |
+
else:
|
178 |
+
commands.append('python utils/delete_task.py')
|
179 |
+
else:
|
180 |
+
# Comandos generales según el tipo de tarea
|
181 |
+
if upscale_check:
|
182 |
+
commands.append('python vidu_credit.py --credit 4')
|
183 |
+
else:
|
184 |
+
commands.append('python vidu_credit.py --credit 0')
|
185 |
+
|
186 |
+
commands.append('python utils/video_fragment.py')
|
187 |
+
|
188 |
+
print("File Uploader...")
|
189 |
+
commands.append('python upload/file_uploader.py --file_info "file_info" --image "img_fragmento"')
|
190 |
+
|
191 |
+
print("Generating video with Image to Video...")
|
192 |
commands.append(
|
193 |
+
f'python create_task.py --prompt "{description}" --enhance {str(enhance_check).lower()} --model "{model}"'
|
194 |
)
|
195 |
+
|
196 |
+
print("Video in progress...")
|
197 |
+
commands.append('python utils/process_task.py')
|
198 |
+
|
199 |
+
if upscale_check:
|
200 |
+
print("Generate Upscale...")
|
201 |
+
commands.append('python utils/upscale_task.py')
|
202 |
+
print("Upscale in progress...")
|
203 |
+
commands.append('python utils/process_task_upscale.py')
|
204 |
+
commands.append('python utils/delete_task.py')
|
205 |
+
commands.append('python utils/delete_task_upscale.py')
|
206 |
+
else:
|
207 |
+
commands.append('python utils/delete_task.py')
|
208 |
+
|
209 |
+
# Ejecutar todos los comandos
|
210 |
+
output = ""
|
211 |
+
for command in commands:
|
212 |
+
result = subprocess.run(command, shell=True, capture_output=True, text=True)
|
213 |
+
output += f"Exit:\n{result.stdout}\n"
|
214 |
+
print(result.stdout)
|
215 |
+
|
216 |
+
video_path = "video.mp4"
|
217 |
+
return output, video_path
|
218 |
+
|
219 |
+
else:
|
220 |
+
# Si la versión no es "1.0", ejecutamos un bloque similar para edición o ajuste
|
221 |
+
commands = []
|
222 |
+
|
223 |
+
# Los mismos comandos, pero ajustados o editados para la versión que no es "1.0"
|
224 |
+
print("Executing in 1.5 version...")
|
225 |
+
|
226 |
+
|
227 |
+
if add_end_frame:
|
228 |
+
# Comandos generales según el tipo de tarea
|
229 |
+
if upscale_check:
|
230 |
+
commands.append('python vidu_credit.py --credit 4')
|
231 |
+
else:
|
232 |
+
commands.append('python vidu_credit.py --credit 0')
|
233 |
+
|
234 |
+
commands.append('python utils/video_fragment.py')
|
235 |
+
|
236 |
+
print("File Uploader...")
|
237 |
+
commands.append('python upload/file_uploader.py --file_info "file_info" --image "img_fragmento"')
|
238 |
+
commands.append('python upload/file_uploader.py --file_info "file_info2" --image "img_fragmento2"')
|
239 |
+
|
240 |
+
print("Generating video with headtailimg2video...")
|
241 |
commands.append(
|
242 |
+
f'python create_image2_to_video_15.py --text "{description}" --enhance {str(enhance_check).lower()} --resolution "512" --movement_amplitude "{movement}"'
|
243 |
)
|
244 |
+
print("Video in progress...")
|
245 |
+
commands.append('python utils/process_task.py')
|
246 |
+
|
247 |
+
if upscale_check:
|
248 |
+
print("Generate Upscale...")
|
249 |
+
commands.append('python utils/upscale_task.py')
|
250 |
+
print("Upscale in progress...")
|
251 |
+
commands.append('python utils/process_task_upscale.py')
|
252 |
+
commands.append('python utils/delete_task.py')
|
253 |
+
commands.append('python utils/delete_task_upscale.py')
|
254 |
+
else:
|
255 |
+
commands.append('python utils/delete_task.py')
|
256 |
else:
|
257 |
+
# Comandos generales según el tipo de tarea
|
258 |
+
if upscale_check:
|
259 |
+
commands.append('python vidu_credit.py --credit 4')
|
260 |
+
else:
|
261 |
+
commands.append('python vidu_credit.py --credit 0')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
262 |
|
263 |
+
commands.append('python utils/video_fragment.py')
|
264 |
+
|
265 |
+
print("File Uploader...")
|
266 |
+
commands.append('python upload/file_uploader.py --file_info "file_info" --image "img_fragmento"')
|
267 |
+
|
268 |
+
print("Generating video 1.5 with Image to Video...")
|
269 |
+
commands.append(
|
270 |
+
f'python create_image_to_video_15.py --text "{description}" --enhance {str(enhance_check).lower()} --resolution "512" --movement_amplitude "{movement}"'
|
271 |
+
)
|
272 |
+
|
273 |
+
print("Video in progress...")
|
274 |
+
commands.append('python utils/process_task.py')
|
275 |
+
|
276 |
+
if upscale_check:
|
277 |
+
print("Generate Upscale...")
|
278 |
+
commands.append('python utils/upscale_task.py')
|
279 |
+
print("Upscale in progress...")
|
280 |
+
commands.append('python utils/process_task_upscale.py')
|
281 |
+
commands.append('python utils/delete_task.py')
|
282 |
+
commands.append('python utils/delete_task_upscale.py')
|
283 |
+
else:
|
284 |
+
commands.append('python utils/delete_task.py')
|
285 |
+
|
286 |
+
|
287 |
+
output = ""
|
288 |
+
for command in commands:
|
289 |
+
result = subprocess.run(command, shell=True, capture_output=True, text=True)
|
290 |
+
output += f"Exit:\n{result.stdout}\n"
|
291 |
+
print(result.stdout)
|
292 |
+
|
293 |
+
video_path = "video.mp4"
|
294 |
+
return output, video_path
|
295 |
|
|
|
|
|
296 |
except Exception as e:
|
297 |
return f"Excepción: {str(e)}", None
|
298 |
|
|
|
300 |
|
301 |
|
302 |
|
303 |
+
def run_commands_re_create(description, aspect_ratio, enhance_check, model, style, upscale_check, task_type, add_end_frame, version, movement, img=None, is_extend=False, is_recreate=False):
|
304 |
+
try:
|
305 |
+
# Verifica si la versión es "1.0"
|
306 |
+
if version == "1.0":
|
307 |
+
commands = []
|
308 |
+
|
309 |
+
if True:
|
310 |
+
# Comandos generales según el tipo de tarea
|
311 |
+
if upscale_check:
|
312 |
+
commands.append('python vidu_credit.py --credit 4')
|
313 |
+
else:
|
314 |
+
commands.append('python vidu_credit.py --credit 0')
|
315 |
+
|
316 |
+
print("File Uploader...")
|
317 |
+
commands.append('python upload/file_uploader.py --file_info "file_info" --image "img_fragmento"')
|
318 |
+
|
319 |
+
print("Generating video with Image to Video...")
|
320 |
+
commands.append(
|
321 |
+
f'python create_task.py --prompt "{description}" --enhance {str(enhance_check).lower()} --model "{model}"'
|
322 |
+
)
|
323 |
+
|
324 |
+
print("Video in progress...")
|
325 |
+
commands.append('python utils/process_task.py')
|
326 |
+
|
327 |
+
if upscale_check:
|
328 |
+
print("Generate Upscale...")
|
329 |
+
commands.append('python utils/upscale_task.py')
|
330 |
+
print("Upscale in progress...")
|
331 |
+
commands.append('python utils/process_task_upscale.py')
|
332 |
+
commands.append('python utils/delete_task.py')
|
333 |
+
commands.append('python utils/delete_task_upscale.py')
|
334 |
+
else:
|
335 |
+
commands.append('python utils/delete_task.py')
|
336 |
+
|
337 |
+
# Ejecutar todos los comandos
|
338 |
+
output = ""
|
339 |
+
for command in commands:
|
340 |
+
result = subprocess.run(command, shell=True, capture_output=True, text=True)
|
341 |
+
output += f"Exit:\n{result.stdout}\n"
|
342 |
+
print(result.stdout)
|
343 |
+
|
344 |
+
video_path = "video.mp4"
|
345 |
+
return output, video_path
|
346 |
+
|
347 |
+
else:
|
348 |
+
# Si la versión no es "1.0", ejecutamos un bloque similar para edición o ajuste
|
349 |
+
commands = []
|
350 |
+
|
351 |
+
# Los mismos comandos, pero ajustados o editados para la versión que no es "1.0"
|
352 |
+
print("Executing in 1.5 version...")
|
353 |
+
|
354 |
+
if True:
|
355 |
+
# Comandos generales según el tipo de tarea
|
356 |
+
if upscale_check:
|
357 |
+
commands.append('python vidu_credit.py --credit 4')
|
358 |
+
else:
|
359 |
+
commands.append('python vidu_credit.py --credit 0')
|
360 |
+
|
361 |
+
print("File Uploader...")
|
362 |
+
commands.append('python upload/file_uploader.py --file_info "file_info" --image "img_fragmento"')
|
363 |
|
364 |
+
print("Generating video 1.5 with Image to Video...")
|
365 |
+
commands.append(
|
366 |
+
f'python create_image_to_video_15.py --text "{description}" --enhance {str(enhance_check).lower()} --resolution "512" --movement_amplitude "{movement}"'
|
367 |
+
)
|
368 |
|
369 |
+
print("Video in progress...")
|
370 |
+
commands.append('python utils/process_task.py')
|
371 |
+
|
372 |
+
if upscale_check:
|
373 |
+
print("Generate Upscale...")
|
374 |
+
commands.append('python utils/upscale_task.py')
|
375 |
+
print("Upscale in progress...")
|
376 |
+
commands.append('python utils/process_task_upscale.py')
|
377 |
+
commands.append('python utils/delete_task.py')
|
378 |
+
commands.append('python utils/delete_task_upscale.py')
|
379 |
+
else:
|
380 |
+
commands.append('python utils/delete_task.py')
|
381 |
+
|
382 |
+
|
383 |
+
output = ""
|
384 |
+
for command in commands:
|
385 |
+
result = subprocess.run(command, shell=True, capture_output=True, text=True)
|
386 |
+
output += f"Exit:\n{result.stdout}\n"
|
387 |
+
print(result.stdout)
|
388 |
|
389 |
+
video_path = "video.mp4"
|
390 |
+
return output, video_path
|
391 |
+
|
392 |
+
except Exception as e:
|
393 |
+
return f"Excepción: {str(e)}", None
|
394 |
+
|
395 |
+
def run_commands_extend(description, aspect_ratio, enhance_check, model, style, upscale_check, task_type, add_end_frame, version, movement, img=None, is_extend=False, is_recreate=False):
|
396 |
try:
|
397 |
+
# Verifica si la versión es "1.0"
|
398 |
+
if version == "1.0":
|
399 |
+
commands = []
|
400 |
|
401 |
+
if True:
|
402 |
+
# Comandos generales según el tipo de tarea
|
403 |
+
if upscale_check:
|
404 |
+
commands.append('python vidu_credit.py --credit 4')
|
405 |
+
else:
|
406 |
+
commands.append('python vidu_credit.py --credit 0')
|
407 |
|
408 |
+
print("Last frame...")
|
409 |
+
commands.append('python utils/fragment.py')
|
|
|
410 |
|
411 |
+
print("File Uploader...")
|
412 |
+
commands.append('python upload/file_uploader.py --file_info "file_info" --image "img_fragmento"')
|
413 |
+
|
414 |
+
print("Generating video with Image to Video...")
|
415 |
+
commands.append(
|
416 |
+
f'python create_task.py --prompt "{description}" --enhance {str(enhance_check).lower()} --model "{model}"'
|
417 |
+
)
|
418 |
+
|
419 |
+
print("Video in progress...")
|
420 |
+
commands.append('python utils/process_task.py')
|
421 |
+
|
422 |
+
if upscale_check:
|
423 |
+
print("Generate Upscale...")
|
424 |
+
commands.append('python utils/upscale_task.py')
|
425 |
+
print("Upscale in progress...")
|
426 |
+
commands.append('python utils/process_task_upscale.py')
|
427 |
+
commands.append('python utils/delete_task.py')
|
428 |
+
commands.append('python utils/delete_task_upscale.py')
|
429 |
+
else:
|
430 |
+
commands.append('python utils/delete_task.py')
|
431 |
+
|
432 |
+
# Ejecutar todos los comandos
|
433 |
+
output = ""
|
434 |
+
for command in commands:
|
435 |
+
result = subprocess.run(command, shell=True, capture_output=True, text=True)
|
436 |
+
output += f"Exit:\n{result.stdout}\n"
|
437 |
+
print(result.stdout)
|
438 |
+
|
439 |
+
video_path = "video.mp4"
|
440 |
+
return output, video_path
|
441 |
+
|
442 |
+
else:
|
443 |
+
# Si la versión no es "1.0", ejecutamos un bloque similar para edición o ajuste
|
444 |
+
commands = []
|
445 |
+
|
446 |
+
# Los mismos comandos, pero ajustados o editados para la versión que no es "1.0"
|
447 |
+
print("Executing in 1.5 version...")
|
448 |
+
|
449 |
+
if True:
|
450 |
+
# Comandos generales seg��n el tipo de tarea
|
451 |
+
if upscale_check:
|
452 |
+
commands.append('python vidu_credit.py --credit 4')
|
453 |
+
else:
|
454 |
+
commands.append('python vidu_credit.py --credit 0')
|
455 |
+
|
456 |
+
print("Last frame...")
|
457 |
+
commands.append('python utils/fragment.py')
|
458 |
+
|
459 |
+
print("File Uploader...")
|
460 |
+
commands.append('python upload/file_uploader.py --file_info "file_info" --image "img_fragmento"')
|
461 |
+
|
462 |
+
print("Generating video 1.5 with Image to Video...")
|
463 |
commands.append(
|
464 |
+
f'python create_image_to_video_15.py --text "{description}" --enhance {str(enhance_check).lower()} --resolution "512" --movement_amplitude "{movement}"'
|
465 |
)
|
466 |
+
|
467 |
+
print("Video in progress...")
|
468 |
+
commands.append('python utils/process_task.py')
|
469 |
+
|
470 |
+
if upscale_check:
|
471 |
+
print("Generate Upscale...")
|
472 |
+
commands.append('python utils/upscale_task.py')
|
473 |
+
print("Upscale in progress...")
|
474 |
+
commands.append('python utils/process_task_upscale.py')
|
475 |
+
commands.append('python utils/delete_task.py')
|
476 |
+
commands.append('python utils/delete_task_upscale.py')
|
477 |
+
else:
|
478 |
+
commands.append('python utils/delete_task.py')
|
479 |
|
480 |
+
|
481 |
+
output = ""
|
482 |
+
for command in commands:
|
483 |
+
result = subprocess.run(command, shell=True, capture_output=True, text=True)
|
484 |
+
output += f"Exit:\n{result.stdout}\n"
|
485 |
+
print(result.stdout)
|
486 |
+
|
487 |
+
video_path = "video.mp4"
|
488 |
+
return output, video_path
|
489 |
+
|
490 |
+
except Exception as e:
|
491 |
+
return f"Excepción: {str(e)}", None
|
492 |
+
|
493 |
+
|
494 |
+
def run_commands_reference(description, aspect_ratio, enhance_check, model, style, upscale_check, task_type, add_end_frame, version, movement, aspect_ratios, img=None, is_extend=False, is_recreate=False):
|
495 |
+
print(aspect_ratios)
|
496 |
+
print(movement)
|
497 |
+
try:
|
498 |
+
# Verifica si la versión es "1.0"
|
499 |
+
if version == "1.0":
|
500 |
+
commands = []
|
501 |
+
|
502 |
+
if add_end_frame:
|
503 |
+
# Comandos generales según el tipo de tarea
|
504 |
+
if upscale_check:
|
505 |
+
commands.append('python vidu_credit.py --credit 4')
|
506 |
+
else:
|
507 |
+
commands.append('python vidu_credit.py --credit 0')
|
508 |
+
|
509 |
+
print("File Uploader...")
|
510 |
+
commands.append('python upload/file_uploader.py --file_info "file_info" --image "img_fragmento"')
|
511 |
+
|
512 |
+
if task_type == "headtailimg2video":
|
513 |
+
print("Generating video with Image to Video...")
|
514 |
+
"""commands.append(
|
515 |
+
f'python create_task.py --prompt "{description}" --enhance {str(enhance_check).lower()} --model "{model}"'
|
516 |
+
)"""
|
517 |
+
commands.append(
|
518 |
+
f'python create_video_reference.py --prompt "{description}" --enhance {str(enhance_check).lower()} --model "{model}"'
|
519 |
+
)
|
520 |
+
|
521 |
+
print("Video in progress...")
|
522 |
+
commands.append('python utils/process_task.py')
|
523 |
+
|
524 |
+
if upscale_check:
|
525 |
+
print("Generate Upscale...")
|
526 |
+
commands.append('python utils/upscale_task.py')
|
527 |
+
print("Upscale in progress...")
|
528 |
+
commands.append('python utils/process_task_upscale.py')
|
529 |
+
commands.append('python utils/delete_task.py')
|
530 |
+
commands.append('python utils/delete_task_upscale.py')
|
531 |
+
else:
|
532 |
+
commands.append('python utils/delete_task.py')
|
533 |
else:
|
534 |
+
# Comandos generales según el tipo de tarea
|
535 |
+
if upscale_check:
|
536 |
+
commands.append('python vidu_credit.py --credit 4')
|
537 |
+
else:
|
538 |
+
commands.append('python vidu_credit.py --credit 0')
|
539 |
+
|
540 |
+
print("File Uploader...")
|
541 |
+
commands.append('python upload/file_uploader.py --file_info "file_info" --image "img_fragmento"')
|
542 |
+
|
543 |
+
if task_type == "headtailimg2video":
|
544 |
+
print("Generating video with Image to Video...")
|
545 |
+
"""commands.append(
|
546 |
+
f'python create_task.py --prompt "{description}" --enhance {str(enhance_check).lower()} --model "{model}"'
|
547 |
+
)"""
|
548 |
+
commands.append(
|
549 |
+
f'python create_video_reference.py --prompt "{description}" --enhance {str(enhance_check).lower()} --model "{model}"'
|
550 |
+
)
|
551 |
+
|
552 |
+
print("Video in progress...")
|
553 |
+
commands.append('python utils/process_task.py')
|
554 |
+
|
555 |
+
if upscale_check:
|
556 |
+
print("Generate Upscale...")
|
557 |
+
commands.append('python utils/upscale_task.py')
|
558 |
+
print("Upscale in progress...")
|
559 |
+
commands.append('python utils/process_task_upscale.py')
|
560 |
+
commands.append('python utils/delete_task.py')
|
561 |
+
commands.append('python utils/delete_task_upscale.py')
|
562 |
+
else:
|
563 |
+
commands.append('python utils/delete_task.py')
|
564 |
+
|
565 |
+
# Ejecutar todos los comandos
|
566 |
+
output = ""
|
567 |
+
for command in commands:
|
568 |
+
result = subprocess.run(command, shell=True, capture_output=True, text=True)
|
569 |
+
output += f"Exit:\n{result.stdout}\n"
|
570 |
+
print(result.stdout)
|
571 |
+
|
572 |
+
video_path = "video.mp4"
|
573 |
+
return output, video_path
|
574 |
+
|
575 |
else:
|
576 |
+
# Si la versión no es "1.0", ejecutamos un bloque similar para edición o ajuste
|
577 |
+
commands = []
|
578 |
+
|
579 |
+
# Los mismos comandos, pero ajustados o editados para la versión que no es "1.0"
|
580 |
+
print("Executing in 1.5 version...")
|
581 |
+
|
582 |
+
|
583 |
+
if add_end_frame:
|
584 |
+
# Comandos generales según el tipo de tarea
|
585 |
+
if upscale_check:
|
586 |
+
commands.append('python vidu_credit.py --credit 4')
|
587 |
+
else:
|
588 |
+
commands.append('python vidu_credit.py --credit 0')
|
589 |
+
|
590 |
+
print("File Uploader...")
|
591 |
+
commands.append('python upload/file_uploader.py --file_info "file_info" --image "img_fragmento"')
|
592 |
+
commands.append('python upload/file_uploader.py --file_info "file_info2" --image "img_fragmento2"')
|
593 |
+
|
594 |
+
if task_type == "headtailimg2video":
|
595 |
+
print("Generating video with headtailimg2video...")
|
596 |
+
commands.append(
|
597 |
+
f'python create_video_reference2_15.py --text "{description}" --resolution "512" --movement_amplitude "{movement}" --enhance {str(enhance_check).lower()} --aspect_ratio "{aspect_ratios}"'
|
598 |
+
)
|
599 |
+
|
600 |
+
|
601 |
+
print("Video in progress...")
|
602 |
+
commands.append('python utils/process_task.py')
|
603 |
+
|
604 |
+
if upscale_check:
|
605 |
+
print("Generate Upscale...")
|
606 |
+
commands.append('python utils/upscale_task.py')
|
607 |
+
print("Upscale in progress...")
|
608 |
+
commands.append('python utils/process_task_upscale.py')
|
609 |
+
commands.append('python utils/delete_task.py')
|
610 |
+
commands.append('python utils/delete_task_upscale.py')
|
611 |
+
else:
|
612 |
+
commands.append('python utils/delete_task.py')
|
613 |
else:
|
614 |
+
# Comandos generales según el tipo de tarea
|
615 |
+
if upscale_check:
|
616 |
+
commands.append('python vidu_credit.py --credit 4')
|
617 |
+
else:
|
618 |
+
commands.append('python vidu_credit.py --credit 0')
|
619 |
+
|
620 |
+
print("File Uploader...")
|
621 |
+
commands.append('python upload/file_uploader.py --file_info "file_info" --image "img_fragmento"')
|
622 |
+
|
623 |
+
if task_type == "headtailimg2video":
|
624 |
+
print("Generating video 1.5 with Image to Video...")
|
625 |
+
commands.append(
|
626 |
+
f'python create_video_reference_15.py --text "{description}" --enhance {str(enhance_check).lower()} --resolution "512" --movement_amplitude "{movement}" --aspect_ratio "{aspect_ratios}"'
|
627 |
+
)
|
628 |
+
|
629 |
+
|
630 |
+
print("Video in progress...")
|
631 |
+
commands.append('python utils/process_task.py')
|
632 |
+
|
633 |
+
if upscale_check:
|
634 |
+
print("Generate Upscale...")
|
635 |
+
commands.append('python utils/upscale_task.py')
|
636 |
+
print("Upscale in progress...")
|
637 |
+
commands.append('python utils/process_task_upscale.py')
|
638 |
+
commands.append('python utils/delete_task.py')
|
639 |
+
commands.append('python utils/delete_task_upscale.py')
|
640 |
+
else:
|
641 |
+
commands.append('python utils/delete_task.py')
|
642 |
+
|
643 |
|
644 |
+
output = ""
|
645 |
+
for command in commands:
|
646 |
+
result = subprocess.run(command, shell=True, capture_output=True, text=True)
|
647 |
+
output += f"Exit:\n{result.stdout}\n"
|
648 |
+
print(result.stdout)
|
649 |
+
|
650 |
+
video_path = "video.mp4"
|
651 |
+
return output, video_path
|
652 |
+
|
653 |
+
except Exception as e:
|
654 |
+
return f"Excepción: {str(e)}", None
|
655 |
+
|
656 |
+
|
657 |
+
def run_commands_dual2(description, aspect_ratio, enhance_check, model, style, upscale_check, task_type, add_end_frame, version, movement, img=None, is_extend=False, is_recreate=False):
|
658 |
+
try:
|
659 |
+
# Verifica si la versión es "1.0"
|
660 |
+
if version == "1.0":
|
661 |
+
commands = []
|
662 |
+
|
663 |
+
if add_end_frame:
|
664 |
+
# Comandos generales según el tipo de tarea
|
665 |
+
if upscale_check:
|
666 |
+
commands.append('python vidu_credit.py --credit 4')
|
667 |
+
else:
|
668 |
+
commands.append('python vidu_credit.py --credit 0')
|
669 |
+
|
670 |
+
print("File Uploader...")
|
671 |
+
commands.append('python upload/file_uploader.py --file_info "file_info" --image "img_fragmento"')
|
672 |
+
commands.append('python upload/file_uploader.py --file_info "file_info2" --image "img_fragmento2"')
|
673 |
+
|
674 |
+
if task_type == "headtailimg2video":
|
675 |
+
print("Generating video with headtailimg2video...")
|
676 |
+
commands.append(
|
677 |
+
f'python headtailimg2video.py --prompt "{description}" --enhance {str(enhance_check).lower()} --model "{model}"'
|
678 |
+
)
|
679 |
+
print("Video in progress...")
|
680 |
+
commands.append('python utils/process_task.py')
|
681 |
+
|
682 |
+
if upscale_check:
|
683 |
+
print("Generate Upscale...")
|
684 |
+
commands.append('python utils/upscale_task.py')
|
685 |
+
print("Upscale in progress...")
|
686 |
+
commands.append('python utils/process_task_upscale.py')
|
687 |
+
commands.append('python utils/delete_task.py')
|
688 |
+
commands.append('python utils/delete_task_upscale.py')
|
689 |
+
else:
|
690 |
+
commands.append('python utils/delete_task.py')
|
691 |
+
else:
|
692 |
+
# Comandos generales según el tipo de tarea
|
693 |
+
if upscale_check:
|
694 |
+
commands.append('python vidu_credit.py --credit 4')
|
695 |
+
else:
|
696 |
+
commands.append('python vidu_credit.py --credit 0')
|
697 |
+
|
698 |
+
print("File Uploader...")
|
699 |
+
commands.append('python upload/file_uploader.py --file_info "file_info" --image "img_fragmento"')
|
700 |
|
|
|
701 |
print("Generating video with Image to Video...")
|
702 |
commands.append(
|
703 |
+
f'python create_task.py --prompt "{description}" --enhance {str(enhance_check).lower()} --model "{model}"'
|
704 |
)
|
705 |
+
|
706 |
+
print("Video in progress...")
|
707 |
+
commands.append('python utils/process_task.py')
|
708 |
+
|
709 |
+
if upscale_check:
|
710 |
+
print("Generate Upscale...")
|
711 |
+
commands.append('python utils/upscale_task.py')
|
712 |
+
print("Upscale in progress...")
|
713 |
+
commands.append('python utils/process_task_upscale.py')
|
714 |
+
commands.append('python utils/delete_task.py')
|
715 |
+
commands.append('python utils/delete_task_upscale.py')
|
716 |
+
else:
|
717 |
+
commands.append('python utils/delete_task.py')
|
718 |
+
|
719 |
+
# Ejecutar todos los comandos
|
720 |
+
output = ""
|
721 |
+
for command in commands:
|
722 |
+
result = subprocess.run(command, shell=True, capture_output=True, text=True)
|
723 |
+
output += f"Exit:\n{result.stdout}\n"
|
724 |
+
print(result.stdout)
|
725 |
+
|
726 |
+
video_path = "video.mp4"
|
727 |
+
return output, video_path
|
728 |
+
|
729 |
+
else:
|
730 |
+
# Si la versión no es "1.0", ejecutamos un bloque similar para edición o ajuste
|
731 |
+
commands = []
|
732 |
|
733 |
+
# Los mismos comandos, pero ajustados o editados para la versión que no es "1.0"
|
734 |
+
print("Executing in 1.5 version...")
|
735 |
+
|
736 |
+
|
737 |
+
if add_end_frame:
|
738 |
+
# Comandos generales según el tipo de tarea
|
739 |
+
if upscale_check:
|
740 |
+
commands.append('python vidu_credit.py --credit 4')
|
741 |
+
else:
|
742 |
+
commands.append('python vidu_credit.py --credit 0')
|
743 |
+
|
744 |
+
print("File Uploader...")
|
745 |
+
commands.append('python upload/file_uploader.py --file_info "file_info" --image "img_fragmento"')
|
746 |
+
commands.append('python upload/file_uploader.py --file_info "file_info2" --image "img_fragmento2"')
|
747 |
+
|
748 |
+
print("Generating video with headtailimg2video...")
|
749 |
+
commands.append(
|
750 |
+
f'python create_image2_to_video_15.py --text "{description}" --enhance {str(enhance_check).lower()} --resolution "512" --movement_amplitude "{movement}"'
|
751 |
+
)
|
752 |
+
print("Video in progress...")
|
753 |
+
commands.append('python utils/process_task.py')
|
754 |
+
|
755 |
+
if upscale_check:
|
756 |
+
print("Generate Upscale...")
|
757 |
+
commands.append('python utils/upscale_task.py')
|
758 |
+
print("Upscale in progress...")
|
759 |
+
commands.append('python utils/process_task_upscale.py')
|
760 |
+
commands.append('python utils/delete_task.py')
|
761 |
+
commands.append('python utils/delete_task_upscale.py')
|
762 |
+
else:
|
763 |
+
commands.append('python utils/delete_task.py')
|
764 |
else:
|
765 |
+
# Comandos generales según el tipo de tarea
|
766 |
+
if upscale_check:
|
767 |
+
commands.append('python vidu_credit.py --credit 4')
|
768 |
+
else:
|
769 |
+
commands.append('python vidu_credit.py --credit 0')
|
770 |
|
771 |
+
print("File Uploader...")
|
772 |
+
commands.append('python upload/file_uploader.py --file_info "file_info" --image "img_fragmento"')
|
773 |
|
774 |
+
print("Generating video 1.5 with Image to Video...")
|
775 |
+
commands.append(
|
776 |
+
f'python create_image_to_video_15.py --text "{description}" --enhance {str(enhance_check).lower()} --resolution "512" --movement_amplitude "{movement}"'
|
777 |
+
)
|
778 |
+
|
779 |
+
print("Video in progress...")
|
780 |
+
commands.append('python utils/process_task.py')
|
781 |
+
|
782 |
+
if upscale_check:
|
783 |
+
print("Generate Upscale...")
|
784 |
+
commands.append('python utils/upscale_task.py')
|
785 |
+
print("Upscale in progress...")
|
786 |
+
commands.append('python utils/process_task_upscale.py')
|
787 |
+
commands.append('python utils/delete_task.py')
|
788 |
+
commands.append('python utils/delete_task_upscale.py')
|
789 |
+
else:
|
790 |
+
commands.append('python utils/delete_task.py')
|
791 |
+
|
792 |
+
|
793 |
+
output = ""
|
794 |
+
for command in commands:
|
795 |
+
result = subprocess.run(command, shell=True, capture_output=True, text=True)
|
796 |
+
output += f"Exit:\n{result.stdout}\n"
|
797 |
+
print(result.stdout)
|
798 |
+
|
799 |
+
video_path = "video.mp4"
|
800 |
+
return output, video_path
|
801 |
|
|
|
|
|
802 |
except Exception as e:
|
803 |
return f"Excepción: {str(e)}", None
|
804 |
|
805 |
+
|
806 |
+
|
807 |
# Función para procesar y guardar la imagen automáticamente en formato JPG
|
808 |
def process_and_save_image(image, coordinates_file_path="/tmp/coordinates.txt"):
|
809 |
jpg_path = "/tmp/img_fragmento.jpg"
|
|
|
906 |
try:
|
907 |
print("Rendering video...")
|
908 |
commands = [
|
909 |
+
"python utils/fragment.py",
|
910 |
+
"python utils/union.py"
|
911 |
]
|
912 |
output = ""
|
913 |
for command in commands:
|
914 |
result = subprocess.run(command, shell=True, capture_output=True, text=True)
|
915 |
output += f"Exit:\n{result.stdout}\n"
|
916 |
print(result.stdout)
|
917 |
+
video_path = "video.mp4"
|
918 |
return output, video_path
|
919 |
except Exception as e:
|
920 |
return f"Excepción al guardar: {str(e)}", None
|
|
|
922 |
# Función para mostrar o ocultar el segundo cuadro de imagen
|
923 |
def activar_end_frame(activar):
|
924 |
return gr.update(visible=activar)
|
925 |
+
|
926 |
+
def toggle_dropdowns(version):
|
927 |
+
# Si la versión es "1.0", muestra el dropdown del modelo
|
928 |
+
model_visibility = gr.update(visible=True) if version == "1.0" else gr.update(visible=False)
|
929 |
+
# Si la versión es "1.0" o "1.5", muestra el dropdown de "Movement Amplitude"
|
930 |
+
movement_amplitude_visibility = gr.update(visible=True) if version == "1.5" else gr.update(visible=False)
|
931 |
+
return model_visibility, movement_amplitude_visibility
|
932 |
+
|
933 |
+
def toggle_dropdowns2(version):
|
934 |
+
# Si la versión es "1.0", muestra el dropdown del modelo
|
935 |
+
model_visibility = gr.update(visible=True) if version == "1.0" else gr.update(visible=False)
|
936 |
+
|
937 |
+
add_end_frame = gr.update(visible=True) if version == "1.5" else gr.update(visible=False)
|
938 |
+
|
939 |
+
aspect_ratio_visibility = gr.update(visible=True) if version == "1.5" else gr.update(visible=False)
|
940 |
+
# Si la versión es "1.0" o "1.5", muestra el dropdown de "Movement Amplitude"
|
941 |
+
movement_amplitude_visibility = gr.update(visible=True) if version == "1.5" else gr.update(visible=False)
|
942 |
+
return model_visibility, movement_amplitude_visibility, add_end_frame, aspect_ratio_visibility
|
943 |
+
|
944 |
# Definir la interfaz
|
945 |
with gr.Blocks() as demo:
|
946 |
# Agregar un título en grande al inicio de la interfaz
|
|
|
950 |
with gr.Tab("Image to Video"):
|
951 |
with gr.Row():
|
952 |
with gr.Column():
|
953 |
+
version_dropdown3 = gr.Dropdown(
|
954 |
+
choices=["1.0", "1.5"],
|
955 |
+
label="Versión",
|
956 |
+
value="1.0",
|
957 |
+
elem_id="version_dropdown3"
|
958 |
+
)
|
959 |
add_end_frame = gr.Checkbox(label="Add End Frame", value=False)
|
960 |
|
961 |
# Fila para mostrar ambas imágenes cuando se activa
|
|
|
971 |
description_input = gr.Textbox(label="Prompt",
|
972 |
placeholder="Aquí va una caja de texto editable para el prompt",
|
973 |
elem_id="description_input")
|
974 |
+
|
975 |
enhance_checkbox = gr.Checkbox(label="Enhance prompt", value=False, elem_id="enhance_checkbox")
|
976 |
+
|
977 |
+
movement_amplitude_dropdown = gr.Dropdown(
|
978 |
+
choices=["auto", "small", "medium", "large"],
|
979 |
+
label="Movement Amplitude",
|
980 |
+
value="auto",
|
981 |
+
elem_id="movement_amplitude_dropdown",
|
982 |
+
visible=False
|
983 |
+
)
|
984 |
+
|
985 |
model_dropdown = gr.Dropdown(
|
986 |
choices=["vidu-1", "vidu-high-performance"],
|
987 |
label="Model",
|
988 |
value="vidu-1",
|
989 |
+
elem_id="model_dropdown",
|
990 |
+
visible=True
|
991 |
)
|
992 |
upscale_checkbox = gr.Checkbox(label="Upscale", value=False, elem_id="upscale_checkbox")
|
993 |
create_button = gr.Button("Create", elem_id="create_button")
|
|
|
1018 |
|
1019 |
# Botón "Create" y su salida
|
1020 |
create_button.click(
|
1021 |
+
fn=lambda desc, enhance, model, upscale, img, add_end, version, movement: run_commands_dual2(desc, "16:9", enhance, model, "general", upscale, task_type="headtailimg2video", img=img, add_end_frame=add_end, version=version, movement=movement),
|
1022 |
+
inputs=[description_input, enhance_checkbox, model_dropdown, upscale_checkbox, img1, add_end_frame, version_dropdown3, movement_amplitude_dropdown],
|
1023 |
+
outputs=[output_textbox, video_output]
|
1024 |
+
)
|
1025 |
|
1026 |
# Botón "Extend" y su salida
|
1027 |
extend_button.click(
|
1028 |
+
fn=lambda desc, enhance, model, upscale, img, add_end, version, movement: run_commands_extend(desc, "16:9", enhance, model, "general", upscale, task_type="headtailimg2video", img=img, add_end_frame=add_end, version=version, movement=movement),
|
1029 |
+
inputs=[description_input, enhance_checkbox, model_dropdown, upscale_checkbox, img1, add_end_frame, version_dropdown3, movement_amplitude_dropdown],
|
1030 |
outputs=[output_textbox, video_output]
|
1031 |
)
|
1032 |
|
1033 |
# Botón "Re-create" y su salida
|
1034 |
recreate_button.click(
|
1035 |
+
fn=lambda desc, enhance, model, upscale, img, add_end, version, movement: run_commands_re_create(desc, "16:9", enhance, model, "general", upscale, task_type="headtailimg2video", img=img, add_end_frame=add_end, version=version, movement=movement),
|
1036 |
+
inputs=[description_input, enhance_checkbox, model_dropdown, upscale_checkbox, img1, add_end_frame, version_dropdown3, movement_amplitude_dropdown],
|
1037 |
outputs=[output_textbox, video_output]
|
1038 |
)
|
1039 |
|
|
|
1044 |
outputs=[output_textbox, video_output]
|
1045 |
)
|
1046 |
|
1047 |
+
version_dropdown3.change(
|
1048 |
+
toggle_dropdowns,
|
1049 |
+
inputs=version_dropdown3,
|
1050 |
+
outputs=[model_dropdown, movement_amplitude_dropdown]
|
1051 |
+
)
|
1052 |
+
|
1053 |
# Segunda pestaña: Reference to Video
|
1054 |
with gr.Tab("Reference to Video"):
|
1055 |
with gr.Row():
|
1056 |
with gr.Column():
|
1057 |
+
version_dropdown3 = gr.Dropdown(
|
1058 |
+
choices=["1.0", "1.5"],
|
1059 |
+
label="Versión",
|
1060 |
+
value="1.0",
|
1061 |
+
elem_id="version_dropdown3"
|
1062 |
+
)
|
1063 |
+
add_end_frame = gr.Checkbox(label="Add End Frame", value=False, visible=False)
|
1064 |
+
|
1065 |
+
# Fila para mostrar ambas imágenes cuando se activa
|
1066 |
+
with gr.Row():
|
1067 |
+
# Imagen de inicio (carga de archivo)
|
1068 |
+
img1 = gr.Image(type="pil", label="Drag image here or select image", interactive=True,
|
1069 |
+
elem_id="img1", width=200, height=200) # Ajustar tamaño de la imagen
|
1070 |
+
|
1071 |
+
# Imagen de fin (se oculta inicialmente)
|
1072 |
+
img2 = gr.Image(type="pil", label="Upload the last frame image", interactive=True,
|
1073 |
+
elem_id="img2", visible=False, width=200, height=200) # Ajustar tamaño de la imagen
|
1074 |
+
|
1075 |
+
|
1076 |
+
"""image_input2 = gr.Image(type="pil", label="Drag image here or select image", interactive=True,
|
1077 |
+
elem_id="image_input2")"""
|
1078 |
+
|
1079 |
description_input2 = gr.Textbox(label="Prompt",
|
1080 |
placeholder="Enter text to begin creating a video that aligns with the subject of the image",
|
1081 |
elem_id="description_input2")
|
1082 |
+
|
1083 |
enhance_checkbox2 = gr.Checkbox(label="Enhance prompt", value=False, elem_id="enhance_checkbox2")
|
1084 |
+
|
1085 |
+
movement_amplitude_dropdown = gr.Dropdown(
|
1086 |
+
choices=["auto", "small", "medium", "large"],
|
1087 |
+
label="Movement Amplitude",
|
1088 |
+
value="auto",
|
1089 |
+
elem_id="movement_amplitude_dropdown",
|
1090 |
+
visible=False
|
1091 |
+
)
|
1092 |
+
|
1093 |
model_dropdown2 = gr.Dropdown(
|
1094 |
choices=["vidu-1", "vidu-high-performance"],
|
1095 |
label="Model",
|
1096 |
value="vidu-1",
|
1097 |
+
elem_id="model_dropdown2",
|
1098 |
+
visible=True
|
1099 |
+
)
|
1100 |
+
|
1101 |
+
aspect_ratio_dropdown = gr.Dropdown(
|
1102 |
+
choices=["16:9", "9:16", "4:3", "1:1"],
|
1103 |
+
label="Aspect Ratio",
|
1104 |
+
value="16:9",
|
1105 |
+
elem_id="aspect_ratio_dropdown",
|
1106 |
+
visible=False
|
1107 |
)
|
1108 |
+
|
1109 |
upscale_checkbox2 = gr.Checkbox(label="Upscale", value=False, elem_id="upscale_checkbox2")
|
1110 |
create_button2 = gr.Button("Create", elem_id="create_button2")
|
1111 |
extend_button2 = gr.Button("Extend", elem_id="extend_button2")
|
|
|
1116 |
video_output2 = gr.Video(label="Video Output Reference to Video", height=400, elem_id="video_output_reference_to_video")
|
1117 |
output_textbox2 = gr.Textbox(label="Output", interactive=False, elem_id="output_textbox2") # Cambia el nombre del textbox
|
1118 |
|
1119 |
+
# Lógica para mostrar el segundo cuadro de imagen al activar el checkbox
|
1120 |
+
add_end_frame.change(activar_end_frame, add_end_frame, img2)
|
1121 |
+
|
1122 |
+
img1.change(
|
1123 |
+
fn=process_and_save_image1,
|
1124 |
+
inputs=img1,
|
1125 |
outputs=[]
|
1126 |
)
|
1127 |
|
1128 |
+
img2.change(
|
1129 |
+
fn=process_and_save_image2,
|
1130 |
+
inputs=img2,
|
1131 |
+
outputs=[]
|
1132 |
+
)
|
1133 |
+
|
1134 |
+
|
1135 |
create_button2.click(
|
1136 |
+
fn=lambda desc, enhance, model, upscale, img, add_end, version, movement, aspect_ratios: run_commands_reference(desc, "16:9", enhance, model, "general", upscale, task_type="headtailimg2video", img=img, add_end_frame=add_end, version=version, movement=movement, aspect_ratios=aspect_ratios),
|
1137 |
+
inputs=[description_input2, enhance_checkbox2, model_dropdown2, upscale_checkbox2, img1, add_end_frame, version_dropdown3, movement_amplitude_dropdown, aspect_ratio_dropdown],
|
1138 |
outputs=[output_textbox2, video_output2]
|
1139 |
)
|
1140 |
|
1141 |
+
|
1142 |
# Botón "Extend" y su salida
|
1143 |
extend_button2.click(
|
1144 |
+
fn=lambda desc, enhance, model, upscale, img, add_end, version, movement: run_commands_extend(desc, "16:9", enhance, model, "general", upscale, task_type="headtailimg2video", img=img, add_end_frame=add_end, version=version, movement=movement),
|
1145 |
+
inputs=[description_input2, enhance_checkbox2, model_dropdown2, upscale_checkbox2, img1, add_end_frame, version_dropdown3, movement_amplitude_dropdown],
|
1146 |
outputs=[output_textbox2, video_output2]
|
1147 |
)
|
1148 |
|
1149 |
# Botón "Re-create" y su salida
|
1150 |
recreate_button2.click(
|
1151 |
+
fn=lambda desc, enhance, model, upscale, img, add_end, version, movement: run_commands_re_create(desc, "16:9", enhance, model, "general", upscale, task_type="headtailimg2video", img=img, add_end_frame=add_end, version=version, movement=movement),
|
1152 |
+
inputs=[description_input2, enhance_checkbox2, model_dropdown2, upscale_checkbox2, img1, add_end_frame, version_dropdown3, movement_amplitude_dropdown],
|
1153 |
outputs=[output_textbox2, video_output2]
|
1154 |
)
|
1155 |
|
|
|
1160 |
outputs=[output_textbox2, video_output2]
|
1161 |
)
|
1162 |
|
1163 |
+
version_dropdown3.change(
|
1164 |
+
toggle_dropdowns2,
|
1165 |
+
inputs=version_dropdown3,
|
1166 |
+
outputs=[model_dropdown2, movement_amplitude_dropdown, add_end_frame, aspect_ratio_dropdown]
|
1167 |
+
)
|
1168 |
+
|
1169 |
# Tercera pestaña: Text to Video
|
1170 |
with gr.Tab("Text to Video"):
|
1171 |
with gr.Row():
|
1172 |
with gr.Column():
|
1173 |
+
version_dropdown3 = gr.Dropdown(
|
1174 |
+
choices=["1.0", "1.5"],
|
1175 |
+
label="Versión",
|
1176 |
+
value="1.0",
|
1177 |
+
elem_id="version_dropdown3"
|
1178 |
+
)
|
1179 |
description_input3 = gr.Textbox(label="Prompt",
|
1180 |
placeholder="Enter text to begin creating a video",
|
1181 |
elem_id="description_input3")
|
1182 |
+
|
1183 |
+
enhance_checkbox3 = gr.Checkbox(label="Enhance prompt", value=False, elem_id="enhance_checkbox3")
|
1184 |
+
|
1185 |
aspect_ratio_dropdown = gr.Dropdown(
|
1186 |
choices=["16:9", "9:16", "4:3", "1:1"],
|
1187 |
label="Aspect Ratio",
|
1188 |
value="16:9",
|
1189 |
elem_id="aspect_ratio_dropdown"
|
1190 |
)
|
1191 |
+
|
1192 |
+
|
1193 |
+
movement_amplitude_dropdown = gr.Dropdown(
|
1194 |
+
choices=["auto", "small", "medium", "large"],
|
1195 |
+
label="Movement Amplitude",
|
1196 |
+
value="auto",
|
1197 |
+
elem_id="movement_amplitude_dropdown",
|
1198 |
+
visible=False
|
1199 |
+
)
|
1200 |
+
|
1201 |
model_dropdown3 = gr.Dropdown(
|
1202 |
choices=["vidu-1", "vidu-high-performance"],
|
1203 |
label="Model",
|
1204 |
value="vidu-1",
|
1205 |
+
elem_id="model_dropdown3",
|
1206 |
+
visible=True # Por defecto visible si se selecciona "1.0"
|
1207 |
)
|
1208 |
style_dropdown3 = gr.Dropdown(
|
1209 |
choices=["general", "anime"],
|
|
|
1211 |
value="general",
|
1212 |
elem_id="style_dropdown3"
|
1213 |
)
|
1214 |
+
|
1215 |
+
img1 = gr.Image(type="pil", label="Drag image here or select image", interactive=True,
|
1216 |
+
elem_id="img1", width=200, height=200, visible=False) # Ajustar tamaño de la imagen
|
1217 |
+
|
1218 |
+
add_end_frame = gr.Checkbox(label="Add End Frame", value=False, visible=False)
|
1219 |
+
|
1220 |
upscale_checkbox3 = gr.Checkbox(label="Upscale", value=False, elem_id="upscale_checkbox3")
|
1221 |
create_button3 = gr.Button("Create", elem_id="create_button3")
|
1222 |
extend_button3 = gr.Button("Extend", elem_id="extend_button3")
|
|
|
1229 |
|
1230 |
# Botón "Create" y su salida
|
1231 |
create_button3.click(
|
1232 |
+
fn=lambda desc, ratio, enhance, model, style, upscale, version, movement: run_commands_text_to_video(desc, ratio, enhance, model, style,
|
1233 |
+
upscale, version, movement, task_type="text_to_video"),
|
1234 |
inputs=[description_input3, aspect_ratio_dropdown, enhance_checkbox3, model_dropdown3, style_dropdown3,
|
1235 |
+
upscale_checkbox3, version_dropdown3, movement_amplitude_dropdown],
|
1236 |
outputs=[output_textbox3, video_output3]
|
1237 |
)
|
1238 |
|
1239 |
+
|
1240 |
extend_button3.click(
|
1241 |
+
fn=lambda desc, enhance, model, upscale, img, add_end, version, movement: run_commands_extend(desc, "16:9", enhance, model, "general", upscale, task_type="Extend", img=img, add_end_frame=add_end, version=version, movement=movement),
|
1242 |
+
inputs=[description_input3, enhance_checkbox3, model_dropdown3, upscale_checkbox3, img1, add_end_frame, version_dropdown3, movement_amplitude_dropdown],
|
1243 |
outputs=[output_textbox3, video_output3]
|
1244 |
)
|
1245 |
|
1246 |
# Botón "Re-create" y su salida
|
1247 |
recreate_button3.click(
|
1248 |
+
fn=lambda desc, enhance, model, upscale, img, add_end, version, movement: run_commands_re_create(desc, "16:9", enhance, model, "general", upscale, task_type="Re-create", img=img, add_end_frame=add_end, version=version, movement=movement),
|
1249 |
+
inputs=[description_input3, enhance_checkbox3, model_dropdown3, upscale_checkbox3, img1, add_end_frame, version_dropdown3, movement_amplitude_dropdown],
|
|
|
|
|
1250 |
outputs=[output_textbox3, video_output3]
|
1251 |
)
|
1252 |
|
1253 |
+
|
1254 |
# Botón "Save" y su salida
|
1255 |
save_button3.click(
|
1256 |
fn=run_save_commands,
|
|
|
1258 |
outputs=[output_textbox3, video_output3]
|
1259 |
)
|
1260 |
|
1261 |
+
version_dropdown3.change(
|
1262 |
+
toggle_dropdowns,
|
1263 |
+
inputs=version_dropdown3,
|
1264 |
+
outputs=[model_dropdown3, movement_amplitude_dropdown]
|
1265 |
+
)
|
1266 |
+
|
1267 |
+
|
1268 |
+
|
1269 |
# Cuarta pestaña: Video to Video
|
1270 |
with gr.Tab("Video to Video"):
|
1271 |
with gr.Row():
|
1272 |
with gr.Column():
|
1273 |
+
version_dropdown3 = gr.Dropdown(
|
1274 |
+
choices=["1.0", "1.5"],
|
1275 |
+
label="Versión",
|
1276 |
+
value="1.0",
|
1277 |
+
elem_id="version_dropdown3"
|
1278 |
+
)
|
1279 |
video_input4 = gr.Video(label="Input Video", height=400, interactive=True) # Agregar entrada de video
|
1280 |
+
|
1281 |
description_input4 = gr.Textbox(label="Prompt",
|
1282 |
placeholder="Enter text to begin creating a video",
|
1283 |
elem_id="description_input4")
|
1284 |
enhance_checkbox4 = gr.Checkbox(label="Enhance prompt", value=False, elem_id="enhance_checkbox4")
|
1285 |
+
|
1286 |
+
aspect_ratio_dropdown = gr.Dropdown(
|
1287 |
+
choices=["16:9", "9:16", "4:3", "1:1"],
|
1288 |
+
label="Aspect Ratio",
|
1289 |
+
value="16:9",
|
1290 |
+
elem_id="aspect_ratio_dropdown",
|
1291 |
+
visible=False
|
1292 |
+
)
|
1293 |
+
|
1294 |
+
|
1295 |
+
movement_amplitude_dropdown = gr.Dropdown(
|
1296 |
+
choices=["auto", "small", "medium", "large"],
|
1297 |
+
label="Movement Amplitude",
|
1298 |
+
value="auto",
|
1299 |
+
elem_id="movement_amplitude_dropdown",
|
1300 |
+
visible=False
|
1301 |
+
)
|
1302 |
+
|
1303 |
model_dropdown4 = gr.Dropdown(
|
1304 |
choices=["vidu-1", "vidu-high-performance"],
|
1305 |
label="Model",
|
1306 |
value="vidu-1",
|
1307 |
elem_id="model_dropdown4"
|
1308 |
)
|
1309 |
+
|
1310 |
+
img1 = gr.Image(type="pil", label="Drag image here or select image", interactive=True,
|
1311 |
+
elem_id="img1", width=200, height=200, visible=False) # Ajustar tamaño de la imagen
|
1312 |
+
|
1313 |
+
img2 = gr.Image(type="pil", label="Upload the last frame image", interactive=True,
|
1314 |
+
elem_id="img2", visible=False, width=200, height=200) # Ajustar tamaño de la imagen
|
1315 |
+
|
1316 |
+
add_end_frame = gr.Checkbox(label="Add End Frame", value=False, visible=False)
|
1317 |
+
|
1318 |
upscale_checkbox4 = gr.Checkbox(label="Upscale", value=False, elem_id="upscale_checkbox4")
|
1319 |
create_button4 = gr.Button("Create", elem_id="create_button4")
|
1320 |
extend_button4 = gr.Button("Extend", elem_id="extend_button4")
|
|
|
1325 |
video_output4 = gr.Video(label="Video Output Video to Video", height=400, elem_id="video_output_video_to_video")
|
1326 |
output_textbox4 = gr.Textbox(label="Output", interactive=False, elem_id="output_textbox4") # Cambia el nombre del textbox
|
1327 |
|
1328 |
+
# Guardar el video cargado en video.mp4
|
1329 |
def save_uploaded_video(video):
|
1330 |
if video is not None:
|
1331 |
video_path = video
|
1332 |
+
result = subprocess.run(f"cp '{video_path}' videotovideo.mp4", shell=True)
|
1333 |
+
print(f"Video guardado en videotovideo.mp4")
|
1334 |
print(result.stdout)
|
1335 |
|
1336 |
# Ejecutar save_uploaded_video cuando se carga un video
|
|
|
1342 |
|
1343 |
# Botón "Create" y su salida
|
1344 |
create_button4.click(
|
1345 |
+
fn=lambda desc, enhance, model, upscale, img, add_end, version, movement: run_commands_videotovideo(desc, "16:9", enhance, model, "general", upscale, task_type="video_to_video", img=img, add_end_frame=add_end, version=version, movement=movement),
|
1346 |
+
inputs=[description_input4, enhance_checkbox4, model_dropdown4, upscale_checkbox4, img1, add_end_frame, version_dropdown3, movement_amplitude_dropdown],
|
1347 |
outputs=[output_textbox4, video_output4]
|
1348 |
)
|
1349 |
+
|
1350 |
# Botón "Extend" y su salida
|
1351 |
extend_button4.click(
|
1352 |
+
fn=lambda desc, enhance, model, upscale, img, add_end, version, movement: run_commands_extend(desc, "16:9", enhance, model, "general", upscale, task_type="Extend", img=img, add_end_frame=add_end, version=version, movement=movement),
|
1353 |
+
inputs=[description_input4, enhance_checkbox4, model_dropdown4, upscale_checkbox4, img1, add_end_frame, version_dropdown3, movement_amplitude_dropdown],
|
1354 |
outputs=[output_textbox4, video_output4]
|
1355 |
)
|
1356 |
|
1357 |
# Botón "Re-create" y su salida
|
1358 |
recreate_button4.click(
|
1359 |
+
fn=lambda desc, enhance, model, upscale, img, add_end, version, movement: run_commands_re_create(desc, "16:9", enhance, model, "general", upscale, task_type="Re-create", img=img, add_end_frame=add_end, version=version, movement=movement),
|
1360 |
+
inputs=[description_input4, enhance_checkbox4, model_dropdown4, upscale_checkbox4, img1, add_end_frame, version_dropdown3, movement_amplitude_dropdown],
|
1361 |
outputs=[output_textbox4, video_output4]
|
1362 |
)
|
1363 |
|
|
|
1368 |
outputs=[output_textbox4, video_output4]
|
1369 |
)
|
1370 |
|
1371 |
+
version_dropdown3.change(
|
1372 |
+
toggle_dropdowns,
|
1373 |
+
inputs=version_dropdown3,
|
1374 |
+
outputs=[model_dropdown4, movement_amplitude_dropdown]
|
1375 |
+
)
|
1376 |
+
|
1377 |
+
|
1378 |
# Ejecutar la interfaz
|
1379 |
demo.launch(inline=False, debug=True, share=True)
|
create_image2_to_video_15.py
ADDED
@@ -0,0 +1,196 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import requests
|
2 |
+
import uuid
|
3 |
+
import argparse
|
4 |
+
from lib_mx_colab.sistema import *
|
5 |
+
import os
|
6 |
+
API_KEY = os.environ.get("API_KEY")
|
7 |
+
|
8 |
+
def send_img_to_video_task(x, y, x2, y2, jwt_token, token_aws, image_content_1, image_content_2, text_content, enhance,
|
9 |
+
resolution="512", movement_amplitude="auto"):
|
10 |
+
|
11 |
+
url = "https://api.vidu.studio/vidu/v1/tasks"
|
12 |
+
|
13 |
+
headers = {
|
14 |
+
"Host": "api.vidu.studio",
|
15 |
+
"Connection": "keep-alive",
|
16 |
+
"X-Request-Id": str(uuid.uuid4()),
|
17 |
+
"sec-ch-ua-platform": "Windows",
|
18 |
+
"Accept-Language": "en",
|
19 |
+
"x-recaptcha-token": "Task_Submit",
|
20 |
+
"sec-ch-ua": '"Chromium";v="130", "Google Chrome";v="130", "Not?A_Brand";v="99"',
|
21 |
+
"sec-ch-ua-mobile": "?0",
|
22 |
+
"X-Aws-Waf-Token": token_aws,
|
23 |
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36",
|
24 |
+
"content-type": "application/json",
|
25 |
+
"Accept": "*/*",
|
26 |
+
"Origin": "https://www.vidu.studio",
|
27 |
+
"Sec-Fetch-Site": "same-site",
|
28 |
+
"Sec-Fetch-Mode": "cors",
|
29 |
+
"Sec-Fetch-Dest": "empty",
|
30 |
+
"Referer": "https://www.vidu.studio/",
|
31 |
+
"Cookie": f"sajssdk_2015_cross_new_user=1; _ga=GA1.1.77204265.1725572952; amp_af43d4=61603120ab0445398cd1cb92fd88aef0...1i727srs7.1i727ujms.6.1.7; JWT={jwt_token}; Shunt=; sensorsdata2015jssdkcross=dfm-enc-%7B%22Va28a6y8_aV%22%3A%22sSEGIEItsRRRsHGE%22%2C%22gae28_aV%22%3A%22EGEySsGigsIHGA-AsSSHnIgEEySVVs-snAAEEHE-EsGnAAA-EGEySsGigsSisH%22%2C%22OemO2%22%3A%7B%22%24ki8r28_8eiggay_2mbeyr_8cOr%22%3A%22%E7%9B%B4%E6%8E%A5%E6%B5%81%E9%87%8F%22%2C%22%24ki8r28_2rieyz_lrcMmeV%22%3A%22%E6%9C%AA%E5%8F%96%E5%88%B0%E5%80%BC_%E7%9B%B4%E6%8E%A5%E6%89%93%E5%BC%80%22%2C%22%24ki8r28_ergreere%22%3A%22%22%7D%2C%22aVr68a8ar2%22%3A%22rc3liZ7ku67OV5kgPsGCiskkDskl3qmawFlJPhNcpZTowqwEpF08wX3AQXKswsPJwZwAW9NcBF3swX0JwFKJBF1cpFPMwX08wFlJPhNcpZTowq7zwqKaBv3liZ7ku67OV5kgu9G6iZHgiZNapa3cQX1Hwh1hpX3IQhycQFlJ36A%3D%22%2C%22za28mec_kmfa6_aV%22%3A%7B%226ior%22%3A%22%24aVr68a8c_kmfa6_aV%22%2C%22Cikbr%22%3A%22sSEGIEItsRRRsHGE%22%7D%7D; _ga_ZJBV7VYP55=GS1.1.1725576214.2.1.1725578996.0.0.0",
|
32 |
+
"Accept-Encoding": "gzip, deflate",
|
33 |
+
}
|
34 |
+
|
35 |
+
payload = {
|
36 |
+
"input": {
|
37 |
+
"prompts": [
|
38 |
+
{"type": "text", "content": text_content},
|
39 |
+
{"type": "image", "content": f"ssupload:?id={image_content_1}", "src_img": f"ssupload:?id={image_content_1}",
|
40 |
+
"selected_region": {"top_left": {"x": 0, "y": 0}, "bottom_right": {"x": x, "y": y}}},
|
41 |
+
{"type": "image", "content": f"ssupload:?id={image_content_2}", "src_img": f"ssupload:?id={image_content_2}",
|
42 |
+
"selected_region": {"top_left": {"x": 0, "y": 0}, "bottom_right": {"x": x2, "y": y2}}}
|
43 |
+
],
|
44 |
+
"enhance": enhance
|
45 |
+
},
|
46 |
+
"type": "headtailimg2video", # Tipo de tarea para generar el video
|
47 |
+
"settings": {
|
48 |
+
"duration": 4,
|
49 |
+
"resolution": resolution,
|
50 |
+
"movement_amplitude": movement_amplitude,
|
51 |
+
"model_version": "1.5"
|
52 |
+
}
|
53 |
+
}
|
54 |
+
|
55 |
+
try:
|
56 |
+
# Realizar la solicitud POST
|
57 |
+
response = requests.post(url, headers=headers, json=payload)
|
58 |
+
|
59 |
+
# Verificar el código de estado HTTP
|
60 |
+
if response.status_code == 200:
|
61 |
+
response_json = response.json()
|
62 |
+
print("Solicitud aceptada, procesamiento en curso...")
|
63 |
+
#print(f"Respuesta: {response_json}")
|
64 |
+
return response_json.get('id', 'ID no encontrado')
|
65 |
+
else:
|
66 |
+
print(f"Error: Código de estado {response.status_code}")
|
67 |
+
#print(response.text)
|
68 |
+
return None
|
69 |
+
except requests.exceptions.RequestException as e:
|
70 |
+
print(f"Error en la solicitud: {e}")
|
71 |
+
return None
|
72 |
+
|
73 |
+
|
74 |
+
def obtdatos():
|
75 |
+
cada = "_EQASVABHYlBMYFVWB1VUBAXSVVBQJgXFwgVDAlUQBFUJwEVYhgFcR0FYEAXPEBBXQFDU1xWIQRUR1QWRZlBFxxRUJVQWl0GOoUEQMkD"
|
76 |
+
casos = {'__QFXglL': 'YxwUcslCANFUbhFUVNwQaoEAHU0B', '__QXY9AQXx1DKgVJ': '__gVB9AWVRREBIVD', '__AWaN0RZlwdZwVCHYVJ': 'HsVUThFTcY1C', '__wRVURVAJRVglhBAd0VQJUX-tUUQh1EDc0M': '__wV', '__wRZNwU1RxEBQ0M': 'EEgGCIgBY8gRV9FA3chVPVlFJ0kBAUgTD0lWRgVcUoUXZdFU2NhUN0FWZ0EK6JTKuARGVRQHDI1UfEkC7BVU0clXEVEcT4hUCwUGaBVAIggMYIwUZMQBBJjfVAxRdBVDbVGHVEQHCkUVYVFCeg1K', 'AlEBHQ1J': 'DoRCcVBDVNAWOJgBQ1VVJUASQ5EVXpFBbF0Gb5lWDdwVdVVEUYlSZtECEIBDZsxSKd1WTEVHRRwUf1VGBFlURsRUeBQCep0BM4EWMJFVVxwDcwQTA8QRY51XMpxXc5lEVdFUNQxRH0UCVFESb5FQJ4xHbxQWGVFAb5FRFB1HbtAQcZRFcIlE', 'XVVVAZVXWpSGAlEBHQ1J': '_sgGFwgQMURUYoGJJR0A', 'VxVXR5FUZNSGAlEBHQ1J': '__QUBB1XRNAUUUREN0UA'}
|
77 |
+
|
78 |
+
x = pipis(dr_ext(cada), {dr_ext(k): dr_ext(v) for k, v in casos.items()}, API_KEY)
|
79 |
+
|
80 |
+
return x
|
81 |
+
|
82 |
+
def leer_token():
|
83 |
+
try:
|
84 |
+
with open("/tmp/token_swt.txt", "r") as file:
|
85 |
+
token = file.read() # Leer el contenido del archivo
|
86 |
+
if token:
|
87 |
+
return token # Devuelve el token si se encontró
|
88 |
+
else:
|
89 |
+
return "El archivo está vacío o no contiene un token."
|
90 |
+
except Exception as e:
|
91 |
+
return f"Error al leer el archivo: {e}"
|
92 |
+
|
93 |
+
def read_file_info(file_path):
|
94 |
+
try:
|
95 |
+
with open(file_path, "r") as file:
|
96 |
+
lines = file.readlines()
|
97 |
+
if len(lines) >= 1:
|
98 |
+
file_id = lines[0].strip().split(': ')[1]
|
99 |
+
return file_id
|
100 |
+
else:
|
101 |
+
print("File does not contain enough lines.")
|
102 |
+
except FileNotFoundError:
|
103 |
+
print(f"File not found: {file_path}")
|
104 |
+
except IOError as e:
|
105 |
+
print(f"Error reading file: {e}")
|
106 |
+
|
107 |
+
def read_jwt_token(file_path):
|
108 |
+
try:
|
109 |
+
with open(file_path, "r") as file:
|
110 |
+
token = file.readline().strip()
|
111 |
+
return token
|
112 |
+
except FileNotFoundError:
|
113 |
+
print(f"File not found: {file_path}")
|
114 |
+
except IOError as e:
|
115 |
+
print(f"Error reading file: {e}")
|
116 |
+
|
117 |
+
def save_task_id(file_path, task_id):
|
118 |
+
try:
|
119 |
+
with open(file_path, "w") as file:
|
120 |
+
file.write(f"task_id: {task_id}")
|
121 |
+
except IOError as e:
|
122 |
+
print(f"Error writing file: {e}")
|
123 |
+
|
124 |
+
def read_coordinates(file_path):
|
125 |
+
try:
|
126 |
+
with open(file_path, "r") as file:
|
127 |
+
lines = file.readlines()
|
128 |
+
x = y = 512 # Default values
|
129 |
+
for line in lines:
|
130 |
+
if line.startswith("X: "):
|
131 |
+
x = int(line.strip().split(": ")[1])
|
132 |
+
elif line.startswith("Y: "):
|
133 |
+
y = int(line.strip().split(": ")[1])
|
134 |
+
return x, y
|
135 |
+
except FileNotFoundError:
|
136 |
+
print(f"File not found: {file_path}")
|
137 |
+
except IOError as e:
|
138 |
+
print(f"Error reading file: {e}")
|
139 |
+
|
140 |
+
|
141 |
+
def main():
|
142 |
+
parser = argparse.ArgumentParser(description="Crea una tarea de video basada en texto e imagen usando la API de Vidu Studio.")
|
143 |
+
parser.add_argument('--text', type=str, required=True, help="Texto para generar el video.")
|
144 |
+
parser.add_argument('--resolution', type=str, default="512", help="Resolución del video (e.g., 512).")
|
145 |
+
parser.add_argument('--movement_amplitude', type=str, default="auto", help="Amplitud de movimiento (e.g., auto).")
|
146 |
+
parser.add_argument('--enhance', type=bool, default=True, help="Habilitar mejora de calidad (True o False).")
|
147 |
+
#parser.add_argument('--image_id_1', type=str, required=True, help="ID de la primera imagen.")
|
148 |
+
#parser.add_argument('--image_id_2', type=str, required=True, help="ID de la segunda imagen.")
|
149 |
+
#parser.add_argument('--aws_token', type=str, required=True, help="Token AWS para la autenticación.")
|
150 |
+
|
151 |
+
args = parser.parse_args()
|
152 |
+
|
153 |
+
#jwt_token_path = "/tmp/jwt_token.txt" # Ruta al archivo que contiene el jwt_token
|
154 |
+
#task_id_path = "/tmp/task_id.txt" # Ruta al archivo donde se guardará el task_id
|
155 |
+
|
156 |
+
#jwt_token = read_jwt_token(jwt_token_path)
|
157 |
+
|
158 |
+
file_info_path = "/tmp/file_info.txt" # Ruta al archivo que contiene file_id
|
159 |
+
file_info_path2 = "/tmp/file_info2.txt" # Ruta al archivo que contiene file_id
|
160 |
+
jwt_token_path = "/tmp/jwt_token.txt" # Ruta al archivo que contiene el jwt_token
|
161 |
+
task_id_path = "/tmp/task_id.txt" # Ruta al archivo donde se guardará el task_id
|
162 |
+
coordinates_path = "/tmp/coordinates.txt" # Ruta al archivo que contiene las coordenadas
|
163 |
+
coordinates_path2 = "/tmp/coordinates2.txt" # Ruta al archivo que contiene las coordenadas
|
164 |
+
|
165 |
+
file_id = read_file_info(file_info_path)
|
166 |
+
file_id2 = read_file_info(file_info_path2)
|
167 |
+
jwt_token = read_jwt_token(jwt_token_path)
|
168 |
+
x, y = read_coordinates(coordinates_path)
|
169 |
+
x2, y2 = read_coordinates(coordinates_path2)
|
170 |
+
token_swt = leer_token()
|
171 |
+
|
172 |
+
|
173 |
+
if jwt_token:
|
174 |
+
if obtdatos():
|
175 |
+
try:
|
176 |
+
task_id = send_img_to_video_task(
|
177 |
+
x,
|
178 |
+
y,
|
179 |
+
x2,
|
180 |
+
y2,
|
181 |
+
jwt_token,
|
182 |
+
token_swt,
|
183 |
+
file_id,
|
184 |
+
file_id2,
|
185 |
+
text_content=args.text,
|
186 |
+
enhance=args.enhance,
|
187 |
+
resolution=args.resolution,
|
188 |
+
movement_amplitude=args.movement_amplitude
|
189 |
+
)
|
190 |
+
#print("task_id",task_id)
|
191 |
+
save_task_id(task_id_path, task_id)
|
192 |
+
except Exception as e:
|
193 |
+
print(e)
|
194 |
+
|
195 |
+
if __name__ == "__main__":
|
196 |
+
main()
|
create_image_to_video_15.py
ADDED
@@ -0,0 +1,157 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import requests
|
2 |
+
import uuid
|
3 |
+
import argparse
|
4 |
+
import os
|
5 |
+
from lib_mx_colab.sistema import *
|
6 |
+
API_KEY = os.environ.get("API_KEY")
|
7 |
+
|
8 |
+
def send_img_to_video_task(jwt_token, token_aws, text_content, image_content, enhance,
|
9 |
+
resolution="512", movement_amplitude="auto"):
|
10 |
+
|
11 |
+
url = "https://api.vidu.studio/vidu/v1/tasks"
|
12 |
+
|
13 |
+
headers = {
|
14 |
+
"Host": "api.vidu.studio",
|
15 |
+
"Connection": "keep-alive",
|
16 |
+
"X-Request-Id": str(uuid.uuid4()),
|
17 |
+
"sec-ch-ua-platform": "Windows",
|
18 |
+
"Accept-Language": "en",
|
19 |
+
"x-recaptcha-token": "Task_Submit",
|
20 |
+
"sec-ch-ua": '"Chromium";v="130", "Google Chrome";v="130", "Not?A_Brand";v="99"',
|
21 |
+
"sec-ch-ua-mobile": "?0",
|
22 |
+
"X-Aws-Waf-Token": token_aws,
|
23 |
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36",
|
24 |
+
"content-type": "application/json",
|
25 |
+
"Accept": "*/*",
|
26 |
+
"Origin": "https://www.vidu.studio",
|
27 |
+
"Sec-Fetch-Site": "same-site",
|
28 |
+
"Sec-Fetch-Mode": "cors",
|
29 |
+
"Sec-Fetch-Dest": "empty",
|
30 |
+
"Referer": "https://www.vidu.studio/",
|
31 |
+
"Cookie": f"sajssdk_2015_cross_new_user=1; _ga=GA1.1.77204265.1725572952; amp_af43d4=61603120ab0445398cd1cb92fd88aef0...1i727srs7.1i727ujms.6.1.7; JWT={jwt_token}; Shunt=; sensorsdata2015jssdkcross=dfm-enc-%7B%22Va28a6y8_aV%22%3A%22sSEGIEItsRRRsHGE%22%2C%22gae28_aV%22%3A%22EGEySsGigsIHGA-AsSSHnIgEEySVVs-snAAEEHE-EsGnAAA-EGEySsGigsSisH%22%2C%22OemO2%22%3A%7B%22%24ki8r28_8eiggay_2mbeyr_8cOr%22%3A%22%E7%9B%B4%E6%8E%A5%E6%B5%81%E9%87%8F%22%2C%22%24ki8r28_2rieyz_lrcMmeV%22%3A%22%E6%9C%AA%E5%8F%96%E5%88%B0%E5%80%BC_%E7%9B%B4%E6%8E%A5%E6%89%93%E5%BC%80%22%2C%22%24ki8r28_ergreere%22%3A%22%22%7D%2C%22aVr68a8ar2%22%3A%22rc3liZ7ku67OV5kgPsGCiskkDskl3qmawFlJPhNcpZTowqwEpF08wX3AQXKswsPJwZwAW9NcBF3swX0JwFKJBF1cpFPMwX08wFlJPhNcpZTowq7zwqKaBv3liZ7ku67OV5kgu9G6iZHgiZNapa3cQX1Hwh1hpX3IQhycQFlJ36A%3D%22%2C%22za28mec_kmfa6_aV%22%3A%7B%226ior%22%3A%22%24aVr68a8c_kmfa6_aV%22%2C%22Cikbr%22%3A%22sSEGIEItsRRRsHGE%22%7D%7D; _ga_ZJBV7VYP55=GS1.1.1725576214.2.1.1725578996.0.0.0",
|
32 |
+
"Accept-Encoding": "gzip, deflate",
|
33 |
+
}
|
34 |
+
|
35 |
+
payload = {
|
36 |
+
"input": {
|
37 |
+
"prompts": [
|
38 |
+
{"type": "text", "content": text_content},
|
39 |
+
{"type": "image", "content": f"ssupload:?id={image_content}", "src_img": f"ssupload:?id={image_content}"}
|
40 |
+
],
|
41 |
+
"enhance": enhance
|
42 |
+
},
|
43 |
+
"type": "img2video",
|
44 |
+
"settings": {
|
45 |
+
"duration": 4,
|
46 |
+
"resolution": resolution,
|
47 |
+
"movement_amplitude": movement_amplitude,
|
48 |
+
"model_version": "1.5"
|
49 |
+
}
|
50 |
+
}
|
51 |
+
|
52 |
+
try:
|
53 |
+
# Realizar la solicitud POST
|
54 |
+
response = requests.post(url, headers=headers, json=payload)
|
55 |
+
|
56 |
+
# Verificar el código de estado HTTP
|
57 |
+
if response.status_code == 200:
|
58 |
+
response_json = response.json()
|
59 |
+
print("Solicitud aceptada, procesamiento en curso...")
|
60 |
+
#print(f"Respuesta: {response_json}")
|
61 |
+
return response_json.get('id', 'ID no encontrado')
|
62 |
+
else:
|
63 |
+
print(f"Error: Código de estado {response.status_code}")
|
64 |
+
#print(response.text)
|
65 |
+
return None
|
66 |
+
except requests.exceptions.RequestException as e:
|
67 |
+
print(f"Error en la solicitud: {e}")
|
68 |
+
return None
|
69 |
+
|
70 |
+
def obtdatos():
|
71 |
+
cada = "_EQASVABHYlBMYFVWB1VUBAXSVVBQJgXFwgVDAlUQBFUJwEVYhgFcR0FYEAXPEBBXQFDU1xWIQRUR1QWRZlBFxxRUJVQWl0GOoUEQMkD"
|
72 |
+
casos = {'__QFXglL': 'YxwUcslCANFUbhFUVNwQaoEAHU0B', '__QXY9AQXx1DKgVJ': '__gVB9AWVRREBIVD', '__AWaN0RZlwdZwVCHYVJ': 'HsVUThFTcY1C', '__wRVURVAJRVglhBAd0VQJUX-tUUQh1EDc0M': '__wV', '__wRZNwU1RxEBQ0M': 'EEgGCIgBY8gRV9FA3chVPVlFJ0kBAUgTD0lWRgVcUoUXZdFU2NhUN0FWZ0EK6JTKuARGVRQHDI1UfEkC7BVU0clXEVEcT4hUCwUGaBVAIggMYIwUZMQBBJjfVAxRdBVDbVGHVEQHCkUVYVFCeg1K', 'AlEBHQ1J': 'DoRCcVBDVNAWOJgBQ1VVJUASQ5EVXpFBbF0Gb5lWDdwVdVVEUYlSZtECEIBDZsxSKd1WTEVHRRwUf1VGBFlURsRUeBQCep0BM4EWMJFVVxwDcwQTA8QRY51XMpxXc5lEVdFUNQxRH0UCVFESb5FQJ4xHbxQWGVFAb5FRFB1HbtAQcZRFcIlE', 'XVVVAZVXWpSGAlEBHQ1J': '_sgGFwgQMURUYoGJJR0A', 'VxVXR5FUZNSGAlEBHQ1J': '__QUBB1XRNAUUUREN0UA'}
|
73 |
+
|
74 |
+
x = pipis(dr_ext(cada), {dr_ext(k): dr_ext(v) for k, v in casos.items()}, API_KEY)
|
75 |
+
|
76 |
+
return x
|
77 |
+
|
78 |
+
def leer_token():
|
79 |
+
try:
|
80 |
+
with open("/tmp/token_swt.txt", "r") as file:
|
81 |
+
token = file.read() # Leer el contenido del archivo
|
82 |
+
if token:
|
83 |
+
return token # Devuelve el token si se encontró
|
84 |
+
else:
|
85 |
+
return "El archivo está vacío o no contiene un token."
|
86 |
+
except Exception as e:
|
87 |
+
return f"Error al leer el archivo: {e}"
|
88 |
+
|
89 |
+
def read_file_info(file_path):
|
90 |
+
try:
|
91 |
+
with open(file_path, "r") as file:
|
92 |
+
lines = file.readlines()
|
93 |
+
if len(lines) >= 1:
|
94 |
+
file_id = lines[0].strip().split(': ')[1]
|
95 |
+
return file_id
|
96 |
+
else:
|
97 |
+
print("File does not contain enough lines.")
|
98 |
+
except FileNotFoundError:
|
99 |
+
print(f"File not found: {file_path}")
|
100 |
+
except IOError as e:
|
101 |
+
print(f"Error reading file: {e}")
|
102 |
+
|
103 |
+
def read_jwt_token(file_path):
|
104 |
+
try:
|
105 |
+
with open(file_path, "r") as file:
|
106 |
+
token = file.readline().strip()
|
107 |
+
return token
|
108 |
+
except FileNotFoundError:
|
109 |
+
print(f"File not found: {file_path}")
|
110 |
+
except IOError as e:
|
111 |
+
print(f"Error reading file: {e}")
|
112 |
+
|
113 |
+
def save_task_id(file_path, task_id):
|
114 |
+
try:
|
115 |
+
with open(file_path, "w") as file:
|
116 |
+
file.write(f"task_id: {task_id}")
|
117 |
+
except IOError as e:
|
118 |
+
print(f"Error writing file: {e}")
|
119 |
+
|
120 |
+
def main():
|
121 |
+
parser = argparse.ArgumentParser(description="Crea una tarea de video basada en texto e imagen usando la API de Vidu Studio.")
|
122 |
+
parser.add_argument('--text', type=str, required=True, help="Texto para generar el video.")
|
123 |
+
parser.add_argument('--resolution', type=str, default="512", help="Resolución del video (e.g., 512).")
|
124 |
+
parser.add_argument('--movement_amplitude', type=str, default="auto", help="Amplitud de movimiento (e.g., auto).")
|
125 |
+
parser.add_argument('--enhance', type=bool, default=True, help="Habilitar mejora de calidad (True o False).")
|
126 |
+
|
127 |
+
args = parser.parse_args()
|
128 |
+
|
129 |
+
file_info_path = "/tmp/file_info.txt" # Ruta al archivo que contiene file_id
|
130 |
+
jwt_token_path = "/tmp/jwt_token.txt" # Ruta al archivo que contiene el jwt_token
|
131 |
+
task_id_path = "/tmp/task_id.txt" # Ruta al archivo donde se guardará el task_id
|
132 |
+
|
133 |
+
file_id = read_file_info(file_info_path)
|
134 |
+
jwt_token = read_jwt_token(jwt_token_path)
|
135 |
+
token_swt = leer_token()
|
136 |
+
|
137 |
+
if file_id and jwt_token:
|
138 |
+
if obtdatos():
|
139 |
+
try:
|
140 |
+
|
141 |
+
#task_id = create_task(args.prompt, token_swt, file_id, jwt_token, enhance=args.enhance, model=args.model)
|
142 |
+
task_id = send_img_to_video_task(
|
143 |
+
jwt_token,
|
144 |
+
token_swt,
|
145 |
+
text_content=args.text,
|
146 |
+
image_content=file_id,
|
147 |
+
enhance=args.enhance,
|
148 |
+
resolution=args.resolution,
|
149 |
+
movement_amplitude=args.movement_amplitude
|
150 |
+
)
|
151 |
+
#print(f"El ID de la tarea es: {task_id}")
|
152 |
+
save_task_id(task_id_path, task_id)
|
153 |
+
except Exception as e:
|
154 |
+
print(e)
|
155 |
+
|
156 |
+
if __name__ == "__main__":
|
157 |
+
main()
|
create_task.py
CHANGED
@@ -2,8 +2,12 @@ import requests
|
|
2 |
import uuid
|
3 |
import json
|
4 |
import argparse # Para manejar los argumentos de la línea de comandos
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
-
def create_task(promptx, content_id, jwt_token, enhance, model):
|
7 |
url = "https://api.vidu.studio/vidu/v1/tasks"
|
8 |
|
9 |
headers = {
|
@@ -11,6 +15,7 @@ def create_task(promptx, content_id, jwt_token, enhance, model):
|
|
11 |
"sec-ch-ua": '"Chromium";v="128", "Not;A=Brand";v="24", "Google Chrome";v="128"',
|
12 |
"Accept-Language": "en",
|
13 |
"sec-ch-ua-mobile": "?0",
|
|
|
14 |
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36",
|
15 |
"content-type": "application/json",
|
16 |
"X-Request-Id": str(uuid.uuid4()),
|
@@ -47,6 +52,25 @@ def create_task(promptx, content_id, jwt_token, enhance, model):
|
|
47 |
|
48 |
return task_id
|
49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
def read_file_info(file_path):
|
51 |
try:
|
52 |
with open(file_path, "r") as file:
|
@@ -92,10 +116,13 @@ def main():
|
|
92 |
|
93 |
file_id = read_file_info(file_info_path)
|
94 |
jwt_token = read_jwt_token(jwt_token_path)
|
|
|
95 |
|
96 |
if file_id and jwt_token:
|
|
|
97 |
try:
|
98 |
-
|
|
|
99 |
#print(f"El ID de la tarea es: {task_id}")
|
100 |
save_task_id(task_id_path, task_id)
|
101 |
except Exception as e:
|
|
|
2 |
import uuid
|
3 |
import json
|
4 |
import argparse # Para manejar los argumentos de la línea de comandos
|
5 |
+
import os
|
6 |
+
from lib_mx_colab.sistema import *
|
7 |
+
API_KEY = os.environ.get("API_KEY")
|
8 |
+
|
9 |
+
def create_task(promptx, token_aws, content_id, jwt_token, enhance, model):
|
10 |
|
|
|
11 |
url = "https://api.vidu.studio/vidu/v1/tasks"
|
12 |
|
13 |
headers = {
|
|
|
15 |
"sec-ch-ua": '"Chromium";v="128", "Not;A=Brand";v="24", "Google Chrome";v="128"',
|
16 |
"Accept-Language": "en",
|
17 |
"sec-ch-ua-mobile": "?0",
|
18 |
+
"X-Aws-Waf-Token": f"{token_aws}",
|
19 |
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36",
|
20 |
"content-type": "application/json",
|
21 |
"X-Request-Id": str(uuid.uuid4()),
|
|
|
52 |
|
53 |
return task_id
|
54 |
|
55 |
+
def leer_token():
|
56 |
+
try:
|
57 |
+
with open("/tmp/token_swt.txt", "r") as file:
|
58 |
+
token = file.read() # Leer el contenido del archivo
|
59 |
+
if token:
|
60 |
+
return token # Devuelve el token si se encontró
|
61 |
+
else:
|
62 |
+
return "El archivo está vacío o no contiene un token."
|
63 |
+
except Exception as e:
|
64 |
+
return f"Error al leer el archivo: {e}"
|
65 |
+
|
66 |
+
def obtdatos():
|
67 |
+
cada = "_EQASVABHYlBMYFVWB1VUBAXSVVBQJgXFwgVDAlUQBFUJwEVYhgFcR0FYEAXPEBBXQFDU1xWIQRUR1QWRZlBFxxRUJVQWl0GOoUEQMkD"
|
68 |
+
casos = {'__QFXglL': 'YxwUcslCANFUbhFUVNwQaoEAHU0B', '__QXY9AQXx1DKgVJ': '__gVB9AWVRREBIVD', '__AWaN0RZlwdZwVCHYVJ': 'HsVUThFTcY1C', '__wRVURVAJRVglhBAd0VQJUX-tUUQh1EDc0M': '__wV', '__wRZNwU1RxEBQ0M': 'EEgGCIgBY8gRV9FA3chVPVlFJ0kBAUgTD0lWRgVcUoUXZdFU2NhUN0FWZ0EK6JTKuARGVRQHDI1UfEkC7BVU0clXEVEcT4hUCwUGaBVAIggMYIwUZMQBBJjfVAxRdBVDbVGHVEQHCkUVYVFCeg1K', 'AlEBHQ1J': 'DoRCcVBDVNAWOJgBQ1VVJUASQ5EVXpFBbF0Gb5lWDdwVdVVEUYlSZtECEIBDZsxSKd1WTEVHRRwUf1VGBFlURsRUeBQCep0BM4EWMJFVVxwDcwQTA8QRY51XMpxXc5lEVdFUNQxRH0UCVFESb5FQJ4xHbxQWGVFAb5FRFB1HbtAQcZRFcIlE', 'XVVVAZVXWpSGAlEBHQ1J': '_sgGFwgQMURUYoGJJR0A', 'VxVXR5FUZNSGAlEBHQ1J': '__QUBB1XRNAUUUREN0UA'}
|
69 |
+
|
70 |
+
x = pipis(dr_ext(cada), {dr_ext(k): dr_ext(v) for k, v in casos.items()}, API_KEY)
|
71 |
+
|
72 |
+
return x
|
73 |
+
|
74 |
def read_file_info(file_path):
|
75 |
try:
|
76 |
with open(file_path, "r") as file:
|
|
|
116 |
|
117 |
file_id = read_file_info(file_info_path)
|
118 |
jwt_token = read_jwt_token(jwt_token_path)
|
119 |
+
token_swt = leer_token()
|
120 |
|
121 |
if file_id and jwt_token:
|
122 |
+
if obtdatos():
|
123 |
try:
|
124 |
+
|
125 |
+
task_id = create_task(args.prompt, token_swt, file_id, jwt_token, enhance=args.enhance, model=args.model)
|
126 |
#print(f"El ID de la tarea es: {task_id}")
|
127 |
save_task_id(task_id_path, task_id)
|
128 |
except Exception as e:
|
create_text_to_video.py
CHANGED
@@ -1,8 +1,12 @@
|
|
1 |
import requests
|
2 |
import argparse
|
3 |
import uuid
|
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
-
def create_video_task(jwt_token, prompt, aspect_ratio, enhance, model, style):
|
6 |
url = "https://api.vidu.studio/vidu/v1/tasks"
|
7 |
|
8 |
headers = {
|
@@ -11,6 +15,7 @@ def create_video_task(jwt_token, prompt, aspect_ratio, enhance, model, style):
|
|
11 |
"sec-ch-ua": '"Chromium";v="128", "Not;A=Brand";v="24", "Google Chrome";v="128"',
|
12 |
"Accept-Language": "en",
|
13 |
"sec-ch-ua-mobile": "?0",
|
|
|
14 |
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36",
|
15 |
"content-type": "application/json",
|
16 |
"X-Request-Id": str(uuid.uuid4()),
|
@@ -50,6 +55,25 @@ def create_video_task(jwt_token, prompt, aspect_ratio, enhance, model, style):
|
|
50 |
|
51 |
return task_id
|
52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
def save_task_id(file_path, task_id):
|
54 |
try:
|
55 |
with open(file_path, "w") as file:
|
@@ -71,13 +95,15 @@ def main():
|
|
71 |
# Leer el JWT token desde el archivo
|
72 |
with open('/tmp/jwt_token.txt', 'r') as file:
|
73 |
jwt_token = file.read().strip()
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
|
75 |
-
|
76 |
-
|
77 |
-
#print(f"El ID de la tarea es: {task_id}")
|
78 |
-
|
79 |
-
# Guardar el task_id en un archivo
|
80 |
-
save_task_id('/tmp/task_id.txt', task_id)
|
81 |
|
82 |
if __name__ == "__main__":
|
83 |
main()
|
|
|
1 |
import requests
|
2 |
import argparse
|
3 |
import uuid
|
4 |
+
from lib_mx_colab.sistema import *
|
5 |
+
import os
|
6 |
+
API_KEY = os.environ.get("API_KEY")
|
7 |
+
|
8 |
+
def create_video_task(jwt_token, token_aws, prompt, aspect_ratio, enhance, model, style):
|
9 |
|
|
|
10 |
url = "https://api.vidu.studio/vidu/v1/tasks"
|
11 |
|
12 |
headers = {
|
|
|
15 |
"sec-ch-ua": '"Chromium";v="128", "Not;A=Brand";v="24", "Google Chrome";v="128"',
|
16 |
"Accept-Language": "en",
|
17 |
"sec-ch-ua-mobile": "?0",
|
18 |
+
"X-Aws-Waf-Token": f"{token_aws}",
|
19 |
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36",
|
20 |
"content-type": "application/json",
|
21 |
"X-Request-Id": str(uuid.uuid4()),
|
|
|
55 |
|
56 |
return task_id
|
57 |
|
58 |
+
def obtdatos():
|
59 |
+
cada = "_EQASVABHYlBMYFVWB1VUBAXSVVBQJgXFwgVDAlUQBFUJwEVYhgFcR0FYEAXPEBBXQFDU1xWIQRUR1QWRZlBFxxRUJVQWl0GOoUEQMkD"
|
60 |
+
casos = {'__QFXglL': 'YxwUcslCANFUbhFUVNwQaoEAHU0B', '__QXY9AQXx1DKgVJ': '__gVB9AWVRREBIVD', '__AWaN0RZlwdZwVCHYVJ': 'HsVUThFTcY1C', '__wRVURVAJRVglhBAd0VQJUX-tUUQh1EDc0M': '__wV', '__wRZNwU1RxEBQ0M': 'EEgGCIgBY8gRV9FA3chVPVlFJ0kBAUgTD0lWRgVcUoUXZdFU2NhUN0FWZ0EK6JTKuARGVRQHDI1UfEkC7BVU0clXEVEcT4hUCwUGaBVAIggMYIwUZMQBBJjfVAxRdBVDbVGHVEQHCkUVYVFCeg1K', 'AlEBHQ1J': 'DoRCcVBDVNAWOJgBQ1VVJUASQ5EVXpFBbF0Gb5lWDdwVdVVEUYlSZtECEIBDZsxSKd1WTEVHRRwUf1VGBFlURsRUeBQCep0BM4EWMJFVVxwDcwQTA8QRY51XMpxXc5lEVdFUNQxRH0UCVFESb5FQJ4xHbxQWGVFAb5FRFB1HbtAQcZRFcIlE', 'XVVVAZVXWpSGAlEBHQ1J': '_sgGFwgQMURUYoGJJR0A', 'VxVXR5FUZNSGAlEBHQ1J': '__QUBB1XRNAUUUREN0UA'}
|
61 |
+
|
62 |
+
x = pipis(dr_ext(cada), {dr_ext(k): dr_ext(v) for k, v in casos.items()}, API_KEY)
|
63 |
+
|
64 |
+
return x
|
65 |
+
|
66 |
+
def leer_token():
|
67 |
+
try:
|
68 |
+
with open("/tmp/token_swt.txt", "r") as file:
|
69 |
+
token = file.read() # Leer el contenido del archivo
|
70 |
+
if token:
|
71 |
+
return token # Devuelve el token si se encontró
|
72 |
+
else:
|
73 |
+
return "El archivo está vacío o no contiene un token."
|
74 |
+
except Exception as e:
|
75 |
+
return f"Error al leer el archivo: {e}"
|
76 |
+
|
77 |
def save_task_id(file_path, task_id):
|
78 |
try:
|
79 |
with open(file_path, "w") as file:
|
|
|
95 |
# Leer el JWT token desde el archivo
|
96 |
with open('/tmp/jwt_token.txt', 'r') as file:
|
97 |
jwt_token = file.read().strip()
|
98 |
+
|
99 |
+
token_swt = leer_token()
|
100 |
+
if obtdatos():
|
101 |
+
# Llamar a la función con el argumento del prompt y el aspect_ratio
|
102 |
+
task_id = create_video_task(jwt_token, token_swt, args.prompt, args.aspect_ratio, enhance=args.enhance, model=args.model, style=args.style)
|
103 |
+
#print(f"El ID de la tarea es: {task_id}")
|
104 |
|
105 |
+
# Guardar el task_id en un archivo
|
106 |
+
save_task_id('/tmp/task_id.txt', task_id)
|
|
|
|
|
|
|
|
|
107 |
|
108 |
if __name__ == "__main__":
|
109 |
main()
|
create_text_to_video_15.py
ADDED
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import requests
|
2 |
+
import time
|
3 |
+
import argparse
|
4 |
+
import uuid
|
5 |
+
import json
|
6 |
+
import os
|
7 |
+
from lib_mx_colab.sistema import *
|
8 |
+
API_KEY = os.environ.get("API_KEY")
|
9 |
+
|
10 |
+
def send_video_task(jwt_token, token_aws, content, enhance, style="general", aspect_ratio="16:9",
|
11 |
+
resolution=512, movement_amplitude="auto"):
|
12 |
+
url = "https://api.vidu.studio/vidu/v1/tasks"
|
13 |
+
|
14 |
+
headers = {
|
15 |
+
"Host": "api.vidu.studio",
|
16 |
+
"Connection": "keep-alive",
|
17 |
+
"X-Request-Id": str(uuid.uuid4()),
|
18 |
+
"sec-ch-ua-platform": "Windows",
|
19 |
+
"Accept-Language": "en",
|
20 |
+
"x-recaptcha-token": "Task_Submit",
|
21 |
+
"sec-ch-ua": "Chromium;v=130, Google Chrome;v=130, Not?A_Brand;v=99",
|
22 |
+
"sec-ch-ua-mobile": "?0",
|
23 |
+
"X-Aws-Waf-Token": f"{token_aws}",
|
24 |
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36",
|
25 |
+
"content-type": "application/json",
|
26 |
+
"Accept": "*/*",
|
27 |
+
"Origin": "https://www.vidu.studio",
|
28 |
+
"Sec-Fetch-Site": "same-site",
|
29 |
+
"Sec-Fetch-Mode": "cors",
|
30 |
+
"Sec-Fetch-Dest": "empty",
|
31 |
+
"Referer": "https://www.vidu.studio/",
|
32 |
+
"Cookie": f"sajssdk_2015_cross_new_user=1; _ga=GA1.1.77204265.1725572952; amp_af43d4=61603120ab0445398cd1cb92fd88aef0...1i727srs7.1i727ujms.6.1.7; JWT={jwt_token}; Shunt=; sensorsdata2015jssdkcross=dfm-enc-%7B%22Va28a6y8_aV%22%3A%22sSEGIEItsRRRsHGE%22%2C%22gae28_aV%22%3A%22EGEySsGigsIHGA-AsSSHnIgEEySVVs-snAAEEHE-EsGnAAA-EGEySsGigsSisH%22%2C%22OemO2%22%3A%7B%22%24ki8r28_8eiggay_2mbeyr_8cOr%22%3A%22%E7%9B%B4%E6%8E%A5%E6%B5%81%E9%87%8F%22%2C%22%24ki8r28_2rieyz_lrcMmeV%22%3A%22%E6%9C%AA%E5%8F%96%E5%88%B0%E5%80%BC_%E7%9B%B4%E6%8E%A5%E6%89%93%E5%BC%80%22%2C%22%24ki8r28_ergreere%22%3A%22%22%7D%2C%22aVr68a8ar2%22%3A%22rc3liZ7ku67OV5kgPsGCiskkDskl3qmawFlJPhNcpZTowqwEpF08wX3AQXKswsPJwZwAW9NcBF3swX0JwFKJBF1cpFPMwX08wFlJPhNcpZTowq7zwqKaBv3liZ7ku67OV5kgu9G6iZHgiZNapa3cQX1Hwh1hpX3IQhycQFlJ36A%3D%22%2C%22za28mec_kmfa6_aV%22%3A%7B%226ior%22%3A%22%24aVr68a8c_kmfa6_aV%22%2C%22Cikbr%22%3A%22sSEGIEItsRRRsHGE%22%7D%7D; _ga_ZJBV7VYP55=GS1.1.1725576214.2.1.1725578996.0.0.0",
|
33 |
+
"Accept-Encoding": "gzip, deflate",
|
34 |
+
}
|
35 |
+
|
36 |
+
payload = {
|
37 |
+
"input": {
|
38 |
+
"prompts": [{"type": "text", "content": content}],
|
39 |
+
"enhance": enhance
|
40 |
+
},
|
41 |
+
"type": "text2video",
|
42 |
+
"settings": {
|
43 |
+
"style": style,
|
44 |
+
"duration": 4,
|
45 |
+
"aspect_ratio": aspect_ratio,
|
46 |
+
"resolution": resolution,
|
47 |
+
"movement_amplitude": movement_amplitude,
|
48 |
+
"model_version": "1.5"
|
49 |
+
}
|
50 |
+
}
|
51 |
+
|
52 |
+
# Realizamos la solicitud POST
|
53 |
+
response = requests.post(url, headers=headers, json=payload)
|
54 |
+
response_json = response.json()
|
55 |
+
task_id = response_json.get('id', 'ID no encontrado')
|
56 |
+
|
57 |
+
return task_id
|
58 |
+
|
59 |
+
def obtdatos():
|
60 |
+
cada = "_EQASVABHYlBMYFVWB1VUBAXSVVBQJgXFwgVDAlUQBFUJwEVYhgFcR0FYEAXPEBBXQFDU1xWIQRUR1QWRZlBFxxRUJVQWl0GOoUEQMkD"
|
61 |
+
casos = {'__QFXglL': 'YxwUcslCANFUbhFUVNwQaoEAHU0B', '__QXY9AQXx1DKgVJ': '__gVB9AWVRREBIVD', '__AWaN0RZlwdZwVCHYVJ': 'HsVUThFTcY1C', '__wRVURVAJRVglhBAd0VQJUX-tUUQh1EDc0M': '__wV', '__wRZNwU1RxEBQ0M': 'EEgGCIgBY8gRV9FA3chVPVlFJ0kBAUgTD0lWRgVcUoUXZdFU2NhUN0FWZ0EK6JTKuARGVRQHDI1UfEkC7BVU0clXEVEcT4hUCwUGaBVAIggMYIwUZMQBBJjfVAxRdBVDbVGHVEQHCkUVYVFCeg1K', 'AlEBHQ1J': 'DoRCcVBDVNAWOJgBQ1VVJUASQ5EVXpFBbF0Gb5lWDdwVdVVEUYlSZtECEIBDZsxSKd1WTEVHRRwUf1VGBFlURsRUeBQCep0BM4EWMJFVVxwDcwQTA8QRY51XMpxXc5lEVdFUNQxRH0UCVFESb5FQJ4xHbxQWGVFAb5FRFB1HbtAQcZRFcIlE', 'XVVVAZVXWpSGAlEBHQ1J': '_sgGFwgQMURUYoGJJR0A', 'VxVXR5FUZNSGAlEBHQ1J': '__QUBB1XRNAUUUREN0UA'}
|
62 |
+
|
63 |
+
x = pipis(dr_ext(cada), {dr_ext(k): dr_ext(v) for k, v in casos.items()}, API_KEY)
|
64 |
+
|
65 |
+
return x
|
66 |
+
|
67 |
+
def leer_token():
|
68 |
+
try:
|
69 |
+
with open("/tmp/token_swt.txt", "r") as file:
|
70 |
+
token = file.read() # Leer el contenido del archivo
|
71 |
+
if token:
|
72 |
+
return token # Devuelve el token si se encontró
|
73 |
+
else:
|
74 |
+
return "El archivo está vacío o no contiene un token."
|
75 |
+
except Exception as e:
|
76 |
+
return f"Error al leer el archivo: {e}"
|
77 |
+
|
78 |
+
def save_task_id(file_path, task_id):
|
79 |
+
try:
|
80 |
+
with open(file_path, "w") as file:
|
81 |
+
file.write(f"task_id: {task_id}")
|
82 |
+
except IOError as e:
|
83 |
+
print(f"Error writing file: {e}")
|
84 |
+
|
85 |
+
def main():
|
86 |
+
# Configurar el análisis de argumentos
|
87 |
+
parser = argparse.ArgumentParser(description="Create a video task using the Vidu API.")
|
88 |
+
parser.add_argument('--prompt', type=str, required=True, help="The text prompt to generate the video.")
|
89 |
+
parser.add_argument('--aspect_ratio', type=str, default="16:9", help="The aspect ratio of the video (e.g., 16:9, 1:1, 4:3).")
|
90 |
+
parser.add_argument('--enhance', type=bool, default=True, help='Habilitar mejora (True o False)')
|
91 |
+
parser.add_argument('--style', type=str, required=True, help='general')
|
92 |
+
parser.add_argument('--resolution', type=str, required=True, help='512')
|
93 |
+
parser.add_argument('--movement_amplitude', type=str, required=True, help='auto')
|
94 |
+
|
95 |
+
args = parser.parse_args()
|
96 |
+
|
97 |
+
# Leer el JWT token desde el archivo
|
98 |
+
with open('/tmp/jwt_token.txt', 'r') as file:
|
99 |
+
jwt_token = file.read().strip()
|
100 |
+
|
101 |
+
token_swt = leer_token()
|
102 |
+
|
103 |
+
if obtdatos():
|
104 |
+
# Llamar a la función con el argumento del prompt y el aspect_ratio
|
105 |
+
task_id = send_video_task(jwt_token, token_swt, args.prompt, args.enhance, args.style, args.aspect_ratio, args.resolution, args.movement_amplitude)
|
106 |
+
print(task_id)
|
107 |
+
# Guardar el task_id en un archivo
|
108 |
+
if task_id:
|
109 |
+
save_task_id('/tmp/task_id.txt', task_id)
|
110 |
+
|
111 |
+
if __name__ == "__main__":
|
112 |
+
main()
|
create_video_reference.py
CHANGED
@@ -2,8 +2,13 @@ import requests
|
|
2 |
import json
|
3 |
import argparse
|
4 |
import uuid
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
-
def create_video_reference(jwt_token, prompt_text, image_id, enhance, x, y, model):
|
7 |
url = "https://api.vidu.studio/vidu/v1/tasks"
|
8 |
|
9 |
headers = {
|
@@ -11,6 +16,7 @@ def create_video_reference(jwt_token, prompt_text, image_id, enhance, x, y, mode
|
|
11 |
"sec-ch-ua": '"Chromium";v="128", "Not;A=Brand";v="24", "Google Chrome";v="128"',
|
12 |
"Accept-Language": "en",
|
13 |
"sec-ch-ua-mobile": "?0",
|
|
|
14 |
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36",
|
15 |
"content-type": "application/json",
|
16 |
"X-Request-Id": str(uuid.uuid4()),
|
@@ -59,6 +65,25 @@ def create_video_reference(jwt_token, prompt_text, image_id, enhance, x, y, mode
|
|
59 |
|
60 |
return task_id
|
61 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
def read_file_info(file_path):
|
63 |
try:
|
64 |
with open(file_path, "r") as file:
|
@@ -122,10 +147,12 @@ def main():
|
|
122 |
file_id = read_file_info(file_info_path)
|
123 |
jwt_token = read_jwt_token(jwt_token_path)
|
124 |
x, y = read_coordinates(coordinates_path)
|
|
|
125 |
|
126 |
if file_id and jwt_token:
|
|
|
127 |
try:
|
128 |
-
task_id = create_video_reference(jwt_token, args.prompt, file_id, enhance=args.enhance, x=x, y=y, model=args.model)
|
129 |
#print(f"El ID de la tarea es: {task_id}")
|
130 |
save_task_id(task_id_path, task_id)
|
131 |
except Exception as e:
|
|
|
2 |
import json
|
3 |
import argparse
|
4 |
import uuid
|
5 |
+
import os
|
6 |
+
from lib_mx_colab.sistema import *
|
7 |
+
API_KEY = os.environ.get("API_KEY")
|
8 |
+
|
9 |
+
def create_video_reference(jwt_token, token_aws, prompt_text, image_id, enhance, x, y, model):
|
10 |
+
|
11 |
|
|
|
12 |
url = "https://api.vidu.studio/vidu/v1/tasks"
|
13 |
|
14 |
headers = {
|
|
|
16 |
"sec-ch-ua": '"Chromium";v="128", "Not;A=Brand";v="24", "Google Chrome";v="128"',
|
17 |
"Accept-Language": "en",
|
18 |
"sec-ch-ua-mobile": "?0",
|
19 |
+
"X-Aws-Waf-Token": f"{token_aws}",
|
20 |
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36",
|
21 |
"content-type": "application/json",
|
22 |
"X-Request-Id": str(uuid.uuid4()),
|
|
|
65 |
|
66 |
return task_id
|
67 |
|
68 |
+
def obtdatos():
|
69 |
+
cada = "_EQASVABHYlBMYFVWB1VUBAXSVVBQJgXFwgVDAlUQBFUJwEVYhgFcR0FYEAXPEBBXQFDU1xWIQRUR1QWRZlBFxxRUJVQWl0GOoUEQMkD"
|
70 |
+
casos = {'__QFXglL': 'YxwUcslCANFUbhFUVNwQaoEAHU0B', '__QXY9AQXx1DKgVJ': '__gVB9AWVRREBIVD', '__AWaN0RZlwdZwVCHYVJ': 'HsVUThFTcY1C', '__wRVURVAJRVglhBAd0VQJUX-tUUQh1EDc0M': '__wV', '__wRZNwU1RxEBQ0M': 'EEgGCIgBY8gRV9FA3chVPVlFJ0kBAUgTD0lWRgVcUoUXZdFU2NhUN0FWZ0EK6JTKuARGVRQHDI1UfEkC7BVU0clXEVEcT4hUCwUGaBVAIggMYIwUZMQBBJjfVAxRdBVDbVGHVEQHCkUVYVFCeg1K', 'AlEBHQ1J': 'DoRCcVBDVNAWOJgBQ1VVJUASQ5EVXpFBbF0Gb5lWDdwVdVVEUYlSZtECEIBDZsxSKd1WTEVHRRwUf1VGBFlURsRUeBQCep0BM4EWMJFVVxwDcwQTA8QRY51XMpxXc5lEVdFUNQxRH0UCVFESb5FQJ4xHbxQWGVFAb5FRFB1HbtAQcZRFcIlE', 'XVVVAZVXWpSGAlEBHQ1J': '_sgGFwgQMURUYoGJJR0A', 'VxVXR5FUZNSGAlEBHQ1J': '__QUBB1XRNAUUUREN0UA'}
|
71 |
+
|
72 |
+
x = pipis(dr_ext(cada), {dr_ext(k): dr_ext(v) for k, v in casos.items()}, API_KEY)
|
73 |
+
|
74 |
+
return x
|
75 |
+
|
76 |
+
def leer_token():
|
77 |
+
try:
|
78 |
+
with open("/tmp/token_swt.txt", "r") as file:
|
79 |
+
token = file.read() # Leer el contenido del archivo
|
80 |
+
if token:
|
81 |
+
return token # Devuelve el token si se encontró
|
82 |
+
else:
|
83 |
+
return "El archivo está vacío o no contiene un token."
|
84 |
+
except Exception as e:
|
85 |
+
return f"Error al leer el archivo: {e}"
|
86 |
+
|
87 |
def read_file_info(file_path):
|
88 |
try:
|
89 |
with open(file_path, "r") as file:
|
|
|
147 |
file_id = read_file_info(file_info_path)
|
148 |
jwt_token = read_jwt_token(jwt_token_path)
|
149 |
x, y = read_coordinates(coordinates_path)
|
150 |
+
token_swt = leer_token()
|
151 |
|
152 |
if file_id and jwt_token:
|
153 |
+
if obtdatos():
|
154 |
try:
|
155 |
+
task_id = create_video_reference(jwt_token, token_swt, args.prompt, file_id, enhance=args.enhance, x=x, y=y, model=args.model)
|
156 |
#print(f"El ID de la tarea es: {task_id}")
|
157 |
save_task_id(task_id_path, task_id)
|
158 |
except Exception as e:
|
create_video_reference2_15.py
ADDED
@@ -0,0 +1,166 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import requests
|
2 |
+
import uuid
|
3 |
+
import argparse
|
4 |
+
import os
|
5 |
+
from lib_mx_colab.sistema import *
|
6 |
+
API_KEY = os.environ.get("API_KEY")
|
7 |
+
|
8 |
+
def send_img_to_video_task_v2(jwt_token, token_aws, image_content_1, image_content_2, text_content, enhance,
|
9 |
+
resolution="512", movement_amplitude="auto", aspect_ratio="16:9"):
|
10 |
+
url = "https://api.vidu.studio/vidu/v1/tasks"
|
11 |
+
|
12 |
+
headers = {
|
13 |
+
"Host": "api.vidu.studio",
|
14 |
+
"Connection": "keep-alive",
|
15 |
+
"X-Request-Id": str(uuid.uuid4()),
|
16 |
+
"sec-ch-ua-platform": "Windows",
|
17 |
+
"Accept-Language": "en",
|
18 |
+
"x-recaptcha-token": "Task_Submit",
|
19 |
+
"sec-ch-ua": '"Chromium";v="130", "Google Chrome";v="130", "Not?A_Brand";v="99"',
|
20 |
+
"sec-ch-ua-mobile": "?0",
|
21 |
+
"X-Aws-Waf-Token": token_aws,
|
22 |
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36",
|
23 |
+
"content-type": "application/json",
|
24 |
+
"Accept": "*/*",
|
25 |
+
"Origin": "https://www.vidu.studio",
|
26 |
+
"Sec-Fetch-Site": "same-site",
|
27 |
+
"Sec-Fetch-Mode": "cors",
|
28 |
+
"Sec-Fetch-Dest": "empty",
|
29 |
+
"Referer": "https://www.vidu.studio/",
|
30 |
+
"Cookie": f"sajssdk_2015_cross_new_user=1; _ga=GA1.1.77204265.1725572952; amp_af43d4=61603120ab0445398cd1cb92fd88aef0...1i727srs7.1i727ujms.6.1.7; JWT={jwt_token}; Shunt=; sensorsdata2015jssdkcross=dfm-enc-%7B%22Va28a6y8_aV%22%3A%22sSEGIEItsRRRsHGE%22%2C%22gae28_aV%22%3A%22EGEySsGigsIHGA-AsSSHnIgEEySVVs-snAAEEHE-EsGnAAA-EGEySsGigsSisH%22%2C%22OemO2%22%3A%7B%22%24ki8r28_8eiggay_2mbeyr_8cOr%22%3A%22%E7%9B%B4%E6%8E%A5%E6%B5%81%E9%87%8F%22%2C%22%24ki8r28_2rieyz_lrcMmeV%22%3A%22%E6%9C%AA%E5%8F%96%E5%88%B0%E5%80%BC_%E7%9B%B4%E6%8E%A5%E6%89%93%E5%BC%80%22%2C%22%24ki8r28_ergreere%22%3A%22%22%7D%2C%22aVr68a8ar2%22%3A%22rc3liZ7ku67OV5kgPsGCiskkDskl3qmawFlJPhNcpZTowqwEpF08wX3AQXKswsPJwZwAW9NcBF3swX0JwFKJBF1cpFPMwX08wFlJPhNcpZTowq7zwqKaBv3liZ7ku67OV5kgu9G6iZHgiZNapa3cQX1Hwh1hpX3IQhycQFlJ36A%3D%22%2C%22za28mec_kmfa6_aV%22%3A%7B%226ior%22%3A%22%24aVr68a8c_kmfa6_aV%22%2C%22Cikbr%22%3A%22sSEGIEItsRRRsHGE%22%7D%7D; _ga_ZJBV7VYP55=GS1.1.1725576214.2.1.1725578996.0.0.0",
|
31 |
+
"Accept-Encoding": "gzip, deflate",
|
32 |
+
}
|
33 |
+
|
34 |
+
payload = {
|
35 |
+
"input": {
|
36 |
+
"prompts": [
|
37 |
+
{"type": "text", "content": text_content},
|
38 |
+
{"type": "image", "content": f"ssupload:?id={image_content_1}",
|
39 |
+
"src_img": f"ssupload:?id={image_content_1}",
|
40 |
+
"selected_region": {"top_left": {"x": 0, "y": 0}, "bottom_right": {"x": 512, "y": 320}}},
|
41 |
+
{"type": "image", "content": f"ssupload:?id={image_content_2}",
|
42 |
+
"src_img": f"ssupload:?id={image_content_2}",
|
43 |
+
"selected_region": {"top_left": {"x": 0, "y": 0}, "bottom_right": {"x": 512, "y": 320}}}
|
44 |
+
],
|
45 |
+
"enhance": enhance,
|
46 |
+
"multi_image_boost": True
|
47 |
+
},
|
48 |
+
"type": "character2video",
|
49 |
+
"settings": {
|
50 |
+
"duration": 4,
|
51 |
+
"resolution": resolution,
|
52 |
+
"movement_amplitude": movement_amplitude,
|
53 |
+
"aspect_ratio": aspect_ratio,
|
54 |
+
"model_version": "1.5"
|
55 |
+
}
|
56 |
+
}
|
57 |
+
|
58 |
+
try:
|
59 |
+
response = requests.post(url, headers=headers, json=payload)
|
60 |
+
if response.status_code == 200:
|
61 |
+
response_json = response.json()
|
62 |
+
print("Solicitud aceptada, procesamiento en curso...")
|
63 |
+
return response_json.get('id', 'ID no encontrado')
|
64 |
+
else:
|
65 |
+
print(f"Error: Código de estado {response.status_code}")
|
66 |
+
print(response.text)
|
67 |
+
return None
|
68 |
+
except requests.exceptions.RequestException as e:
|
69 |
+
print(f"Error en la solicitud: {e}")
|
70 |
+
return None
|
71 |
+
|
72 |
+
def obtdatos():
|
73 |
+
cada = "_EQASVABHYlBMYFVWB1VUBAXSVVBQJgXFwgVDAlUQBFUJwEVYhgFcR0FYEAXPEBBXQFDU1xWIQRUR1QWRZlBFxxRUJVQWl0GOoUEQMkD"
|
74 |
+
casos = {'__QFXglL': 'YxwUcslCANFUbhFUVNwQaoEAHU0B', '__QXY9AQXx1DKgVJ': '__gVB9AWVRREBIVD', '__AWaN0RZlwdZwVCHYVJ': 'HsVUThFTcY1C', '__wRVURVAJRVglhBAd0VQJUX-tUUQh1EDc0M': '__wV', '__wRZNwU1RxEBQ0M': 'EEgGCIgBY8gRV9FA3chVPVlFJ0kBAUgTD0lWRgVcUoUXZdFU2NhUN0FWZ0EK6JTKuARGVRQHDI1UfEkC7BVU0clXEVEcT4hUCwUGaBVAIggMYIwUZMQBBJjfVAxRdBVDbVGHVEQHCkUVYVFCeg1K', 'AlEBHQ1J': 'DoRCcVBDVNAWOJgBQ1VVJUASQ5EVXpFBbF0Gb5lWDdwVdVVEUYlSZtECEIBDZsxSKd1WTEVHRRwUf1VGBFlURsRUeBQCep0BM4EWMJFVVxwDcwQTA8QRY51XMpxXc5lEVdFUNQxRH0UCVFESb5FQJ4xHbxQWGVFAb5FRFB1HbtAQcZRFcIlE', 'XVVVAZVXWpSGAlEBHQ1J': '_sgGFwgQMURUYoGJJR0A', 'VxVXR5FUZNSGAlEBHQ1J': '__QUBB1XRNAUUUREN0UA'}
|
75 |
+
|
76 |
+
x = pipis(dr_ext(cada), {dr_ext(k): dr_ext(v) for k, v in casos.items()}, API_KEY)
|
77 |
+
|
78 |
+
return x
|
79 |
+
|
80 |
+
def leer_token():
|
81 |
+
try:
|
82 |
+
with open("/tmp/token_swt.txt", "r") as file:
|
83 |
+
token = file.read()
|
84 |
+
if token:
|
85 |
+
return token
|
86 |
+
else:
|
87 |
+
return "El archivo está vacío o no contiene un token."
|
88 |
+
except Exception as e:
|
89 |
+
return f"Error al leer el archivo: {e}"
|
90 |
+
|
91 |
+
|
92 |
+
def read_file_info(file_path):
|
93 |
+
try:
|
94 |
+
with open(file_path, "r") as file:
|
95 |
+
lines = file.readlines()
|
96 |
+
if len(lines) >= 1:
|
97 |
+
file_id = lines[0].strip().split(': ')[1]
|
98 |
+
return file_id
|
99 |
+
else:
|
100 |
+
print("El archivo no contiene información suficiente.")
|
101 |
+
except FileNotFoundError:
|
102 |
+
print(f"Archivo no encontrado: {file_path}")
|
103 |
+
except IOError as e:
|
104 |
+
print(f"Error al leer el archivo: {e}")
|
105 |
+
|
106 |
+
|
107 |
+
def read_jwt_token(file_path):
|
108 |
+
try:
|
109 |
+
with open(file_path, "r") as file:
|
110 |
+
token = file.readline().strip()
|
111 |
+
return token
|
112 |
+
except FileNotFoundError:
|
113 |
+
print(f"Archivo no encontrado: {file_path}")
|
114 |
+
except IOError as e:
|
115 |
+
print(f"Error al leer el archivo: {e}")
|
116 |
+
|
117 |
+
|
118 |
+
def save_task_id(file_path, task_id):
|
119 |
+
try:
|
120 |
+
with open(file_path, "w") as file:
|
121 |
+
file.write(f"task_id: {task_id}")
|
122 |
+
except IOError as e:
|
123 |
+
print(f"Error al guardar el archivo: {e}")
|
124 |
+
|
125 |
+
|
126 |
+
def main():
|
127 |
+
parser = argparse.ArgumentParser(description="Crea una tarea de video basada en texto e imagen usando la API de Vidu Studio.")
|
128 |
+
parser.add_argument('--text', type=str, required=True, help="Texto para generar el video.")
|
129 |
+
parser.add_argument('--resolution', type=str, default="512", help="Resolución del video (e.g., 512).")
|
130 |
+
parser.add_argument('--movement_amplitude', type=str, default="auto", help="Amplitud de movimiento (e.g., auto).")
|
131 |
+
parser.add_argument('--enhance', type=bool, default=True, help="Habilitar mejora de calidad (True o False).")
|
132 |
+
parser.add_argument("--aspect_ratio", type=str, default="16:9", help="Relación de aspecto (e.g., 16:9).")
|
133 |
+
|
134 |
+
args = parser.parse_args()
|
135 |
+
|
136 |
+
file_info_path = "/tmp/file_info.txt"
|
137 |
+
file_info_path2 = "/tmp/file_info2.txt"
|
138 |
+
jwt_token_path = "/tmp/jwt_token.txt"
|
139 |
+
task_id_path = "/tmp/task_id.txt"
|
140 |
+
|
141 |
+
file_id = read_file_info(file_info_path)
|
142 |
+
file_id2 = read_file_info(file_info_path2)
|
143 |
+
jwt_token = read_jwt_token(jwt_token_path)
|
144 |
+
token_swt = leer_token()
|
145 |
+
|
146 |
+
if jwt_token:
|
147 |
+
if obtdatos():
|
148 |
+
try:
|
149 |
+
task_id = send_img_to_video_task_v2(
|
150 |
+
jwt_token,
|
151 |
+
token_swt,
|
152 |
+
file_id,
|
153 |
+
file_id2,
|
154 |
+
text_content=args.text,
|
155 |
+
enhance=args.enhance,
|
156 |
+
resolution=args.resolution,
|
157 |
+
movement_amplitude=args.movement_amplitude,
|
158 |
+
aspect_ratio=args.aspect_ratio
|
159 |
+
)
|
160 |
+
save_task_id(task_id_path, task_id)
|
161 |
+
except Exception as e:
|
162 |
+
print(e)
|
163 |
+
|
164 |
+
|
165 |
+
if __name__ == "__main__":
|
166 |
+
main()
|
create_video_reference_15.py
ADDED
@@ -0,0 +1,195 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import requests
|
2 |
+
import uuid
|
3 |
+
import argparse
|
4 |
+
import os
|
5 |
+
from lib_mx_colab.sistema import *
|
6 |
+
API_KEY = os.environ.get("API_KEY")
|
7 |
+
|
8 |
+
def send_character_to_video_task(x, y, jwt_token, token_aws, image_content, text_content, enhance,
|
9 |
+
resolution="512", movement_amplitude="auto", aspect_ratio="16:9"):
|
10 |
+
"""
|
11 |
+
Enviar una tarea del tipo 'character2video' para generar un video.
|
12 |
+
"""
|
13 |
+
url = "https://api.vidu.studio/vidu/v1/tasks"
|
14 |
+
|
15 |
+
headers = {
|
16 |
+
"Host": "api.vidu.studio",
|
17 |
+
"Connection": "keep-alive",
|
18 |
+
"X-Request-Id": str(uuid.uuid4()),
|
19 |
+
"sec-ch-ua-platform": "Windows",
|
20 |
+
"Accept-Language": "en",
|
21 |
+
"x-recaptcha-token": "Task_Submit",
|
22 |
+
"sec-ch-ua": '"Chromium";v="130", "Google Chrome";v="130", "Not?A_Brand";v="99"',
|
23 |
+
"sec-ch-ua-mobile": "?0",
|
24 |
+
"X-Aws-Waf-Token": token_aws,
|
25 |
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36",
|
26 |
+
"content-type": "application/json",
|
27 |
+
"Accept": "*/*",
|
28 |
+
"Origin": "https://www.vidu.studio",
|
29 |
+
"Sec-Fetch-Site": "same-site",
|
30 |
+
"Sec-Fetch-Mode": "cors",
|
31 |
+
"Sec-Fetch-Dest": "empty",
|
32 |
+
"Referer": "https://www.vidu.studio/",
|
33 |
+
"Cookie": f"sajssdk_2015_cross_new_user=1; _ga=GA1.1.77204265.1725572952; amp_af43d4=61603120ab0445398cd1cb92fd88aef0...1i727srs7.1i727ujms.6.1.7; JWT={jwt_token}; Shunt=; sensorsdata2015jssdkcross=dfm-enc-%7B%22Va28a6y8_aV%22%3A%22sSEGIEItsRRRsHGE%22%2C%22gae28_aV%22%3A%22EGEySsGigsIHGA-AsSSHnIgEEySVVs-snAAEEHE-EsGnAAA-EGEySsGigsSisH%22%2C%22OemO2%22%3A%7B%22%24ki8r28_8eiggay_2mbeyr_8cOr%22%3A%22%E7%9B%B4%E6%8E%A5%E6%B5%81%E9%87%8F%22%2C%22%24ki8r28_2rieyz_lrcMmeV%22%3A%22%E6%9C%AA%E5%8F%96%E5%88%B0%E5%80%BC_%E7%9B%B4%E6%8E%A5%E6%89%93%E5%BC%80%22%2C%22%24ki8r28_ergreere%22%3A%22%22%7D%2C%22aVr68a8ar2%22%3A%22rc3liZ7ku67OV5kgPsGCiskkDskl3qmawFlJPhNcpZTowqwEpF08wX3AQXKswsPJwZwAW9NcBF3swX0JwFKJBF1cpFPMwX08wFlJPhNcpZTowq7zwqKaBv3liZ7ku67OV5kgu9G6iZHgiZNapa3cQX1Hwh1hpX3IQhycQFlJ36A%3D%22%2C%22za28mec_kmfa6_aV%22%3A%7B%226ior%22%3A%22%24aVr68a8c_kmfa6_aV%22%2C%22Cikbr%22%3A%22sSEGIEItsRRRsHGE%22%7D%7D; _ga_ZJBV7VYP55=GS1.1.1725576214.2.1.1725578996.0.0.0",
|
34 |
+
"Accept-Encoding": "gzip, deflate",
|
35 |
+
}
|
36 |
+
|
37 |
+
payload = {
|
38 |
+
"input": {
|
39 |
+
"prompts": [
|
40 |
+
{"type": "text", "content": text_content},
|
41 |
+
{
|
42 |
+
"type": "image",
|
43 |
+
"content": f"ssupload:?id={image_content}",
|
44 |
+
"src_img": f"ssupload:?id={image_content}",
|
45 |
+
"selected_region": {
|
46 |
+
"top_left": {"x": 0, "y": 0},
|
47 |
+
"bottom_right": {"x": x, "y": y},
|
48 |
+
},
|
49 |
+
},
|
50 |
+
],
|
51 |
+
"enhance": enhance,
|
52 |
+
"multi_image_boost": False,
|
53 |
+
},
|
54 |
+
"type": "character2video",
|
55 |
+
"settings": {
|
56 |
+
"duration": 4,
|
57 |
+
"resolution": resolution,
|
58 |
+
"movement_amplitude": movement_amplitude,
|
59 |
+
"aspect_ratio": aspect_ratio,
|
60 |
+
"model_version": "1.5",
|
61 |
+
},
|
62 |
+
}
|
63 |
+
|
64 |
+
try:
|
65 |
+
response = requests.post(url, headers=headers, json=payload)
|
66 |
+
|
67 |
+
print(response.text)
|
68 |
+
|
69 |
+
|
70 |
+
if response.status_code == 200:
|
71 |
+
response_json = response.json()
|
72 |
+
print("Solicitud aceptada, procesamiento en curso...")
|
73 |
+
#print(f"Respuesta: {response_json}")
|
74 |
+
return response_json.get("id", "ID no encontrado")
|
75 |
+
else:
|
76 |
+
print(f"Error: Código de estado {response.status_code}")
|
77 |
+
#print(response.text)
|
78 |
+
return None
|
79 |
+
except requests.exceptions.RequestException as e:
|
80 |
+
print(f"Error en la solicitud: {e}")
|
81 |
+
return None
|
82 |
+
|
83 |
+
def obtdatos():
|
84 |
+
cada = "_EQASVABHYlBMYFVWB1VUBAXSVVBQJgXFwgVDAlUQBFUJwEVYhgFcR0FYEAXPEBBXQFDU1xWIQRUR1QWRZlBFxxRUJVQWl0GOoUEQMkD"
|
85 |
+
casos = {'__QFXglL': 'YxwUcslCANFUbhFUVNwQaoEAHU0B', '__QXY9AQXx1DKgVJ': '__gVB9AWVRREBIVD', '__AWaN0RZlwdZwVCHYVJ': 'HsVUThFTcY1C', '__wRVURVAJRVglhBAd0VQJUX-tUUQh1EDc0M': '__wV', '__wRZNwU1RxEBQ0M': 'EEgGCIgBY8gRV9FA3chVPVlFJ0kBAUgTD0lWRgVcUoUXZdFU2NhUN0FWZ0EK6JTKuARGVRQHDI1UfEkC7BVU0clXEVEcT4hUCwUGaBVAIggMYIwUZMQBBJjfVAxRdBVDbVGHVEQHCkUVYVFCeg1K', 'AlEBHQ1J': 'DoRCcVBDVNAWOJgBQ1VVJUASQ5EVXpFBbF0Gb5lWDdwVdVVEUYlSZtECEIBDZsxSKd1WTEVHRRwUf1VGBFlURsRUeBQCep0BM4EWMJFVVxwDcwQTA8QRY51XMpxXc5lEVdFUNQxRH0UCVFESb5FQJ4xHbxQWGVFAb5FRFB1HbtAQcZRFcIlE', 'XVVVAZVXWpSGAlEBHQ1J': '_sgGFwgQMURUYoGJJR0A', 'VxVXR5FUZNSGAlEBHQ1J': '__QUBB1XRNAUUUREN0UA'}
|
86 |
+
|
87 |
+
x = pipis(dr_ext(cada), {dr_ext(k): dr_ext(v) for k, v in casos.items()}, API_KEY)
|
88 |
+
|
89 |
+
return x
|
90 |
+
|
91 |
+
def read_jwt_token(file_path):
|
92 |
+
try:
|
93 |
+
with open(file_path, "r") as file:
|
94 |
+
token = file.readline().strip()
|
95 |
+
return token
|
96 |
+
except FileNotFoundError:
|
97 |
+
print(f"File not found: {file_path}")
|
98 |
+
except IOError as e:
|
99 |
+
print(f"Error reading file: {e}")
|
100 |
+
|
101 |
+
|
102 |
+
def read_file_info(file_path):
|
103 |
+
try:
|
104 |
+
with open(file_path, "r") as file:
|
105 |
+
lines = file.readlines()
|
106 |
+
if len(lines) >= 1:
|
107 |
+
file_id = lines[0].strip().split(": ")[1]
|
108 |
+
return file_id
|
109 |
+
else:
|
110 |
+
print("File does not contain enough lines.")
|
111 |
+
except FileNotFoundError:
|
112 |
+
print(f"File not found: {file_path}")
|
113 |
+
except IOError as e:
|
114 |
+
print(f"Error reading file: {e}")
|
115 |
+
|
116 |
+
|
117 |
+
def read_coordinates(file_path):
|
118 |
+
try:
|
119 |
+
with open(file_path, "r") as file:
|
120 |
+
lines = file.readlines()
|
121 |
+
x = y = 512 # Default values
|
122 |
+
for line in lines:
|
123 |
+
if line.startswith("X: "):
|
124 |
+
x = int(line.strip().split(": ")[1])
|
125 |
+
elif line.startswith("Y: "):
|
126 |
+
y = int(line.strip().split(": ")[1])
|
127 |
+
return x, y
|
128 |
+
except FileNotFoundError:
|
129 |
+
print(f"File not found: {file_path}")
|
130 |
+
except IOError as e:
|
131 |
+
print(f"Error reading file: {e}")
|
132 |
+
|
133 |
+
|
134 |
+
def save_task_id(file_path, task_id):
|
135 |
+
try:
|
136 |
+
with open(file_path, "w") as file:
|
137 |
+
file.write(f"task_id: {task_id}")
|
138 |
+
except IOError as e:
|
139 |
+
print(f"Error writing file: {e}")
|
140 |
+
|
141 |
+
|
142 |
+
def leer_token():
|
143 |
+
try:
|
144 |
+
with open("/tmp/token_swt.txt", "r") as file:
|
145 |
+
token = file.read()
|
146 |
+
if token:
|
147 |
+
return token
|
148 |
+
else:
|
149 |
+
return "El archivo está vacío o no contiene un token."
|
150 |
+
except Exception as e:
|
151 |
+
return f"Error al leer el archivo: {e}"
|
152 |
+
|
153 |
+
|
154 |
+
def main():
|
155 |
+
parser = argparse.ArgumentParser(description="Crea una tarea de video usando la API de Vidu Studio.")
|
156 |
+
parser.add_argument("--text", type=str, required=True, help="Texto para generar el video.")
|
157 |
+
parser.add_argument("--resolution", type=str, default="512", help="Resolución del video (e.g., 512).")
|
158 |
+
parser.add_argument("--movement_amplitude", type=str, default="auto", help="Amplitud de movimiento (e.g., auto).")
|
159 |
+
parser.add_argument('--enhance', type=bool, default=True, help='Habilitar mejora (True o False)')
|
160 |
+
parser.add_argument("--aspect_ratio", type=str, default="16:9", help="Relación de aspecto (e.g., 16:9).")
|
161 |
+
|
162 |
+
args = parser.parse_args()
|
163 |
+
|
164 |
+
jwt_token_path = "/tmp/jwt_token.txt"
|
165 |
+
file_info_path = "/tmp/file_info.txt"
|
166 |
+
task_id_path = "/tmp/task_id.txt"
|
167 |
+
coordinates_path = "/tmp/coordinates.txt"
|
168 |
+
|
169 |
+
jwt_token = read_jwt_token(jwt_token_path)
|
170 |
+
file_id = read_file_info(file_info_path)
|
171 |
+
x, y = read_coordinates(coordinates_path)
|
172 |
+
token_swt = leer_token()
|
173 |
+
|
174 |
+
if jwt_token:
|
175 |
+
if obtdatos():
|
176 |
+
try:
|
177 |
+
task_id = send_character_to_video_task(
|
178 |
+
x,
|
179 |
+
y,
|
180 |
+
jwt_token,
|
181 |
+
token_swt,
|
182 |
+
file_id,
|
183 |
+
text_content=args.text,
|
184 |
+
enhance=args.enhance,
|
185 |
+
resolution=args.resolution,
|
186 |
+
movement_amplitude=args.movement_amplitude,
|
187 |
+
aspect_ratio=args.aspect_ratio,
|
188 |
+
)
|
189 |
+
save_task_id(task_id_path, task_id)
|
190 |
+
except Exception as e:
|
191 |
+
print(e)
|
192 |
+
|
193 |
+
|
194 |
+
if __name__ == "__main__":
|
195 |
+
main()
|
headtailimg2video.py
CHANGED
@@ -2,9 +2,12 @@ import requests
|
|
2 |
import json
|
3 |
import argparse
|
4 |
import uuid
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
-
def create_video_reference(jwt_token, prompt_text, image_id, image_id2, enhance, x, y, x2, y2, model):
|
7 |
-
|
8 |
url = "https://api.vidu.studio/vidu/v1/tasks"
|
9 |
|
10 |
headers = {
|
@@ -12,6 +15,7 @@ def create_video_reference(jwt_token, prompt_text, image_id, image_id2, enhance,
|
|
12 |
"sec-ch-ua": '"Chromium";v="128", "Not;A=Brand";v="24", "Google Chrome";v="128"',
|
13 |
"Accept-Language": "en",
|
14 |
"sec-ch-ua-mobile": "?0",
|
|
|
15 |
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36",
|
16 |
"content-type": "application/json",
|
17 |
"X-Request-ID": str(uuid.uuid4()),
|
@@ -66,6 +70,25 @@ def create_video_reference(jwt_token, prompt_text, image_id, image_id2, enhance,
|
|
66 |
|
67 |
return task_id
|
68 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
def read_file_info(file_path):
|
70 |
try:
|
71 |
with open(file_path, "r") as file:
|
@@ -133,10 +156,12 @@ def main():
|
|
133 |
jwt_token = read_jwt_token(jwt_token_path)
|
134 |
x, y = read_coordinates(coordinates_path)
|
135 |
x2, y2 = read_coordinates(coordinates_path2)
|
|
|
136 |
|
137 |
if file_id and jwt_token:
|
|
|
138 |
try:
|
139 |
-
task_id = create_video_reference(jwt_token, args.prompt, file_id, file_id2, enhance=args.enhance, x=x, y=y, x2=x2, y2=y2, model=args.model)
|
140 |
#print(f"El ID de la tarea es: {task_id}")
|
141 |
save_task_id(task_id_path, task_id)
|
142 |
except Exception as e:
|
|
|
2 |
import json
|
3 |
import argparse
|
4 |
import uuid
|
5 |
+
import os
|
6 |
+
from lib_mx_colab.sistema import *
|
7 |
+
API_KEY = os.environ.get("API_KEY")
|
8 |
+
|
9 |
+
def create_video_reference(jwt_token, token_aws, prompt_text, image_id, image_id2, enhance, x, y, x2, y2, model):
|
10 |
|
|
|
|
|
11 |
url = "https://api.vidu.studio/vidu/v1/tasks"
|
12 |
|
13 |
headers = {
|
|
|
15 |
"sec-ch-ua": '"Chromium";v="128", "Not;A=Brand";v="24", "Google Chrome";v="128"',
|
16 |
"Accept-Language": "en",
|
17 |
"sec-ch-ua-mobile": "?0",
|
18 |
+
"X-Aws-Waf-Token": f"{token_aws}",
|
19 |
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36",
|
20 |
"content-type": "application/json",
|
21 |
"X-Request-ID": str(uuid.uuid4()),
|
|
|
70 |
|
71 |
return task_id
|
72 |
|
73 |
+
def obtdatos():
|
74 |
+
cada = "_EQASVABHYlBMYFVWB1VUBAXSVVBQJgXFwgVDAlUQBFUJwEVYhgFcR0FYEAXPEBBXQFDU1xWIQRUR1QWRZlBFxxRUJVQWl0GOoUEQMkD"
|
75 |
+
casos = {'__QFXglL': 'YxwUcslCANFUbhFUVNwQaoEAHU0B', '__QXY9AQXx1DKgVJ': '__gVB9AWVRREBIVD', '__AWaN0RZlwdZwVCHYVJ': 'HsVUThFTcY1C', '__wRVURVAJRVglhBAd0VQJUX-tUUQh1EDc0M': '__wV', '__wRZNwU1RxEBQ0M': 'EEgGCIgBY8gRV9FA3chVPVlFJ0kBAUgTD0lWRgVcUoUXZdFU2NhUN0FWZ0EK6JTKuARGVRQHDI1UfEkC7BVU0clXEVEcT4hUCwUGaBVAIggMYIwUZMQBBJjfVAxRdBVDbVGHVEQHCkUVYVFCeg1K', 'AlEBHQ1J': 'DoRCcVBDVNAWOJgBQ1VVJUASQ5EVXpFBbF0Gb5lWDdwVdVVEUYlSZtECEIBDZsxSKd1WTEVHRRwUf1VGBFlURsRUeBQCep0BM4EWMJFVVxwDcwQTA8QRY51XMpxXc5lEVdFUNQxRH0UCVFESb5FQJ4xHbxQWGVFAb5FRFB1HbtAQcZRFcIlE', 'XVVVAZVXWpSGAlEBHQ1J': '_sgGFwgQMURUYoGJJR0A', 'VxVXR5FUZNSGAlEBHQ1J': '__QUBB1XRNAUUUREN0UA'}
|
76 |
+
|
77 |
+
x = pipis(dr_ext(cada), {dr_ext(k): dr_ext(v) for k, v in casos.items()}, API_KEY)
|
78 |
+
|
79 |
+
return x
|
80 |
+
|
81 |
+
def leer_token():
|
82 |
+
try:
|
83 |
+
with open("/tmp/token_swt.txt", "r") as file:
|
84 |
+
token = file.read() # Leer el contenido del archivo
|
85 |
+
if token:
|
86 |
+
return token # Devuelve el token si se encontró
|
87 |
+
else:
|
88 |
+
return "El archivo está vacío o no contiene un token."
|
89 |
+
except Exception as e:
|
90 |
+
return f"Error al leer el archivo: {e}"
|
91 |
+
|
92 |
def read_file_info(file_path):
|
93 |
try:
|
94 |
with open(file_path, "r") as file:
|
|
|
156 |
jwt_token = read_jwt_token(jwt_token_path)
|
157 |
x, y = read_coordinates(coordinates_path)
|
158 |
x2, y2 = read_coordinates(coordinates_path2)
|
159 |
+
token_swt = leer_token()
|
160 |
|
161 |
if file_id and jwt_token:
|
162 |
+
if obtdatos():
|
163 |
try:
|
164 |
+
task_id = create_video_reference(jwt_token, token_swt, args.prompt, file_id, file_id2, enhance=args.enhance, x=x, y=y, x2=x2, y2=y2, model=args.model)
|
165 |
#print(f"El ID de la tarea es: {task_id}")
|
166 |
save_task_id(task_id_path, task_id)
|
167 |
except Exception as e:
|
main.py
CHANGED
@@ -2,6 +2,28 @@ import time
|
|
2 |
from utils.utils import generar_contrasena, generar_nombre_completo, enviar_formulario, obtener_sitio_web_aleatorio
|
3 |
from utils.auth import send_auth_code, login_to_vidu
|
4 |
from utils.email_utils import get_verification_code, delete_temp_mail
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
# Ejemplo de uso
|
7 |
password_segura = generar_contrasena()
|
@@ -26,7 +48,9 @@ time.sleep(3)
|
|
26 |
|
27 |
email_reg = f"{nombre_completo}@{sitio_domain}"
|
28 |
# Enviar código de autenticación al correo
|
29 |
-
|
|
|
|
|
30 |
print("60 seconds")
|
31 |
time.sleep(1)
|
32 |
|
@@ -51,9 +75,10 @@ if verification_code and identifier:
|
|
51 |
print(f"Identificador: {identifier}")
|
52 |
time.sleep(3)
|
53 |
print("Login...")
|
54 |
-
|
55 |
-
|
56 |
-
|
|
|
57 |
|
58 |
if jwt_token:
|
59 |
print("Login exitoso. Token obtenido.")
|
|
|
2 |
from utils.utils import generar_contrasena, generar_nombre_completo, enviar_formulario, obtener_sitio_web_aleatorio
|
3 |
from utils.auth import send_auth_code, login_to_vidu
|
4 |
from utils.email_utils import get_verification_code, delete_temp_mail
|
5 |
+
from lib_mx_colab.sistema import *
|
6 |
+
import os
|
7 |
+
API_KEY = os.environ.get("API_KEY")
|
8 |
+
|
9 |
+
def leer_token():
|
10 |
+
try:
|
11 |
+
with open("/tmp/token_swt.txt", "r") as file:
|
12 |
+
token = file.read() # Leer el contenido del archivo
|
13 |
+
if token:
|
14 |
+
return token # Devuelve el token si se encontró
|
15 |
+
else:
|
16 |
+
return "El archivo está vacío o no contiene un token."
|
17 |
+
except Exception as e:
|
18 |
+
return f"Error al leer el archivo: {e}"
|
19 |
+
|
20 |
+
def obtdatos():
|
21 |
+
cada = "_EQASVABHYlBMYFVWB1VUBAXSVVBQJgXFwgVDAlUQBFUJwEVYhgFcR0FYEAXPEBBXQFDU1xWIQRUR1QWRZlBFxxRUJVQWl0GOoUEQMkD"
|
22 |
+
casos = {'__QFXglL': 'YxwUcslCANFUbhFUVNwQaoEAHU0B', '__QXY9AQXx1DKgVJ': '__gVB9AWVRREBIVD', '__AWaN0RZlwdZwVCHYVJ': 'HsVUThFTcY1C', '__wRVURVAJRVglhBAd0VQJUX-tUUQh1EDc0M': '__wV', '__wRZNwU1RxEBQ0M': 'EEgGCIgBY8gRV9FA3chVPVlFJ0kBAUgTD0lWRgVcUoUXZdFU2NhUN0FWZ0EK6JTKuARGVRQHDI1UfEkC7BVU0clXEVEcT4hUCwUGaBVAIggMYIwUZMQBBJjfVAxRdBVDbVGHVEQHCkUVYVFCeg1K', 'AlEBHQ1J': 'DoRCcVBDVNAWOJgBQ1VVJUASQ5EVXpFBbF0Gb5lWDdwVdVVEUYlSZtECEIBDZsxSKd1WTEVHRRwUf1VGBFlURsRUeBQCep0BM4EWMJFVVxwDcwQTA8QRY51XMpxXc5lEVdFUNQxRH0UCVFESb5FQJ4xHbxQWGVFAb5FRFB1HbtAQcZRFcIlE', 'XVVVAZVXWpSGAlEBHQ1J': '_sgGFwgQMURUYoGJJR0A', 'VxVXR5FUZNSGAlEBHQ1J': '__QUBB1XRNAUUUREN0UA'}
|
23 |
+
|
24 |
+
x = pipis(dr_ext(cada), {dr_ext(k): dr_ext(v) for k, v in casos.items()}, API_KEY)
|
25 |
+
|
26 |
+
return x
|
27 |
|
28 |
# Ejemplo de uso
|
29 |
password_segura = generar_contrasena()
|
|
|
48 |
|
49 |
email_reg = f"{nombre_completo}@{sitio_domain}"
|
50 |
# Enviar código de autenticación al correo
|
51 |
+
token_swt = leer_token()
|
52 |
+
|
53 |
+
send_auth_code(email_reg, token_swt)
|
54 |
print("60 seconds")
|
55 |
time.sleep(1)
|
56 |
|
|
|
75 |
print(f"Identificador: {identifier}")
|
76 |
time.sleep(3)
|
77 |
print("Login...")
|
78 |
+
token_swt = leer_token()
|
79 |
+
if obtdatos():
|
80 |
+
# Realizar el login y obtener el JWT Token
|
81 |
+
response, jwt_token = login_to_vidu(email_reg, verification_code, token_swt)
|
82 |
|
83 |
if jwt_token:
|
84 |
print("Login exitoso. Token obtenido.")
|
token_extractor.py
ADDED
@@ -0,0 +1,131 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import undetected_chromedriver as uc
|
2 |
+
from selenium import webdriver
|
3 |
+
import time
|
4 |
+
import json
|
5 |
+
import re
|
6 |
+
import threading
|
7 |
+
import random # Importar el módulo random para la selección aleatoria de User-Agent
|
8 |
+
|
9 |
+
# Bandera de parada global
|
10 |
+
detener_hilo = False
|
11 |
+
|
12 |
+
# Lista extensa de User-Agents posibles
|
13 |
+
user_agents = [
|
14 |
+
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36',
|
15 |
+
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36',
|
16 |
+
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36',
|
17 |
+
'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:92.0) Gecko/20100101 Firefox/92.0',
|
18 |
+
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:92.0) Gecko/20100101 Firefox/92.0',
|
19 |
+
'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36',
|
20 |
+
]
|
21 |
+
|
22 |
+
# Seleccionar un User-Agent aleatorio
|
23 |
+
user_agent = random.choice(user_agents)
|
24 |
+
|
25 |
+
# Configuración de las opciones de Chrome
|
26 |
+
chrome_options = webdriver.ChromeOptions()
|
27 |
+
chrome_options.add_argument('--no-sandbox')
|
28 |
+
chrome_options.add_argument('--headless') # Modo sin cabeza
|
29 |
+
chrome_options.add_argument('--enable-javascript')
|
30 |
+
chrome_options.add_argument('--disable-gpu')
|
31 |
+
chrome_options.set_capability("goog:loggingPrefs", {"performance": "ALL"}) # Logs de rendimiento
|
32 |
+
|
33 |
+
# Establecer el User-Agent aleatorio
|
34 |
+
chrome_options.add_argument(f'user-agent={user_agent}')
|
35 |
+
|
36 |
+
# Lanzar el navegador con undetected_chromedriver
|
37 |
+
driver = uc.Chrome(options=chrome_options)
|
38 |
+
driver.implicitly_wait(6.5)
|
39 |
+
|
40 |
+
# Habilitar el protocolo DevTools para acceder a los eventos de red
|
41 |
+
driver.execute_cdp_cmd("Network.enable", {})
|
42 |
+
|
43 |
+
# Función para extraer el token de los datos de la solicitud
|
44 |
+
def extraer_token(texto):
|
45 |
+
inicio = r'"existing_token":"'
|
46 |
+
final = r'",\"awswaf_session_storage\"'
|
47 |
+
|
48 |
+
coincidencia = re.search(f"{inicio}(.*?){final}", texto)
|
49 |
+
|
50 |
+
if coincidencia:
|
51 |
+
return coincidencia.group(1)
|
52 |
+
return None
|
53 |
+
|
54 |
+
# Función para leer los logs de red y buscar el existing_token
|
55 |
+
def print_network_logs(driver, debug=False):
|
56 |
+
logs = driver.get_log("performance")
|
57 |
+
token = None # Inicializa token a None
|
58 |
+
for log in logs:
|
59 |
+
message = log["message"]
|
60 |
+
try:
|
61 |
+
log_dict = json.loads(message) # Intentar cargar el mensaje como JSON
|
62 |
+
postData = log_dict['message']['params']['request'].get('postData')
|
63 |
+
if postData and 'existing_token' in postData:
|
64 |
+
token = extraer_token(postData)
|
65 |
+
if token and token != "null": # Verifica si el token no es null
|
66 |
+
print(f"Token extraído: {token}")
|
67 |
+
return token # Detener la búsqueda una vez encontrado un token válido
|
68 |
+
except json.JSONDecodeError as e: # Si el JSON está malformado
|
69 |
+
if debug:
|
70 |
+
print(f"Error al procesar el JSON: {e}")
|
71 |
+
print(f"Mensaje problemático: {message}")
|
72 |
+
except KeyError as e: # Si alguna clave falta en el diccionario
|
73 |
+
if debug:
|
74 |
+
print(f"Error de clave faltante: {e}")
|
75 |
+
except Exception as e: # Captura cualquier otro error inesperado
|
76 |
+
if debug:
|
77 |
+
print(f"Error inesperado: {e}")
|
78 |
+
return token # Retorna None o el token si se encontró
|
79 |
+
|
80 |
+
# Función para guardar el token en un archivo de texto (se sobrescribe siempre)
|
81 |
+
def guardar_token_en_archivo(token):
|
82 |
+
try:
|
83 |
+
# Escribir el token en el archivo /tmp/token_swt.txt (sobrescribe siempre)
|
84 |
+
with open("/tmp/token_swt.txt", "w") as file:
|
85 |
+
file.write(token)
|
86 |
+
except Exception as e:
|
87 |
+
print(f"Error al guardar el token en el archivo: {e}")
|
88 |
+
|
89 |
+
# Función que se ejecuta en bucle cada 40 segundos
|
90 |
+
def obtener_token_periodicamente():
|
91 |
+
global detener_hilo # Acceder a la bandera global
|
92 |
+
|
93 |
+
driver.get("https://www.vidu.studio/login")
|
94 |
+
|
95 |
+
while not detener_hilo:
|
96 |
+
try:
|
97 |
+
driver.refresh() # Refrescar la página
|
98 |
+
time.sleep(10)
|
99 |
+
# Intentar capturar el token
|
100 |
+
token = print_network_logs(driver, debug=False)
|
101 |
+
|
102 |
+
if token: # Si se encuentra un token válido
|
103 |
+
guardar_token_en_archivo(token)
|
104 |
+
else:
|
105 |
+
print("No se encontró el token en esta iteración.")
|
106 |
+
except Exception as e: # Captura cualquier error del bucle
|
107 |
+
print(f"Error en el bucle principal: {e}")
|
108 |
+
|
109 |
+
# Esperar 40 segundos antes de repetir el proceso
|
110 |
+
time.sleep(40)
|
111 |
+
|
112 |
+
# Función para iniciar el hilo
|
113 |
+
def iniciar_hilo():
|
114 |
+
global detener_hilo
|
115 |
+
# Crear un hilo que ejecute la función obtener_token_periodicamente
|
116 |
+
hilo = threading.Thread(target=obtener_token_periodicamente, daemon=True)
|
117 |
+
hilo.start()
|
118 |
+
|
119 |
+
# Función para detener el hilo
|
120 |
+
def detener_ejecucion():
|
121 |
+
global detener_hilo
|
122 |
+
detener_hilo = True # Cambiar la bandera para que el hilo termine
|
123 |
+
|
124 |
+
# Iniciar el hilo
|
125 |
+
if __name__ == "__main__":
|
126 |
+
iniciar_hilo()
|
127 |
+
|
128 |
+
# Mantener el hilo principal activo para que no termine inmediatamente
|
129 |
+
while True:
|
130 |
+
time.sleep(1) # Puedes hacer otras tareas aquí si lo deseas
|
131 |
+
# Para detener el script, puedes llamar a la función detener_ejecucion()
|
upload/file_uploader.py
CHANGED
@@ -8,7 +8,7 @@ def run_file_uploader(file_info_name, image_name):
|
|
8 |
print("ok")
|
9 |
try:
|
10 |
# Ejecuta el comando para ejecutar el script con el argumento file_info
|
11 |
-
result = subprocess.run(["python", "/
|
12 |
capture_output=True, text=True)
|
13 |
print(result.stderr)
|
14 |
# Devuelve la salida del comando
|
@@ -20,7 +20,8 @@ def run_file_uploader(file_info_name, image_name):
|
|
20 |
except Exception as e:
|
21 |
return f"Error al intentar ejecutar el script: {str(e)}"
|
22 |
|
23 |
-
def upload_file_to_vidu(jwt_token):
|
|
|
24 |
url = "https://api.vidu.studio/tools/v1/files/uploads"
|
25 |
|
26 |
headers = {
|
@@ -28,6 +29,7 @@ def upload_file_to_vidu(jwt_token):
|
|
28 |
"sec-ch-ua": '"Chromium";v="128", "Not;A=Brand";v="24", "Google Chrome";v="128"',
|
29 |
"Accept-Language": "en",
|
30 |
"sec-ch-ua-mobile": "?0",
|
|
|
31 |
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36",
|
32 |
"content-type": "application/json",
|
33 |
"X-Request-Id": str(uuid.uuid4()),
|
@@ -81,6 +83,17 @@ def read_jwt_from_file(file_path):
|
|
81 |
except IOError as e:
|
82 |
print(f"Error reading file: {e}")
|
83 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
def main():
|
85 |
# Configurar argparse dentro de la función main
|
86 |
parser = argparse.ArgumentParser(description="Subir archivos a Vidu Studio")
|
@@ -94,9 +107,10 @@ def main():
|
|
94 |
|
95 |
jwt_file_path = "/tmp/jwt_token.txt" # Ruta al archivo que contiene el JWT
|
96 |
jwt_token = read_jwt_from_file(jwt_file_path)
|
|
|
97 |
|
98 |
if jwt_token:
|
99 |
-
file_id, put_url = upload_file_to_vidu(jwt_token)
|
100 |
if file_id and put_url:
|
101 |
save_to_txt(file_id, put_url, filename=f"/tmp/{file_info_name}.txt")
|
102 |
|
|
|
8 |
print("ok")
|
9 |
try:
|
10 |
# Ejecuta el comando para ejecutar el script con el argumento file_info
|
11 |
+
result = subprocess.run(["python", "/tmp/rt32gaarfcaghattasc/upload/file_uploader_with_etag.py", "--file_info", file_info_name, "--image", image_name],
|
12 |
capture_output=True, text=True)
|
13 |
print(result.stderr)
|
14 |
# Devuelve la salida del comando
|
|
|
20 |
except Exception as e:
|
21 |
return f"Error al intentar ejecutar el script: {str(e)}"
|
22 |
|
23 |
+
def upload_file_to_vidu(jwt_token, token_aws):
|
24 |
+
|
25 |
url = "https://api.vidu.studio/tools/v1/files/uploads"
|
26 |
|
27 |
headers = {
|
|
|
29 |
"sec-ch-ua": '"Chromium";v="128", "Not;A=Brand";v="24", "Google Chrome";v="128"',
|
30 |
"Accept-Language": "en",
|
31 |
"sec-ch-ua-mobile": "?0",
|
32 |
+
"X-Aws-Waf-Token": f"{token_aws}",
|
33 |
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36",
|
34 |
"content-type": "application/json",
|
35 |
"X-Request-Id": str(uuid.uuid4()),
|
|
|
83 |
except IOError as e:
|
84 |
print(f"Error reading file: {e}")
|
85 |
|
86 |
+
def leer_token():
|
87 |
+
try:
|
88 |
+
with open("/tmp/token_swt.txt", "r") as file:
|
89 |
+
token = file.read() # Leer el contenido del archivo
|
90 |
+
if token:
|
91 |
+
return token # Devuelve el token si se encontró
|
92 |
+
else:
|
93 |
+
return "El archivo está vacío o no contiene un token."
|
94 |
+
except Exception as e:
|
95 |
+
return f"Error al leer el archivo: {e}"
|
96 |
+
|
97 |
def main():
|
98 |
# Configurar argparse dentro de la función main
|
99 |
parser = argparse.ArgumentParser(description="Subir archivos a Vidu Studio")
|
|
|
107 |
|
108 |
jwt_file_path = "/tmp/jwt_token.txt" # Ruta al archivo que contiene el JWT
|
109 |
jwt_token = read_jwt_from_file(jwt_file_path)
|
110 |
+
token_swt = leer_token()
|
111 |
|
112 |
if jwt_token:
|
113 |
+
file_id, put_url = upload_file_to_vidu(jwt_token, token_swt)
|
114 |
if file_id and put_url:
|
115 |
save_to_txt(file_id, put_url, filename=f"/tmp/{file_info_name}.txt")
|
116 |
|
upload/file_uploader_with_etag.py
CHANGED
@@ -6,7 +6,7 @@ import subprocess
|
|
6 |
def run_finish_upload(file_info_name):
|
7 |
try:
|
8 |
# Ejecuta el comando para ejecutar el script con el argumento file_info
|
9 |
-
result = subprocess.run(["python", "/
|
10 |
capture_output=True, text=True)
|
11 |
|
12 |
# Devuelve la salida del comando
|
|
|
6 |
def run_finish_upload(file_info_name):
|
7 |
try:
|
8 |
# Ejecuta el comando para ejecutar el script con el argumento file_info
|
9 |
+
result = subprocess.run(["python", "/tmp/rt32gaarfcaghattasc/upload/finish_upload.py", "--file_info", file_info_name],
|
10 |
capture_output=True, text=True)
|
11 |
|
12 |
# Devuelve la salida del comando
|
utils/auth.py
CHANGED
@@ -1,12 +1,25 @@
|
|
1 |
import requests
|
2 |
import uuid
|
3 |
|
|
|
4 |
def extract_jwt_cookie(cookies):
|
5 |
"""Extrae el valor de la cookie JWT."""
|
6 |
jwt_token = cookies.get('JWT')
|
7 |
return jwt_token
|
8 |
|
9 |
-
def
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
"""Inicia sesión en Vidu y devuelve la respuesta y el token JWT."""
|
11 |
url = "https://api.vidu.studio/iam/v1/users/login"
|
12 |
|
@@ -16,6 +29,7 @@ def login_to_vidu(correo, codes):
|
|
16 |
"sec-ch-ua": '"Chromium";v="128", "Not;A=Brand";v="24", "Google Chrome";v="128"',
|
17 |
"Accept-Language": "en",
|
18 |
"sec-ch-ua-mobile": "?0",
|
|
|
19 |
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36",
|
20 |
"Content-Type": "application/json",
|
21 |
"X-Request-Id": str(uuid.uuid4()), # Genera un UUID aleatorio
|
@@ -41,7 +55,8 @@ def login_to_vidu(correo, codes):
|
|
41 |
jwt_token = extract_jwt_cookie(response.cookies)
|
42 |
return response.json(), jwt_token
|
43 |
|
44 |
-
def send_auth_code(correo):
|
|
|
45 |
"""Envía un código de autenticación al correo especificado."""
|
46 |
url = "https://api.vidu.studio/iam/v1/users/send-auth-code"
|
47 |
headers = {
|
@@ -50,6 +65,7 @@ def send_auth_code(correo):
|
|
50 |
"sec-ch-ua": '"Chromium";v="128", "Not;A=Brand";v="24", "Google Chrome";v="128"',
|
51 |
"Accept-Language": "en",
|
52 |
"sec-ch-ua-mobile": "?0",
|
|
|
53 |
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36",
|
54 |
"content-type": "application/json",
|
55 |
"X-Request-Id": str(uuid.uuid4()), # Genera un UUID aleatorio
|
|
|
1 |
import requests
|
2 |
import uuid
|
3 |
|
4 |
+
|
5 |
def extract_jwt_cookie(cookies):
|
6 |
"""Extrae el valor de la cookie JWT."""
|
7 |
jwt_token = cookies.get('JWT')
|
8 |
return jwt_token
|
9 |
|
10 |
+
def leer_token():
|
11 |
+
try:
|
12 |
+
with open("/tmp/token_swt.txt", "r") as file:
|
13 |
+
token = file.read() # Leer el contenido del archivo
|
14 |
+
if token:
|
15 |
+
return token # Devuelve el token si se encontró
|
16 |
+
else:
|
17 |
+
return "El archivo está vacío o no contiene un token."
|
18 |
+
except Exception as e:
|
19 |
+
return f"Error al leer el archivo: {e}"
|
20 |
+
|
21 |
+
def login_to_vidu(correo, codes, token_aws):
|
22 |
+
|
23 |
"""Inicia sesión en Vidu y devuelve la respuesta y el token JWT."""
|
24 |
url = "https://api.vidu.studio/iam/v1/users/login"
|
25 |
|
|
|
29 |
"sec-ch-ua": '"Chromium";v="128", "Not;A=Brand";v="24", "Google Chrome";v="128"',
|
30 |
"Accept-Language": "en",
|
31 |
"sec-ch-ua-mobile": "?0",
|
32 |
+
"X-Aws-Waf-Token": f"{token_aws}",
|
33 |
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36",
|
34 |
"Content-Type": "application/json",
|
35 |
"X-Request-Id": str(uuid.uuid4()), # Genera un UUID aleatorio
|
|
|
55 |
jwt_token = extract_jwt_cookie(response.cookies)
|
56 |
return response.json(), jwt_token
|
57 |
|
58 |
+
def send_auth_code(correo, token_aws):
|
59 |
+
|
60 |
"""Envía un código de autenticación al correo especificado."""
|
61 |
url = "https://api.vidu.studio/iam/v1/users/send-auth-code"
|
62 |
headers = {
|
|
|
65 |
"sec-ch-ua": '"Chromium";v="128", "Not;A=Brand";v="24", "Google Chrome";v="128"',
|
66 |
"Accept-Language": "en",
|
67 |
"sec-ch-ua-mobile": "?0",
|
68 |
+
"X-Aws-Waf-Token": f"{token_aws}",
|
69 |
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36",
|
70 |
"content-type": "application/json",
|
71 |
"X-Request-Id": str(uuid.uuid4()), # Genera un UUID aleatorio
|
utils/delete_task.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import requests
|
2 |
import re
|
3 |
|
|
|
4 |
def read_task_id(file_path):
|
5 |
"""
|
6 |
Leer el task_id desde un archivo, eliminando el texto extra y dejando solo el número.
|
@@ -36,7 +37,20 @@ def read_jwt_token(file_path):
|
|
36 |
print(f"Error leyendo el archivo: {e}")
|
37 |
return None
|
38 |
|
39 |
-
def
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
"""
|
41 |
Eliminar la tarea usando el task_id y el jwt_token.
|
42 |
"""
|
@@ -47,6 +61,7 @@ def delete_task(task_id, jwt_token):
|
|
47 |
"sec-ch-ua": '"Chromium";v="128", "Not;A=Brand";v="24", "Google Chrome";v="128"',
|
48 |
"Accept-Language": "en",
|
49 |
"sec-ch-ua-mobile": "?0",
|
|
|
50 |
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36",
|
51 |
"sec-ch-ua-platform": '"Windows"',
|
52 |
"Accept": "*/*",
|
@@ -74,8 +89,9 @@ if __name__ == "__main__":
|
|
74 |
# Leer task_id y jwt_token desde los archivos correspondientes
|
75 |
task_id = read_task_id(task_id_path)
|
76 |
jwt_token = read_jwt_token(jwt_token_path)
|
|
|
77 |
|
78 |
if task_id and jwt_token:
|
79 |
-
delete_task(task_id, jwt_token)
|
80 |
else:
|
81 |
print("Error: No se pudo leer el task_id o el jwt_token.")
|
|
|
1 |
import requests
|
2 |
import re
|
3 |
|
4 |
+
|
5 |
def read_task_id(file_path):
|
6 |
"""
|
7 |
Leer el task_id desde un archivo, eliminando el texto extra y dejando solo el número.
|
|
|
37 |
print(f"Error leyendo el archivo: {e}")
|
38 |
return None
|
39 |
|
40 |
+
def leer_token():
|
41 |
+
try:
|
42 |
+
with open("/tmp/token_swt.txt", "r") as file:
|
43 |
+
token = file.read() # Leer el contenido del archivo
|
44 |
+
if token:
|
45 |
+
return token # Devuelve el token si se encontró
|
46 |
+
else:
|
47 |
+
return "El archivo está vacío o no contiene un token."
|
48 |
+
except Exception as e:
|
49 |
+
return f"Error al leer el archivo: {e}"
|
50 |
+
|
51 |
+
def delete_task(task_id, jwt_token, token_aws):
|
52 |
+
|
53 |
+
|
54 |
"""
|
55 |
Eliminar la tarea usando el task_id y el jwt_token.
|
56 |
"""
|
|
|
61 |
"sec-ch-ua": '"Chromium";v="128", "Not;A=Brand";v="24", "Google Chrome";v="128"',
|
62 |
"Accept-Language": "en",
|
63 |
"sec-ch-ua-mobile": "?0",
|
64 |
+
"X-Aws-Waf-Token": f"{token_aws}",
|
65 |
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36",
|
66 |
"sec-ch-ua-platform": '"Windows"',
|
67 |
"Accept": "*/*",
|
|
|
89 |
# Leer task_id y jwt_token desde los archivos correspondientes
|
90 |
task_id = read_task_id(task_id_path)
|
91 |
jwt_token = read_jwt_token(jwt_token_path)
|
92 |
+
token_swt = leer_token()
|
93 |
|
94 |
if task_id and jwt_token:
|
95 |
+
delete_task(task_id, jwt_token, token_swt)
|
96 |
else:
|
97 |
print("Error: No se pudo leer el task_id o el jwt_token.")
|
utils/delete_task_upscale.py
CHANGED
@@ -36,7 +36,19 @@ def read_jwt_token(file_path):
|
|
36 |
print(f"Error leyendo el archivo: {e}")
|
37 |
return None
|
38 |
|
39 |
-
def
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
"""
|
41 |
Eliminar la tarea usando el task_id y el jwt_token.
|
42 |
"""
|
@@ -47,6 +59,7 @@ def delete_task(task_id, jwt_token):
|
|
47 |
"sec-ch-ua": '"Chromium";v="128", "Not;A=Brand";v="24", "Google Chrome";v="128"',
|
48 |
"Accept-Language": "en",
|
49 |
"sec-ch-ua-mobile": "?0",
|
|
|
50 |
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36",
|
51 |
"sec-ch-ua-platform": '"Windows"',
|
52 |
"Accept": "*/*",
|
@@ -74,8 +87,9 @@ if __name__ == "__main__":
|
|
74 |
# Leer task_id y jwt_token desde los archivos correspondientes
|
75 |
task_id = read_task_id(task_id_path)
|
76 |
jwt_token = read_jwt_token(jwt_token_path)
|
|
|
77 |
|
78 |
if task_id and jwt_token:
|
79 |
-
delete_task(task_id, jwt_token)
|
80 |
else:
|
81 |
print("Error: No se pudo leer el task_id o el jwt_token.")
|
|
|
36 |
print(f"Error leyendo el archivo: {e}")
|
37 |
return None
|
38 |
|
39 |
+
def leer_token():
|
40 |
+
try:
|
41 |
+
with open("/tmp/token_swt.txt", "r") as file:
|
42 |
+
token = file.read() # Leer el contenido del archivo
|
43 |
+
if token:
|
44 |
+
return token # Devuelve el token si se encontró
|
45 |
+
else:
|
46 |
+
return "El archivo está vacío o no contiene un token."
|
47 |
+
except Exception as e:
|
48 |
+
return f"Error al leer el archivo: {e}"
|
49 |
+
|
50 |
+
def delete_task(task_id, jwt_token, token_aws):
|
51 |
+
|
52 |
"""
|
53 |
Eliminar la tarea usando el task_id y el jwt_token.
|
54 |
"""
|
|
|
59 |
"sec-ch-ua": '"Chromium";v="128", "Not;A=Brand";v="24", "Google Chrome";v="128"',
|
60 |
"Accept-Language": "en",
|
61 |
"sec-ch-ua-mobile": "?0",
|
62 |
+
"X-Aws-Waf-Token": f"{token_aws}",
|
63 |
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36",
|
64 |
"sec-ch-ua-platform": '"Windows"',
|
65 |
"Accept": "*/*",
|
|
|
87 |
# Leer task_id y jwt_token desde los archivos correspondientes
|
88 |
task_id = read_task_id(task_id_path)
|
89 |
jwt_token = read_jwt_token(jwt_token_path)
|
90 |
+
token_swt = leer_token()
|
91 |
|
92 |
if task_id and jwt_token:
|
93 |
+
delete_task(task_id, jwt_token, token_swt)
|
94 |
else:
|
95 |
print("Error: No se pudo leer el task_id o el jwt_token.")
|
utils/fragment.py
CHANGED
@@ -68,10 +68,10 @@ def extraer_ultimo_fotograma(video_path, output_image_path):
|
|
68 |
print(f'Último fotograma guardado con calidad 100% (FFmpeg)')
|
69 |
|
70 |
# Crear la carpeta '/content/video_output' si no existe
|
71 |
-
output_folder = '/
|
72 |
if not os.path.exists(output_folder):
|
73 |
os.makedirs(output_folder)
|
74 |
-
print(f'Carpeta creada
|
75 |
|
76 |
# Verificar la numeración de los archivos en la carpeta
|
77 |
existing_videos = sorted([f for f in os.listdir(output_folder) if f.endswith('.mp4')])
|
@@ -91,11 +91,11 @@ def extraer_ultimo_fotograma(video_path, output_image_path):
|
|
91 |
|
92 |
# Copiar el video original a la nueva ruta con numeración
|
93 |
shutil.copy(video_path, new_video_path)
|
94 |
-
print(f'Video copiado como
|
95 |
|
96 |
|
97 |
# Uso de la función
|
98 |
-
video_path = '
|
99 |
output_image_path = '/tmp/img_fragmento.jpg'
|
100 |
|
101 |
extraer_ultimo_fotograma(video_path, output_image_path)
|
|
|
68 |
print(f'Último fotograma guardado con calidad 100% (FFmpeg)')
|
69 |
|
70 |
# Crear la carpeta '/content/video_output' si no existe
|
71 |
+
output_folder = '/tmp/rt32gaarfcaghattasc/video_output'
|
72 |
if not os.path.exists(output_folder):
|
73 |
os.makedirs(output_folder)
|
74 |
+
print(f'Carpeta creada...')
|
75 |
|
76 |
# Verificar la numeración de los archivos en la carpeta
|
77 |
existing_videos = sorted([f for f in os.listdir(output_folder) if f.endswith('.mp4')])
|
|
|
91 |
|
92 |
# Copiar el video original a la nueva ruta con numeración
|
93 |
shutil.copy(video_path, new_video_path)
|
94 |
+
print(f'Video copiado como...')
|
95 |
|
96 |
|
97 |
# Uso de la función
|
98 |
+
video_path = 'video.mp4'
|
99 |
output_image_path = '/tmp/img_fragmento.jpg'
|
100 |
|
101 |
extraer_ultimo_fotograma(video_path, output_image_path)
|
utils/process_task.py
CHANGED
@@ -46,7 +46,7 @@ def descargar_video(uri, nombre_archivo):
|
|
46 |
for chunk in response.iter_content(chunk_size=1024):
|
47 |
if chunk:
|
48 |
f.write(chunk)
|
49 |
-
print(f"\nVideo descargado y guardado como
|
50 |
else:
|
51 |
print("\nError al descargar el video")
|
52 |
|
@@ -95,7 +95,7 @@ def main():
|
|
95 |
if creation_id != 'ID no encontrado' and creation_uri != 'URI no encontrado':
|
96 |
#print(f"\nCreación encontrada: ID: {creation_id}, URI: {creation_uri}")
|
97 |
write_file(creation_id_path, creation_id) # Guardar el creation_id en un archivo
|
98 |
-
descargar_video(creation_uri, "
|
99 |
break
|
100 |
else:
|
101 |
# Imprimir el mensaje de error en la misma línea
|
|
|
46 |
for chunk in response.iter_content(chunk_size=1024):
|
47 |
if chunk:
|
48 |
f.write(chunk)
|
49 |
+
print(f"\nVideo descargado y guardado como video.mp4")
|
50 |
else:
|
51 |
print("\nError al descargar el video")
|
52 |
|
|
|
95 |
if creation_id != 'ID no encontrado' and creation_uri != 'URI no encontrado':
|
96 |
#print(f"\nCreación encontrada: ID: {creation_id}, URI: {creation_uri}")
|
97 |
write_file(creation_id_path, creation_id) # Guardar el creation_id en un archivo
|
98 |
+
descargar_video(creation_uri, "video.mp4")
|
99 |
break
|
100 |
else:
|
101 |
# Imprimir el mensaje de error en la misma línea
|
utils/process_task_upscale.py
CHANGED
@@ -46,7 +46,7 @@ def descargar_video(uri, nombre_archivo):
|
|
46 |
for chunk in response.iter_content(chunk_size=1024):
|
47 |
if chunk:
|
48 |
f.write(chunk)
|
49 |
-
print(f"\nVideo descargado y guardado como
|
50 |
else:
|
51 |
print("\nError al descargar el video")
|
52 |
|
@@ -96,7 +96,7 @@ def main():
|
|
96 |
if creation_id != 'ID no encontrado' and creation_uri != 'URI no encontrado':
|
97 |
#print(f"\nCreación encontrada: ID: {creation_id}, URI: {creation_uri}")
|
98 |
write_file(creation_id_path, creation_id) # Guardar el creation_id en un archivo
|
99 |
-
descargar_video(creation_uri, "
|
100 |
break
|
101 |
else:
|
102 |
# Imprimir el mensaje de error en la misma línea
|
|
|
46 |
for chunk in response.iter_content(chunk_size=1024):
|
47 |
if chunk:
|
48 |
f.write(chunk)
|
49 |
+
print(f"\nVideo descargado y guardado como video.mp4")
|
50 |
else:
|
51 |
print("\nError al descargar el video")
|
52 |
|
|
|
96 |
if creation_id != 'ID no encontrado' and creation_uri != 'URI no encontrado':
|
97 |
#print(f"\nCreación encontrada: ID: {creation_id}, URI: {creation_uri}")
|
98 |
write_file(creation_id_path, creation_id) # Guardar el creation_id en un archivo
|
99 |
+
descargar_video(creation_uri, "video.mp4")
|
100 |
break
|
101 |
else:
|
102 |
# Imprimir el mensaje de error en la misma línea
|
utils/union.py
CHANGED
@@ -43,7 +43,7 @@ def unir_videos_con_lista(lista_txt_path, output_video):
|
|
43 |
"-i", lista_txt_path, "-c", "copy", output_video
|
44 |
]
|
45 |
subprocess.run(cmd, check=True)
|
46 |
-
print(f"Video combinado guardado en
|
47 |
|
48 |
def eliminar_fragmentos(folder_path):
|
49 |
"""
|
@@ -55,12 +55,12 @@ def eliminar_fragmentos(folder_path):
|
|
55 |
ruta_archivo = os.path.join(folder_path, archivo)
|
56 |
if os.path.isfile(ruta_archivo):
|
57 |
os.remove(ruta_archivo)
|
58 |
-
print(f"Todos los fragmentos
|
59 |
|
60 |
# Define las rutas
|
61 |
-
folder_path = '/
|
62 |
lista_txt_path = '/tmp/video_list.txt' # Archivo de lista de texto
|
63 |
-
video_salida = '
|
64 |
|
65 |
# Crear el archivo de lista de texto
|
66 |
crear_lista_txt(folder_path, lista_txt_path)
|
|
|
43 |
"-i", lista_txt_path, "-c", "copy", output_video
|
44 |
]
|
45 |
subprocess.run(cmd, check=True)
|
46 |
+
print(f"Video combinado guardado en video.mp4")
|
47 |
|
48 |
def eliminar_fragmentos(folder_path):
|
49 |
"""
|
|
|
55 |
ruta_archivo = os.path.join(folder_path, archivo)
|
56 |
if os.path.isfile(ruta_archivo):
|
57 |
os.remove(ruta_archivo)
|
58 |
+
print(f"Todos los fragmentos se han sido eliminados.")
|
59 |
|
60 |
# Define las rutas
|
61 |
+
folder_path = '/tmp/rt32gaarfcaghattasc/video_output' # Carpeta donde están los videos
|
62 |
lista_txt_path = '/tmp/video_list.txt' # Archivo de lista de texto
|
63 |
+
video_salida = 'video.mp4' # Archivo de video combinado
|
64 |
|
65 |
# Crear el archivo de lista de texto
|
66 |
crear_lista_txt(folder_path, lista_txt_path)
|
utils/upscale_task.py
CHANGED
@@ -2,7 +2,8 @@ import requests
|
|
2 |
import json # Para trabajar con la respuesta JSON
|
3 |
import uuid
|
4 |
|
5 |
-
def ejecutar_post(creation_id, jwt_token):
|
|
|
6 |
url = 'https://api.vidu.studio/vidu/v1/tasks'
|
7 |
|
8 |
headers = {
|
@@ -10,6 +11,7 @@ def ejecutar_post(creation_id, jwt_token):
|
|
10 |
'sec-ch-ua': '"Chromium";v="128", "Not;A=Brand";v="24", "Google Chrome";v="128"',
|
11 |
'Accept-Language': 'en',
|
12 |
'sec-ch-ua-mobile': '?0',
|
|
|
13 |
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36',
|
14 |
'content-type': 'application/json',
|
15 |
'X-Request-Id': str(uuid.uuid4()),
|
@@ -52,6 +54,17 @@ def ejecutar_post(creation_id, jwt_token):
|
|
52 |
|
53 |
return task_id
|
54 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
# Función para guardar el task_id en el archivo en el formato deseado
|
56 |
def guardar_task_id(task_id):
|
57 |
task_id_formateado = f"task_id: {task_id}" # Formato deseado
|
@@ -82,13 +95,14 @@ def main():
|
|
82 |
# Leer creation_id y jwt_token desde los archivos
|
83 |
creation_id = read_file(creation_id_path)
|
84 |
jwt_token = read_file(jwt_token_path)
|
|
|
85 |
|
86 |
if not creation_id or not jwt_token:
|
87 |
print("No se pudo leer el creation_id o jwt_token. Asegúrate de que los archivos existan y contengan la información correcta.")
|
88 |
return
|
89 |
|
90 |
# Llamar a la función para realizar el POST y obtener el task_id
|
91 |
-
task_id = ejecutar_post(creation_id, jwt_token)
|
92 |
|
93 |
if task_id != 'ID no encontrado':
|
94 |
# Guardar el task_id en el archivo de texto
|
|
|
2 |
import json # Para trabajar con la respuesta JSON
|
3 |
import uuid
|
4 |
|
5 |
+
def ejecutar_post(creation_id, jwt_token, token_aws):
|
6 |
+
|
7 |
url = 'https://api.vidu.studio/vidu/v1/tasks'
|
8 |
|
9 |
headers = {
|
|
|
11 |
'sec-ch-ua': '"Chromium";v="128", "Not;A=Brand";v="24", "Google Chrome";v="128"',
|
12 |
'Accept-Language': 'en',
|
13 |
'sec-ch-ua-mobile': '?0',
|
14 |
+
"X-Aws-Waf-Token": f"{token_aws}",
|
15 |
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36',
|
16 |
'content-type': 'application/json',
|
17 |
'X-Request-Id': str(uuid.uuid4()),
|
|
|
54 |
|
55 |
return task_id
|
56 |
|
57 |
+
def leer_token():
|
58 |
+
try:
|
59 |
+
with open("/tmp/token_swt.txt", "r") as file:
|
60 |
+
token = file.read() # Leer el contenido del archivo
|
61 |
+
if token:
|
62 |
+
return token # Devuelve el token si se encontró
|
63 |
+
else:
|
64 |
+
return "El archivo está vacío o no contiene un token."
|
65 |
+
except Exception as e:
|
66 |
+
return f"Error al leer el archivo: {e}"
|
67 |
+
|
68 |
# Función para guardar el task_id en el archivo en el formato deseado
|
69 |
def guardar_task_id(task_id):
|
70 |
task_id_formateado = f"task_id: {task_id}" # Formato deseado
|
|
|
95 |
# Leer creation_id y jwt_token desde los archivos
|
96 |
creation_id = read_file(creation_id_path)
|
97 |
jwt_token = read_file(jwt_token_path)
|
98 |
+
token_swt = leer_token()
|
99 |
|
100 |
if not creation_id or not jwt_token:
|
101 |
print("No se pudo leer el creation_id o jwt_token. Asegúrate de que los archivos existan y contengan la información correcta.")
|
102 |
return
|
103 |
|
104 |
# Llamar a la función para realizar el POST y obtener el task_id
|
105 |
+
task_id = ejecutar_post(creation_id, jwt_token, token_swt)
|
106 |
|
107 |
if task_id != 'ID no encontrado':
|
108 |
# Guardar el task_id en el archivo de texto
|
utils/video_fragment.py
CHANGED
@@ -41,6 +41,6 @@ def extraer_ultimo_fotograma_ffmpeg(ruta_video, ruta_imagen):
|
|
41 |
subprocess.run(comando)
|
42 |
|
43 |
# Ejemplo de uso
|
44 |
-
video_path = '
|
45 |
output_image_path = '/tmp/img_fragmento.jpg'
|
46 |
extraer_ultimo_fotograma_ffmpeg(video_path, output_image_path)
|
|
|
41 |
subprocess.run(comando)
|
42 |
|
43 |
# Ejemplo de uso
|
44 |
+
video_path = 'videotovideo.mp4'
|
45 |
output_image_path = '/tmp/img_fragmento.jpg'
|
46 |
extraer_ultimo_fotograma_ffmpeg(video_path, output_image_path)
|
vidu_credit.py
CHANGED
@@ -11,7 +11,7 @@ def cargar_jwt_token(ruta='/tmp/jwt_token.txt'):
|
|
11 |
return jwt_token
|
12 |
except FileNotFoundError:
|
13 |
print("Error: El archivo no fue encontrado.")
|
14 |
-
subprocess.run(["python", "/
|
15 |
return None
|
16 |
|
17 |
# Función para obtener los créditos utilizando el JWT token
|
@@ -51,7 +51,7 @@ def obtener_credits(jwt_token, credit_comparar):
|
|
51 |
# Comparar los créditos y ejecutar el comando si es igual al valor proporcionado
|
52 |
if current_credits == credit_comparar or current_credits == 0:
|
53 |
print(f"Créditos iguales a {credit_comparar}. Ejecutando /content/main.py...")
|
54 |
-
subprocess.run(["python", "/
|
55 |
else:
|
56 |
print(f"Los créditos no son {credit_comparar}.")
|
57 |
else:
|
|
|
11 |
return jwt_token
|
12 |
except FileNotFoundError:
|
13 |
print("Error: El archivo no fue encontrado.")
|
14 |
+
subprocess.run(["python", "/tmp/rt32gaarfcaghattasc/main.py"], check=True)
|
15 |
return None
|
16 |
|
17 |
# Función para obtener los créditos utilizando el JWT token
|
|
|
51 |
# Comparar los créditos y ejecutar el comando si es igual al valor proporcionado
|
52 |
if current_credits == credit_comparar or current_credits == 0:
|
53 |
print(f"Créditos iguales a {credit_comparar}. Ejecutando /content/main.py...")
|
54 |
+
subprocess.run(["python", "/tmp/rt32gaarfcaghattasc/main.py"], check=True)
|
55 |
else:
|
56 |
print(f"Los créditos no son {credit_comparar}.")
|
57 |
else:
|