asad231 commited on
Commit
8fd4d5c
·
verified ·
1 Parent(s): ea072d2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -22
app.py CHANGED
@@ -290,7 +290,7 @@ def download_video(url):
290
  except Exception as e:
291
  return None
292
 
293
- # ✅ Display Video (YouTube Embed or Small Size Video Player)
294
  video_path = None
295
 
296
  if uploaded_video is not None:
@@ -298,36 +298,18 @@ if uploaded_video is not None:
298
  with open(temp_file.name, "wb") as f:
299
  f.write(uploaded_video.read())
300
  video_path = temp_file.name # Set video path for detection
301
-
302
- # 🔹 **Small Video Display**
303
- st.markdown(
304
- f"""
305
- <video controls width="300">
306
- <source src="data:video/mp4;base64,{uploaded_video.getvalue().decode('utf-8')}" type="video/mp4">
307
- Your browser does not support the video tag.
308
- </video>
309
- """,
310
- unsafe_allow_html=True,
311
- )
312
 
313
  elif video_url:
314
  if "youtube.com" in video_url or "youtu.be" in video_url:
315
  st.markdown(
316
- f'<iframe width="300" height="170" src="{video_url.replace("watch?v=", "embed/")}" frameborder="0" allowfullscreen></iframe>',
317
  unsafe_allow_html=True,
318
  )
319
  else:
320
  video_path = download_video(video_url) # Download MP4
321
  if video_path:
322
- st.markdown(
323
- f"""
324
- <video controls width="300">
325
- <source src="{video_path}" type="video/mp4">
326
- Your browser does not support the video tag.
327
- </video>
328
- """,
329
- unsafe_allow_html=True,
330
- )
331
  else:
332
  st.warning("⚠️ Invalid MP4 URL.")
333
 
 
290
  except Exception as e:
291
  return None
292
 
293
+ # ✅ Display Video (YouTube Embed or Local)
294
  video_path = None
295
 
296
  if uploaded_video is not None:
 
298
  with open(temp_file.name, "wb") as f:
299
  f.write(uploaded_video.read())
300
  video_path = temp_file.name # Set video path for detection
301
+ st.video(video_path) # Show uploaded video
 
 
 
 
 
 
 
 
 
 
302
 
303
  elif video_url:
304
  if "youtube.com" in video_url or "youtu.be" in video_url:
305
  st.markdown(
306
+ f'<iframe width="560" height="315" src="{video_url.replace("watch?v=", "embed/")}" frameborder="0" allowfullscreen></iframe>',
307
  unsafe_allow_html=True,
308
  )
309
  else:
310
  video_path = download_video(video_url) # Download MP4
311
  if video_path:
312
+ st.video(video_path) # Show downloaded MP4
 
 
 
 
 
 
 
 
313
  else:
314
  st.warning("⚠️ Invalid MP4 URL.")
315