Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,9 +1,9 @@
|
|
| 1 |
import os
|
| 2 |
-
import moviepy.
|
| 3 |
import gradio as gr
|
| 4 |
|
| 5 |
-
def split_video(video_file, parts, resolution, quality, audio_enabled, volume):
|
| 6 |
-
video =
|
| 7 |
duration = video.duration
|
| 8 |
part_duration = duration / parts
|
| 9 |
|
|
@@ -11,7 +11,7 @@ def split_video(video_file, parts, resolution, quality, audio_enabled, volume):
|
|
| 11 |
for part in range(parts):
|
| 12 |
start_time = part * part_duration
|
| 13 |
end_time = (part + 1) * part_duration
|
| 14 |
-
part_clip = video.
|
| 15 |
|
| 16 |
# Настройка параметров кодирования
|
| 17 |
if quality == "Низкое":
|
|
@@ -29,7 +29,7 @@ def split_video(video_file, parts, resolution, quality, audio_enabled, volume):
|
|
| 29 |
|
| 30 |
# Сохранение видео
|
| 31 |
output_filename = f"part_{part + 1}.mp4"
|
| 32 |
-
part_clip.
|
| 33 |
output_filename,
|
| 34 |
codec="libx264",
|
| 35 |
audio_codec="aac",
|
|
@@ -57,4 +57,4 @@ iface = gr.Interface(
|
|
| 57 |
)
|
| 58 |
|
| 59 |
if __name__ == "__main__":
|
| 60 |
-
iface.launch()
|
|
|
|
| 1 |
import os
|
| 2 |
+
import moviepy.editor_async as mp_async
|
| 3 |
import gradio as gr
|
| 4 |
|
| 5 |
+
async def split_video(video_file, parts, resolution, quality, audio_enabled, volume):
|
| 6 |
+
video = mp_async.VideoFileClip(video_file.name)
|
| 7 |
duration = video.duration
|
| 8 |
part_duration = duration / parts
|
| 9 |
|
|
|
|
| 11 |
for part in range(parts):
|
| 12 |
start_time = part * part_duration
|
| 13 |
end_time = (part + 1) * part_duration
|
| 14 |
+
part_clip = await video.subclip_async(start_time, end_time)
|
| 15 |
|
| 16 |
# Настройка параметров кодирования
|
| 17 |
if quality == "Низкое":
|
|
|
|
| 29 |
|
| 30 |
# Сохранение видео
|
| 31 |
output_filename = f"part_{part + 1}.mp4"
|
| 32 |
+
await part_clip.write_videofile_async(
|
| 33 |
output_filename,
|
| 34 |
codec="libx264",
|
| 35 |
audio_codec="aac",
|
|
|
|
| 57 |
)
|
| 58 |
|
| 59 |
if __name__ == "__main__":
|
| 60 |
+
iface.launch(debug=True)
|