Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -14,6 +14,11 @@ output_dir.mkdir(exist_ok=True)
|
|
| 14 |
logging.basicConfig(level=logging.INFO)
|
| 15 |
|
| 16 |
standard_resolutions = [240, 360, 480, 720, 1080, 1440, 2160, 4320]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
def download_file(url, destination):
|
| 19 |
response = requests.get(url)
|
|
@@ -69,7 +74,7 @@ def convert_video(video_file, quality, aspect_ratio, video_url):
|
|
| 69 |
output_path = get_output_path(input_path, str(res) + 'p')
|
| 70 |
|
| 71 |
ffmpeg_command = [
|
| 72 |
-
"ffmpeg", "-i", str(input_path), "-c:v", "libx264", "-crf", str(quality),
|
| 73 |
"-vf", f"scale={scale}:force_original_aspect_ratio=decrease,pad=ceil(iw/2)*2:ceil(ih/2)*2",
|
| 74 |
"-hls_time", "10", "-hls_playlist_type", "vod", "-hls_segment_filename",
|
| 75 |
str(output_dir / f"{output_path.stem}_%03d.ts"), str(output_path)
|
|
|
|
| 14 |
logging.basicConfig(level=logging.INFO)
|
| 15 |
|
| 16 |
standard_resolutions = [240, 360, 480, 720, 1080, 1440, 2160, 4320]
|
| 17 |
+
quality_mapping = {
|
| 18 |
+
"Low": 35,
|
| 19 |
+
"Medium": 23,
|
| 20 |
+
"High": 18,
|
| 21 |
+
}
|
| 22 |
|
| 23 |
def download_file(url, destination):
|
| 24 |
response = requests.get(url)
|
|
|
|
| 74 |
output_path = get_output_path(input_path, str(res) + 'p')
|
| 75 |
|
| 76 |
ffmpeg_command = [
|
| 77 |
+
"ffmpeg", "-i", str(input_path), "-c:v", "libx264", "-crf", str(quality_mapping[quality]),
|
| 78 |
"-vf", f"scale={scale}:force_original_aspect_ratio=decrease,pad=ceil(iw/2)*2:ceil(ih/2)*2",
|
| 79 |
"-hls_time", "10", "-hls_playlist_type", "vod", "-hls_segment_filename",
|
| 80 |
str(output_dir / f"{output_path.stem}_%03d.ts"), str(output_path)
|