Update app.py
Browse files
app.py
CHANGED
@@ -6,6 +6,17 @@ import glob
|
|
6 |
import shutil
|
7 |
import gradio as gr
|
8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
os.system("chmod +x fdkaac")
|
10 |
accel = 'auto'
|
11 |
video_base_opts = ['-crf', '63', '-c:v', 'libx264', '-tune', 'zerolatency']
|
@@ -47,8 +58,8 @@ async def convert_video_task(input_path, downscale, faster, use_mp3):
|
|
47 |
|
48 |
# Compress WAV → AAC with local fdkaac
|
49 |
await run_subprocess([
|
50 |
-
|
51 |
-
|
52 |
])
|
53 |
|
54 |
# Compress video with extreme low quality
|
@@ -67,7 +78,7 @@ async def process_conversion(use_youtube, youtube_url, video_file, downscale, fa
|
|
67 |
if use_youtube:
|
68 |
yt_uuid = str(uuid.uuid4())
|
69 |
yt_out = os.path.join(UPLOAD_FOLDER, yt_uuid + ".%(ext)s")
|
70 |
-
yt_cmd = [
|
71 |
await run_subprocess(yt_cmd)
|
72 |
pattern = os.path.join(UPLOAD_FOLDER, yt_uuid + ".*")
|
73 |
files = glob.glob(pattern)
|
|
|
6 |
import shutil
|
7 |
import gradio as gr
|
8 |
|
9 |
+
ffmpeg_path = shutil.which("ffmpeg")
|
10 |
+
fdkaac_path = os.path.abspath("./fdkaac")
|
11 |
+
yt_dlp_path = shutil.which("yt-dlp")
|
12 |
+
|
13 |
+
if not ffmpeg_path:
|
14 |
+
raise FileNotFoundError("FFmpeg not found in PATH.")
|
15 |
+
if not yt_dlp_path:
|
16 |
+
raise FileNotFoundError("yt-dlp not found in PATH.")
|
17 |
+
if not os.path.isfile(fdkaac_path):
|
18 |
+
raise FileNotFoundError("fdkaac binary not found in current directory.")
|
19 |
+
|
20 |
os.system("chmod +x fdkaac")
|
21 |
accel = 'auto'
|
22 |
video_base_opts = ['-crf', '63', '-c:v', 'libx264', '-tune', 'zerolatency']
|
|
|
58 |
|
59 |
# Compress WAV → AAC with local fdkaac
|
60 |
await run_subprocess([
|
61 |
+
fdkaac_path, '-b', '1k', '-C', '-f', '2', '-G', '1', '-w', '8000',
|
62 |
+
'-o', audio_output, audio_wav
|
63 |
])
|
64 |
|
65 |
# Compress video with extreme low quality
|
|
|
78 |
if use_youtube:
|
79 |
yt_uuid = str(uuid.uuid4())
|
80 |
yt_out = os.path.join(UPLOAD_FOLDER, yt_uuid + ".%(ext)s")
|
81 |
+
yt_cmd = [yt_dlp_path, '-o', yt_out, '-f', 'b', youtube_url]
|
82 |
await run_subprocess(yt_cmd)
|
83 |
pattern = os.path.join(UPLOAD_FOLDER, yt_uuid + ".*")
|
84 |
files = glob.glob(pattern)
|