Download recorte.py from brianbla/mispace: direct link, hf CLI and curl.
- Browser
- Download file 885 Bytes
-
https://huggingface.co/spaces/brianbla/mispace/resolve/main/recorte.py
- Command line
-
hf download hf://spaces/brianbla/mispace/recorte.py
-
curl -L -o recorte.py https://huggingface.co/spaces/brianbla/mispace/resolve/main/recorte.py
885 Bytes
| import gradio as gr | |
| import os | |
| def crop_video(input_video, width, height, x, y): | |
| # Define la ruta de salida | |
| output_video = "output.mp4" | |
| # Comando de FFmpeg para recortar el video | |
| command = f"ffmpeg -i \"{input_video}\" -vf \"crop={width}:{height}:{x}:{y}\" \"{output_video}\"" | |
| # Ejecuta el comando | |
| os.system(command) | |
| return output_video | |
| # Interfaz de Gradio | |
| iface = gr.Interface( | |
| fn=crop_video, | |
| inputs=[ | |
| gr.Video(label="Video de entrada"), | |
| gr.Textbox(label="Ancho del recorte (w)"), | |
| gr.Textbox(label="Altura del recorte (h)"), | |
| gr.Textbox(label="Posición X del recorte"), | |
| gr.Textbox(label="Posición Y del recorte"), | |
| ], | |
| outputs=gr.Video(label="Video de salida"), | |
| title="Recortador de Video", | |
| description="Sube un video y especifica el área que deseas recortar." | |
| ) | |
| iface.launch() | |