Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -83,19 +83,21 @@ def create_master_playlist(output_paths, input_filename):
|
|
83 |
f.write(f'#EXT-X-STREAM-INF:BANDWIDTH=8000000,RESOLUTION={res}\n')
|
84 |
# read the .m3u8 file and replace relative links with absolute links
|
85 |
with open(path, 'r') as playlist_file:
|
86 |
-
content = playlist_file.
|
87 |
-
content =
|
88 |
-
f.
|
|
|
89 |
return master_playlist_path
|
90 |
|
91 |
def upload_file_to_s3(file_path, s3_path):
|
92 |
-
print(f"
|
93 |
with open(file_path, 'rb') as file:
|
94 |
file_content = file.read()
|
95 |
|
96 |
with fs.open(s3_path, 'wb') as file:
|
97 |
file.write(file_content)
|
98 |
|
|
|
99 |
def convert_video(video_file, quality, aspect_ratio, video_url):
|
100 |
# Ensure either a file or a URL is provided
|
101 |
if not video_file and not video_url:
|
|
|
83 |
f.write(f'#EXT-X-STREAM-INF:BANDWIDTH=8000000,RESOLUTION={res}\n')
|
84 |
# read the .m3u8 file and replace relative links with absolute links
|
85 |
with open(path, 'r') as playlist_file:
|
86 |
+
content = playlist_file.readlines()
|
87 |
+
content = [line.replace('.ts', f'.ts?https://s3-us-east-1.amazonaws.com/{AWS_S3_BUCKET}/{input_filename}/{res}/{line.strip()}') if line.endswith('.ts\n') else line for line in content]
|
88 |
+
f.writelines(content)
|
89 |
+
f.write('\n')
|
90 |
return master_playlist_path
|
91 |
|
92 |
def upload_file_to_s3(file_path, s3_path):
|
93 |
+
print(f"Uploading {file_path} to AWS at {s3_path}")
|
94 |
with open(file_path, 'rb') as file:
|
95 |
file_content = file.read()
|
96 |
|
97 |
with fs.open(s3_path, 'wb') as file:
|
98 |
file.write(file_content)
|
99 |
|
100 |
+
|
101 |
def convert_video(video_file, quality, aspect_ratio, video_url):
|
102 |
# Ensure either a file or a URL is provided
|
103 |
if not video_file and not video_url:
|