brianbla commited on
Commit
fd3a3dc
verified
1 Parent(s): 29d3095

Upload recorte.py

Browse files
Files changed (1) hide show
  1. recorte.py +31 -0
recorte.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import os
3
+
4
+ def crop_video(input_video, width, height, x, y):
5
+ # Define la ruta de salida
6
+ output_video = "output.mp4"
7
+
8
+ # Comando de FFmpeg para recortar el video
9
+ command = f"ffmpeg -i \"{input_video}\" -vf \"crop={width}:{height}:{x}:{y}\" \"{output_video}\""
10
+
11
+ # Ejecuta el comando
12
+ os.system(command)
13
+
14
+ return output_video
15
+
16
+ # Interfaz de Gradio
17
+ iface = gr.Interface(
18
+ fn=crop_video,
19
+ inputs=[
20
+ gr.inputs.Video(label="Video de entrada"),
21
+ gr.inputs.Textbox(label="Ancho del recorte (w)"),
22
+ gr.inputs.Textbox(label="Altura del recorte (h)"),
23
+ gr.inputs.Textbox(label="Posici贸n X del recorte"),
24
+ gr.inputs.Textbox(label="Posici贸n Y del recorte"),
25
+ ],
26
+ outputs=gr.outputs.Video(label="Video de salida"),
27
+ title="Recortador de Video",
28
+ description="Sube un video y especifica el 谩rea que deseas recortar."
29
+ )
30
+
31
+ iface.launch()