Update app.py
Browse files
app.py
CHANGED
|
@@ -52,57 +52,7 @@ with tab2:
|
|
| 52 |
if st.button("Process Video"):
|
| 53 |
st.warning('This feature is under construction and will be developed in a future project.')
|
| 54 |
|
| 55 |
-
|
| 56 |
-
"""
|
| 57 |
-
# Function to download YouTube video
|
| 58 |
-
def download_youtube_video(url):
|
| 59 |
-
yt = YouTube(url)
|
| 60 |
-
stream = yt.streams.filter(file_extension='mp4').first()
|
| 61 |
-
video = stream.download()
|
| 62 |
-
return video
|
| 63 |
-
|
| 64 |
-
st.header('Video Upload and Processing (To Do)')
|
| 65 |
-
|
| 66 |
-
# Setup your Twelve Labs client
|
| 67 |
-
# Assuming 'client' is set up here (use your actual client initialization)
|
| 68 |
-
# client = TwelveLabsClient(api_key="your_api_key")
|
| 69 |
-
|
| 70 |
-
# Container for video input
|
| 71 |
-
with st.container():
|
| 72 |
-
st.write("Video Input")
|
| 73 |
-
video_file = st.file_uploader("Upload a video file", type=["mp4", "avi"])
|
| 74 |
-
youtube_url = st.text_input("Or paste a YouTube URL here:")
|
| 75 |
-
|
| 76 |
-
# Container for video processing output
|
| 77 |
-
with st.container():
|
| 78 |
-
st.write("Video Processing")
|
| 79 |
-
|
| 80 |
-
if st.button("Process Video"):
|
| 81 |
-
if video_file is not None:
|
| 82 |
-
video_path = video_file.name
|
| 83 |
-
with open(video_path, mode='wb') as f:
|
| 84 |
-
f.write(video_file.getbuffer())
|
| 85 |
-
elif youtube_url:
|
| 86 |
-
video_path = download_youtube_video(youtube_url)
|
| 87 |
-
else:
|
| 88 |
-
st.warning("Please upload a video file or enter a YouTube URL.")
|
| 89 |
-
st.stop()
|
| 90 |
-
|
| 91 |
-
print(f"Uploading {video_path}")
|
| 92 |
-
task = client.task.create(index_id="<YOUR_INDEX_ID>", file=video_path, language="en")
|
| 93 |
-
st.success(f"Task id={task.id}")
|
| 94 |
-
|
| 95 |
-
# Optional: Monitor the video indexing process
|
| 96 |
-
def on_task_update(task: Task):
|
| 97 |
-
st.write(f"Status={task.status}")
|
| 98 |
-
|
| 99 |
-
task.wait_for_done(callback=on_task_update)
|
| 100 |
-
|
| 101 |
-
if task.status != "ready":
|
| 102 |
-
st.error(f"Indexing failed with status {task.status}")
|
| 103 |
-
else:
|
| 104 |
-
st.success(f"Uploaded {video_path}. The unique identifier of your video is {task.video_id}.")
|
| 105 |
-
"""
|
| 106 |
|
| 107 |
with tab3:
|
| 108 |
|
|
|
|
| 52 |
if st.button("Process Video"):
|
| 53 |
st.warning('This feature is under construction and will be developed in a future project.')
|
| 54 |
|
| 55 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
|
| 57 |
with tab3:
|
| 58 |
|