mrpoddaa commited on
Commit
ebaa914
Β·
verified Β·
1 Parent(s): b35c1c0

Upload 4 files

Browse files
Files changed (4) hide show
  1. README.md +122 -12
  2. app.py +183 -0
  3. packages.txt +1 -0
  4. requirements.txt +4 -0
README.md CHANGED
@@ -1,12 +1,122 @@
1
- ---
2
- title: Burning
3
- emoji: πŸ“ˆ
4
- colorFrom: purple
5
- colorTo: pink
6
- sdk: gradio
7
- sdk_version: 6.5.1
8
- app_file: app.py
9
- pinned: false
10
- ---
11
-
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 🎬 Video Subtitle Burner & Uploader
2
+
3
+ A Gradio application that burns subtitles into videos and uploads them to abyss.to
4
+
5
+ ## Features
6
+
7
+ - βœ… Download videos from Google Drive or direct URLs
8
+ - βœ… Burn SRT subtitles into video
9
+ - βœ… Upload processed video to abyss.to (hydrax.net)
10
+ - βœ… Simple web interface
11
+ - βœ… Progress tracking
12
+
13
+ ## How to Deploy on Hugging Face Spaces
14
+
15
+ ### Method 1: Web Interface
16
+
17
+ 1. Go to https://huggingface.co/spaces
18
+ 2. Click **"Create new Space"**
19
+ 3. Fill in details:
20
+ - **Space name**: `subtitle-burner` (or your choice)
21
+ - **License**: Apache 2.0
22
+ - **Select SDK**: Gradio
23
+ - **Hardware**: CPU Basic (Free tier works!)
24
+ 4. Click **"Create Space"**
25
+ 5. Upload these files:
26
+ - `app.py`
27
+ - `requirements.txt`
28
+ - `README.md`
29
+ 6. Go to **Settings** β†’ **Variables and secrets**
30
+ 7. Add **packages_txt** file with content:
31
+ ```
32
+ ffmpeg
33
+ ```
34
+ 8. Wait for the build to complete (~2-5 minutes)
35
+ 9. Your app will be live! πŸŽ‰
36
+
37
+ ### Method 2: Git Upload
38
+
39
+ ```bash
40
+ # Clone your space
41
+ git clone https://huggingface.co/spaces/YOUR_USERNAME/subtitle-burner
42
+ cd subtitle-burner
43
+
44
+ # Copy files
45
+ cp app.py requirements.txt README.md ./
46
+
47
+ # Create packages.txt for FFmpeg
48
+ echo "ffmpeg" > packages.txt
49
+
50
+ # Commit and push
51
+ git add .
52
+ git commit -m "Initial commit"
53
+ git push
54
+ ```
55
+
56
+ ## Usage
57
+
58
+ 1. **Video URL**: Paste your Google Drive link or direct video URL
59
+ - Google Drive: `https://drive.google.com/file/d/FILE_ID/view`
60
+ - Direct: Any `.mp4` URL
61
+
62
+ 2. **Subtitle Content**: Paste your SRT subtitle file content
63
+ ```
64
+ 1
65
+ 00:00:01,000 --> 00:00:04,000
66
+ ࢸේ ࢋࢯාහࢻࢫ subtitle ΰΆ‘ΰΆšΰΆšΰ·Š
67
+
68
+ 2
69
+ 00:00:04,500 --> 00:00:08,000
70
+ This is an example subtitle
71
+ ```
72
+
73
+ 3. Click **Process & Upload**
74
+
75
+ 4. Wait for processing (may take a few minutes depending on video size)
76
+
77
+ 5. Get the abyss.to upload response with your video link!
78
+
79
+ ## Technical Details
80
+
81
+ - **FFmpeg**: Used for burning subtitles
82
+ - **Gradio**: Web interface framework
83
+ - **gdown**: Google Drive file downloads
84
+ - **requests**: HTTP operations and uploading
85
+
86
+ ## Files
87
+
88
+ - `app.py`: Main application code
89
+ - `requirements.txt`: Python dependencies
90
+ - `packages.txt`: System packages (FFmpeg)
91
+ - `README.md`: Documentation
92
+
93
+ ## Important Notes
94
+
95
+ ⚠️ **FFmpeg Required**: Make sure to create `packages.txt` with `ffmpeg` for Hugging Face Spaces
96
+
97
+ ⚠️ **File Size Limits**: Hugging Face free tier has storage limits. Large videos may fail.
98
+
99
+ ⚠️ **Processing Time**: Video processing can take time. Be patient!
100
+
101
+ ## Troubleshooting
102
+
103
+ ### Error: FFmpeg not found
104
+ - Make sure `packages.txt` contains `ffmpeg`
105
+ - Rebuild the space
106
+
107
+ ### Error: Download failed
108
+ - Check if the Google Drive link is publicly accessible
109
+ - Verify the direct URL is correct
110
+
111
+ ### Error: Upload to abyss.to failed
112
+ - Check your internet connection
113
+ - Verify the abyss.to upload URL is correct
114
+ - Check file size limits
115
+
116
+ ## License
117
+
118
+ Apache 2.0
119
+
120
+ ## Credits
121
+
122
+ Built with Gradio, FFmpeg, and Python 🐍
app.py ADDED
@@ -0,0 +1,183 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import subprocess
3
+ import requests
4
+ import os
5
+ import re
6
+ from pathlib import Path
7
+ import gdown
8
+
9
+ def download_from_gdrive(url):
10
+ """Download file from Google Drive"""
11
+ try:
12
+ # Extract file ID from various Google Drive URL formats
13
+ file_id = None
14
+ if 'drive.google.com' in url:
15
+ if '/file/d/' in url:
16
+ file_id = url.split('/file/d/')[1].split('/')[0]
17
+ elif 'id=' in url:
18
+ file_id = url.split('id=')[1].split('&')[0]
19
+
20
+ if file_id:
21
+ output = 'input_video.mp4'
22
+ gdown.download(f'https://drive.google.com/uc?id={file_id}', output, quiet=False)
23
+ return output
24
+ else:
25
+ return None
26
+ except Exception as e:
27
+ print(f"Error downloading from Google Drive: {e}")
28
+ return None
29
+
30
+ def download_video(url):
31
+ """Download video from direct URL or Google Drive"""
32
+ try:
33
+ # Check if it's a Google Drive link
34
+ if 'drive.google.com' in url:
35
+ return download_from_gdrive(url)
36
+
37
+ # Direct download
38
+ response = requests.get(url, stream=True)
39
+ response.raise_for_status()
40
+
41
+ output_path = 'input_video.mp4'
42
+ with open(output_path, 'wb') as f:
43
+ for chunk in response.iter_content(chunk_size=8192):
44
+ f.write(chunk)
45
+
46
+ return output_path
47
+ except Exception as e:
48
+ return f"Error downloading video: {str(e)}"
49
+
50
+ def burn_subtitles(video_path, subtitle_file):
51
+ """Burn subtitles into video using FFmpeg"""
52
+ try:
53
+ output_path = 'output_with_subs.mp4'
54
+
55
+ # Save subtitle file
56
+ subtitle_path = 'subtitles.srt'
57
+ with open(subtitle_path, 'w', encoding='utf-8') as f:
58
+ f.write(subtitle_file)
59
+
60
+ # FFmpeg command to burn subtitles
61
+ cmd = [
62
+ 'ffmpeg',
63
+ '-i', video_path,
64
+ '-vf', f"subtitles={subtitle_path}:force_style='FontSize=24,PrimaryColour=&H00FFFFFF,OutlineColour=&H00000000,Outline=2'",
65
+ '-c:a', 'copy',
66
+ '-y',
67
+ output_path
68
+ ]
69
+
70
+ subprocess.run(cmd, check=True, capture_output=True)
71
+ return output_path
72
+ except subprocess.CalledProcessError as e:
73
+ return f"Error burning subtitles: {e.stderr.decode()}"
74
+ except Exception as e:
75
+ return f"Error: {str(e)}"
76
+
77
+ def upload_to_abyss(file_path):
78
+ """Upload file to abyss.to (hydrax.net)"""
79
+ try:
80
+ url = 'http://up.hydrax.net/af3a445e1825a2b8256fc918c6087381'
81
+
82
+ file_name = os.path.basename(file_path)
83
+ file_type = 'video/mp4'
84
+
85
+ with open(file_path, 'rb') as f:
86
+ files = {'file': (file_name, f, file_type)}
87
+ response = requests.post(url, files=files, timeout=300)
88
+
89
+ return response.text
90
+ except Exception as e:
91
+ return f"Error uploading to abyss.to: {str(e)}"
92
+
93
+ def process_video(video_url, subtitle_content, progress=gr.Progress()):
94
+ """Main processing function"""
95
+ try:
96
+ progress(0.1, desc="Downloading video...")
97
+ video_path = download_video(video_url)
98
+
99
+ if isinstance(video_path, str) and video_path.startswith("Error"):
100
+ return video_path, None
101
+
102
+ if not os.path.exists(video_path):
103
+ return "Error: Video download failed", None
104
+
105
+ progress(0.4, desc="Burning subtitles...")
106
+ output_path = burn_subtitles(video_path, subtitle_content)
107
+
108
+ if isinstance(output_path, str) and output_path.startswith("Error"):
109
+ return output_path, None
110
+
111
+ progress(0.7, desc="Uploading to abyss.to...")
112
+ upload_response = upload_to_abyss(output_path)
113
+
114
+ progress(1.0, desc="Complete!")
115
+
116
+ # Cleanup
117
+ if os.path.exists(video_path):
118
+ os.remove(video_path)
119
+ if os.path.exists('subtitles.srt'):
120
+ os.remove('subtitles.srt')
121
+
122
+ return f"βœ… Upload successful!\n\nResponse from abyss.to:\n{upload_response}", output_path
123
+
124
+ except Exception as e:
125
+ return f"Error: {str(e)}", None
126
+
127
+ # Gradio Interface
128
+ with gr.Blocks(title="Subtitle Burner & Uploader", theme=gr.themes.Soft()) as app:
129
+ gr.Markdown("""
130
+ # 🎬 Video Subtitle Burner & Uploader
131
+
132
+ Upload a video (via link) and subtitle file, burn subtitles into the video, and upload to abyss.to
133
+ """)
134
+
135
+ with gr.Row():
136
+ with gr.Column():
137
+ video_url = gr.Textbox(
138
+ label="Video URL",
139
+ placeholder="Enter Google Drive link or direct video URL",
140
+ lines=2
141
+ )
142
+
143
+ subtitle_file = gr.Textbox(
144
+ label="Subtitle Content (.srt)",
145
+ placeholder="Paste your SRT subtitle content here...",
146
+ lines=10
147
+ )
148
+
149
+ process_btn = gr.Button("πŸš€ Process & Upload", variant="primary", size="lg")
150
+
151
+ with gr.Column():
152
+ status_output = gr.Textbox(
153
+ label="Status",
154
+ lines=10,
155
+ interactive=False
156
+ )
157
+
158
+ video_output = gr.Video(
159
+ label="Preview (with subtitles)",
160
+ interactive=False
161
+ )
162
+
163
+ gr.Markdown("""
164
+ ### πŸ“ Instructions:
165
+ 1. **Video URL**: Paste a Google Drive share link or direct video URL
166
+ 2. **Subtitle Content**: Paste the contents of your .srt subtitle file
167
+ 3. Click **Process & Upload** and wait
168
+ 4. The video with burned subtitles will be uploaded to abyss.to
169
+
170
+ ### πŸ”— Supported formats:
171
+ - Google Drive: `https://drive.google.com/file/d/FILE_ID/view`
172
+ - Direct links: Any direct .mp4 URL
173
+ - Subtitles: Standard SRT format
174
+ """)
175
+
176
+ process_btn.click(
177
+ fn=process_video,
178
+ inputs=[video_url, subtitle_file],
179
+ outputs=[status_output, video_output]
180
+ )
181
+
182
+ if __name__ == "__main__":
183
+ app.launch()
packages.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ ffmpeg
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ gradio==4.16.0
2
+ requests==2.31.0
3
+ gdown==4.7.1
4
+ ffmpeg-python==0.2.0