Download app.py from yking21/ffmegp: direct link, hf CLI and curl.
- Browser
- Download file 1.19 kB
-
https://huggingface.co/spaces/yking21/ffmegp/resolve/main/app.py
- Command line
-
hf download hf://spaces/yking21/ffmegp/app.py
-
curl -L -o app.py https://huggingface.co/spaces/yking21/ffmegp/resolve/main/app.py
1.19 kB
| import gradio as gr | |
| # ุจุฏูุงู ู ู: from moviepy.editor import VideoFileClip, TextClip, CompositeVideoClip | |
| from moviepy import VideoFileClip, TextClip, CompositeVideoClip | |
| import requests | |
| def process_video(video_url, audio_url, hook_text): | |
| # ุชุญู ูู ุงูููุฏูู ูุงูุตูุช | |
| with open("input.mp4", "wb") as f: | |
| f.write(requests.get(video_url).content) | |
| with open("audio.mp3", "wb") as f: | |
| f.write(requests.get(audio_url).content) | |
| # ุฏู ุฌ ุงููุต ูุงูุตูุช | |
| video = VideoFileClip("input.mp4") | |
| txt_hook = TextClip(hook_text, fontsize=45, color='white', font='Arial-Bold').set_position(('center', 'center')).set_duration(video.duration) | |
| txt_caption = TextClip("ุงูุฑุฃ ุงููุงุจุชุดู ๐", fontsize=30, color='yellow', font='Arial-Bold').set_position(('center', video.h - 120)).set_duration(video.duration) | |
| final = CompositeVideoClip([video, txt_hook, txt_caption]) | |
| final.write_videofile("output.mp4", codec="libx264", audio="audio.mp3") | |
| return "output.mp4" | |
| # ูุงุฌูุฉ Gradio ููู API | |
| demo = gr.Interface( | |
| fn=process_video, | |
| inputs=["text", "text", "text"], | |
| outputs="video" | |
| ) | |
| demo.launch() |