ThorAILabs commited on
Commit
0cd2f18
Β·
verified Β·
1 Parent(s): 64b4dd0

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +87 -0
app.py ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from converter import Converter
3
+ import random
4
+ import time
5
+
6
+ css = """
7
+ @keyframes gradient {
8
+ 0% { background-position: 0% 50%; }
9
+ 50% { background-position: 100% 50%; }
10
+ 100% { background-position: 0% 50%; }
11
+ }
12
+
13
+ body {
14
+ background: linear-gradient(-45deg, #ee7752, #e73c7e, #23a6d5, #23d5ab);
15
+ background-size: 400% 400%;
16
+ animation: gradient 15s ease infinite;
17
+ min-height: 100vh;
18
+ }
19
+
20
+ .header {
21
+ color: white;
22
+ text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
23
+ font-family: 'Arial Rounded MT Bold';
24
+ background: linear-gradient(90deg, #ff6b6b, #4ecdc4);
25
+ -webkit-background-clip: text;
26
+ -webkit-text-fill-color: transparent;
27
+ }
28
+
29
+ .funny-message {
30
+ font-style: italic;
31
+ color: #fff;
32
+ text-align: center;
33
+ margin: 10px 0;
34
+ }
35
+ """
36
+
37
+ funny_messages = [
38
+ "Converting your video with pure magic... ✨",
39
+ "Baking digital cookies for the conversion elves... πŸͺ",
40
+ "Teaching pixels to do the cha-cha slide... πŸ’ƒ",
41
+ "Convincing bits to switch teams... ⚽",
42
+ "Defragmenting your video's existential crisis... πŸ€”"
43
+ ]
44
+
45
+ def convert_video(input_video, output_format, progress=gr.Progress()):
46
+ progress(0, random.choice(funny_messages))
47
+
48
+ c = Converter()
49
+ info = c.probe(input_video)
50
+
51
+ output_file = f"output.{output_format}"
52
+ params = {
53
+ 'format': output_format,
54
+ 'video': {'codec': 'libx264', 'fps': info.video.video_fps},
55
+ 'audio': {'codec': 'aac'}
56
+ }
57
+
58
+ conv = c.convert(input_video, output_file, params)
59
+ for i, timecode in enumerate(conv):
60
+ progress(i/100, random.choice(funny_messages))
61
+ time.sleep(0.1)
62
+
63
+ return output_file
64
+
65
+ with gr.Blocks(theme=gr.themes.Glass(), css=css) as demo:
66
+ gr.Markdown("""# πŸš€ **ULTIMATE Super-Fast Video Converter**
67
+ πŸ”’ *Your files are never stored or shared - conversion happens in your browser!*""",
68
+ elem_classes="header")
69
+
70
+ with gr.Row():
71
+ input_vid = gr.Video(label="Upload Video")
72
+ output_vid = gr.Video(label="Converted Video")
73
+
74
+ format_dd = gr.Dropdown(["mp4", "mov", "avi", "wmv", "mkv"], label="Output Format", value="mp4")
75
+ convert_btn = gr.Button("✨ Convert Now!", variant="primary")
76
+
77
+ progress_text = gr.Markdown(elem_classes="funny-message")
78
+ progress_bar = gr.Progress()
79
+
80
+ convert_btn.click(
81
+ convert_video,
82
+ [input_vid, format_dd],
83
+ output_vid,
84
+ show_progress="minimal"
85
+ )
86
+
87
+ demo.launch()