yasvanthkumar commited on
Commit
f2d9bf2
·
verified ·
1 Parent(s): aa1bd4b

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +55 -0
app.py ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from clipper import process_youtube_link, process_uploaded_file
3
+ import os
4
+
5
+ st.set_page_config(page_title="YT Clipper AI", layout="centered")
6
+ st.title("YT Clipper AI — Personal Shorts Generator")
7
+ st.markdown("Paste a YouTube link or upload an MP4 to auto-generate vertical Shorts.")
8
+
9
+ mode = st.radio("Input type", ("YouTube link", "Upload MP4"))
10
+ out_dir = "outputs"
11
+ os.makedirs(out_dir, exist_ok=True)
12
+
13
+ if mode == "YouTube link":
14
+ url = st.text_input("YouTube URL")
15
+ if st.button("Generate Clips from URL") and url:
16
+ with st.spinner("Processing… please wait..."):
17
+ clips = process_youtube_link(url, out_dir=out_dir, num_clips=3)
18
+
19
+ st.success(f"Generated {len(clips)} clips")
20
+
21
+ for c in clips:
22
+ try:
23
+ st.video(c)
24
+ except:
25
+ st.write(f"Preview not available for {c}")
26
+
27
+ with open(c, "rb") as f:
28
+ st.download_button("Download", f.read(), file_name=os.path.basename(c))
29
+
30
+ else:
31
+ uploaded = st.file_uploader("Upload MP4 file", type=["mp4", "mov", "mkv"])
32
+ if uploaded is not None:
33
+ save_path = os.path.join("uploads", uploaded.name)
34
+ os.makedirs("uploads", exist_ok=True)
35
+
36
+ with open(save_path, "wb") as f:
37
+ f.write(uploaded.getbuffer())
38
+
39
+ if st.button("Generate Clips from Upload"):
40
+ with st.spinner("Processing upload…"):
41
+ clips = process_uploaded_file(save_path, out_dir=out_dir, num_clips=3)
42
+
43
+ st.success(f"Generated {len(clips)} clips")
44
+
45
+ for c in clips:
46
+ try:
47
+ st.video(c)
48
+ except:
49
+ st.write(f"Preview not available for {c}")
50
+
51
+ with open(c, "rb") as f:
52
+ st.download_button("Download", f.read(), file_name=os.path.basename(c))
53
+
54
+ st.markdown("---")
55
+ st.info("Starter version. Upgrade highlight detection & captions later.")