Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -64,7 +64,9 @@ def split_and_zip(video_path, n_parts):
|
|
| 64 |
length = duration - start if i == n_parts - 1 else seg_len
|
| 65 |
length = max(0.0, min(length, duration - start))
|
| 66 |
|
| 67 |
-
|
|
|
|
|
|
|
| 68 |
cmd = [
|
| 69 |
"ffmpeg", "-hide_banner", "-loglevel", "error", "-y",
|
| 70 |
"-ss", f"{start:.6f}",
|
|
@@ -84,12 +86,12 @@ def split_and_zip(video_path, n_parts):
|
|
| 84 |
except Exception as e:
|
| 85 |
logs.append(f"❌ Failed part {i+1}: {e}")
|
| 86 |
|
| 87 |
-
# zip
|
| 88 |
-
zip_path =
|
| 89 |
-
shutil.make_archive(str(
|
| 90 |
|
| 91 |
-
logs.append(f"ZIP ready: {
|
| 92 |
-
return zip_path, "\n".join(logs)
|
| 93 |
|
| 94 |
# ---------- UI ----------
|
| 95 |
with gr.Blocks(title="Video Splitter") as demo:
|
|
|
|
| 64 |
length = duration - start if i == n_parts - 1 else seg_len
|
| 65 |
length = max(0.0, min(length, duration - start))
|
| 66 |
|
| 67 |
+
# Filename: Filename_Part_XX.mp4 (with leading zero up to 09)
|
| 68 |
+
out_file = outdir / f"{stem}_Part_{i+1:02d}.mp4"
|
| 69 |
+
|
| 70 |
cmd = [
|
| 71 |
"ffmpeg", "-hide_banner", "-loglevel", "error", "-y",
|
| 72 |
"-ss", f"{start:.6f}",
|
|
|
|
| 86 |
except Exception as e:
|
| 87 |
logs.append(f"❌ Failed part {i+1}: {e}")
|
| 88 |
|
| 89 |
+
# ZIP filename: Filename_Split.zip
|
| 90 |
+
zip_path = Path(workdir) / f"{stem}_Split.zip"
|
| 91 |
+
shutil.make_archive(str(zip_path.with_suffix("")), "zip", root_dir=outdir)
|
| 92 |
|
| 93 |
+
logs.append(f"ZIP ready: {zip_path.name}")
|
| 94 |
+
return str(zip_path), "\n".join(logs)
|
| 95 |
|
| 96 |
# ---------- UI ----------
|
| 97 |
with gr.Blocks(title="Video Splitter") as demo:
|