Update app.py
Browse files
app.py
CHANGED
@@ -85,12 +85,12 @@ async def convert_video_task(input_path, downscale, faster, use_mp3, audio_only,
|
|
85 |
|
86 |
# Compress video without audio
|
87 |
video_cmd = [
|
88 |
-
|
89 |
-
]
|
|
|
|
|
|
|
90 |
|
91 |
-
if downscale:
|
92 |
-
video_cmd += ['-vf', 'scale=-2:144']
|
93 |
-
|
94 |
if custom_bitrate:
|
95 |
video_cmd += ['-b:v', f"{int(video_bitrate)}k"]
|
96 |
else:
|
@@ -102,15 +102,26 @@ if downscale:
|
|
102 |
await run_subprocess(video_cmd)
|
103 |
|
104 |
if audio_only:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
return audio_output, None
|
106 |
|
107 |
-
# Merge
|
108 |
merged_output = os.path.join(CONVERTED_FOLDER, f"{uuid.uuid4()}.mp4")
|
109 |
await run_subprocess([
|
110 |
-
'ffmpeg', '-y',
|
|
|
|
|
|
|
|
|
111 |
])
|
112 |
|
113 |
-
# Cleanup
|
114 |
for f in [audio_wav, audio_output, video_output]:
|
115 |
try:
|
116 |
os.remove(f)
|
|
|
85 |
|
86 |
# Compress video without audio
|
87 |
video_cmd = [
|
88 |
+
'ffmpeg', '-y', '-hwaccel', accel, '-i', input_path
|
89 |
+
]
|
90 |
+
|
91 |
+
if downscale:
|
92 |
+
video_cmd += ['-vf', 'scale=-2:144']
|
93 |
|
|
|
|
|
|
|
94 |
if custom_bitrate:
|
95 |
video_cmd += ['-b:v', f"{int(video_bitrate)}k"]
|
96 |
else:
|
|
|
102 |
await run_subprocess(video_cmd)
|
103 |
|
104 |
if audio_only:
|
105 |
+
# User wants audio only, no merged video
|
106 |
+
# Clean intermediates except audio_output
|
107 |
+
for f in [audio_wav, video_output]:
|
108 |
+
try:
|
109 |
+
os.remove(f)
|
110 |
+
except FileNotFoundError:
|
111 |
+
pass
|
112 |
return audio_output, None
|
113 |
|
114 |
+
# Merge audio + video into final file
|
115 |
merged_output = os.path.join(CONVERTED_FOLDER, f"{uuid.uuid4()}.mp4")
|
116 |
await run_subprocess([
|
117 |
+
'ffmpeg', '-y',
|
118 |
+
'-i', video_output,
|
119 |
+
'-i', audio_output,
|
120 |
+
'-c', 'copy',
|
121 |
+
merged_output
|
122 |
])
|
123 |
|
124 |
+
# Cleanup intermediate files
|
125 |
for f in [audio_wav, audio_output, video_output]:
|
126 |
try:
|
127 |
os.remove(f)
|