Riolit commited on
Commit
0bb8ee4
·
verified ·
1 Parent(s): a148575

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -6
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
- out_file = outdir / f"{stem}_part{i+1:02d}.mp4"
 
 
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 = str(outdir) + ".zip"
89
- shutil.make_archive(str(outdir), "zip", root_dir=outdir)
90
 
91
- logs.append(f"ZIP ready: {Path(zip_path).name}")
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: