Update app.py
Browse files
app.py
CHANGED
|
@@ -1167,6 +1167,33 @@ def display_videos_and_links(num_columns):
|
|
| 1167 |
cols = st.columns(num_columns) # Define num_columns columns outside the loop
|
| 1168 |
col_index = 0 # Initialize column index
|
| 1169 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1170 |
for video_file in video_files_sorted:
|
| 1171 |
with cols[col_index % num_columns]: # Use modulo to alternate between columns
|
| 1172 |
k = video_file.split('.')[0] # Assumes keyword is the file name without extension
|
|
|
|
| 1167 |
cols = st.columns(num_columns) # Define num_columns columns outside the loop
|
| 1168 |
col_index = 0 # Initialize column index
|
| 1169 |
|
| 1170 |
+
for video_file in video_files_sorted:
|
| 1171 |
+
with cols[col_index % num_columns]: # Use modulo to alternate between columns
|
| 1172 |
+
k = video_file.split('.')[0] # Assumes keyword is the file name without extension
|
| 1173 |
+
st.video(video_file, format='video/mp4', start_time=0)
|
| 1174 |
+
display_glossary_entity(k)
|
| 1175 |
+
|
| 1176 |
+
# Add text input for video file
|
| 1177 |
+
video_text_input = st.text_input(f"Video Prompt for {video_file}", key=f"video_prompt_{video_file}")
|
| 1178 |
+
if video_text_input:
|
| 1179 |
+
try:
|
| 1180 |
+
seconds_per_frame = float(video_text_input)
|
| 1181 |
+
process_video(video_file, seconds_per_frame)
|
| 1182 |
+
except ValueError:
|
| 1183 |
+
st.error(f"Invalid input for seconds per frame: {video_text_input}. Please enter a valid number.")
|
| 1184 |
+
|
| 1185 |
+
col_index += 1 # Increment column index to place the next video in the next column
|
| 1186 |
+
|
| 1187 |
+
def display_videos_and_links_old2(num_columns):
|
| 1188 |
+
video_files = [f for f in os.listdir('.') if f.endswith('.mp4')]
|
| 1189 |
+
if not video_files:
|
| 1190 |
+
st.write("No MP4 videos found in the current directory.")
|
| 1191 |
+
return
|
| 1192 |
+
|
| 1193 |
+
video_files_sorted = sorted(video_files, key=lambda x: len(x.split('.')[0]))
|
| 1194 |
+
cols = st.columns(num_columns) # Define num_columns columns outside the loop
|
| 1195 |
+
col_index = 0 # Initialize column index
|
| 1196 |
+
|
| 1197 |
for video_file in video_files_sorted:
|
| 1198 |
with cols[col_index % num_columns]: # Use modulo to alternate between columns
|
| 1199 |
k = video_file.split('.')[0] # Assumes keyword is the file name without extension
|