Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -9,11 +9,20 @@ import http.server
|
|
9 |
import socketserver
|
10 |
import threading
|
11 |
import socket
|
|
|
12 |
|
13 |
# Define output directory
|
14 |
output_dir = Path.cwd() / "output"
|
15 |
output_dir.mkdir(exist_ok=True)
|
16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
logging.basicConfig(level=logging.INFO)
|
18 |
|
19 |
standard_resolutions = [240, 360, 480, 720, 1080, 1440, 2160, 4320]
|
@@ -103,6 +112,8 @@ def convert_video(video_file, quality, aspect_ratio, video_url):
|
|
103 |
output_links = []
|
104 |
for path in output_paths:
|
105 |
output_links.append(f'<a href="http://{server_ip}:8000{path}" target="_blank">Download {Path(path).stem}</a>')
|
|
|
|
|
106 |
|
107 |
output_html = "<br>".join(output_links)
|
108 |
return output_html
|
|
|
9 |
import socketserver
|
10 |
import threading
|
11 |
import socket
|
12 |
+
import s3fs
|
13 |
|
14 |
# Define output directory
|
15 |
output_dir = Path.cwd() / "output"
|
16 |
output_dir.mkdir(exist_ok=True)
|
17 |
|
18 |
+
# Set S3 credentials
|
19 |
+
AWS_S3_BUCKET = os.getenv("AWS_S3_BUCKET")
|
20 |
+
AWS_ACCESS_KEY_ID = os.getenv("AWS_ACCESS_KEY_ID")
|
21 |
+
AWS_SECRET_ACCESS_KEY = os.getenv("AWS_SECRET_ACCESS_KEY")
|
22 |
+
|
23 |
+
storage_options = {"key": AWS_ACCESS_KEY_ID, "secret": AWS_SECRET_ACCESS_KEY}
|
24 |
+
fs = s3fs.S3FileSystem(**storage_options)
|
25 |
+
|
26 |
logging.basicConfig(level=logging.INFO)
|
27 |
|
28 |
standard_resolutions = [240, 360, 480, 720, 1080, 1440, 2160, 4320]
|
|
|
112 |
output_links = []
|
113 |
for path in output_paths:
|
114 |
output_links.append(f'<a href="http://{server_ip}:8000{path}" target="_blank">Download {Path(path).stem}</a>')
|
115 |
+
print("Upload " + Path(path).stem + " to AWS")
|
116 |
+
fs.mv(str(output_dir / f"{output_path.stem}_%03d.ts"), f"s3://{AWS_S3_BUCKET}/{Path(path).stem}",)
|
117 |
|
118 |
output_html = "<br>".join(output_links)
|
119 |
return output_html
|