CosmickVisions commited on
Commit
806d7f2
·
verified ·
1 Parent(s): 0d1d899

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -31
app.py CHANGED
@@ -1683,43 +1683,30 @@ def main():
1683
  # Offer download of processed video
1684
  st.success("Video processing complete!")
1685
  st.download_button(
1686
- label="Download Processed Video",
1687
  data=processed_video,
1688
  file_name=f"processed_{uploaded_file.name}",
1689
  mime="video/mp4"
1690
  )
1691
 
1692
- # Add clearer instructions
1693
- st.markdown("""
1694
- ### Video Playback Options
1695
- - **Option 1:** Download and play the video locally (recommended)
1696
- - **Option 2:** Try the embedded player below (may not work in all browsers)
1697
 
1698
- ⚠️ Note: If the player controls aren't responding, please download the video
1699
- for the best viewing experience.
1700
- """)
1701
-
1702
- # Display processed video
1703
- st.video(processed_video)
1704
-
1705
- # Add custom HTML video player with better compatibility
1706
- st.markdown("### Processed Video")
1707
-
1708
- # Create a base64 encoded version of the video for embedding
1709
- b64_video = base64.b64encode(processed_video).decode()
1710
-
1711
- # Create custom HTML with video element that has full controls
1712
- video_html = f"""
1713
- <video width="100%" controls>
1714
- <source src="data:video/mp4;base64,{b64_video}" type="video/mp4">
1715
- Your browser does not support the video tag.
1716
- </video>
1717
- """
1718
- st.markdown(video_html, unsafe_allow_html=True)
1719
-
1720
- # Keep the regular player as a fallback option
1721
- st.markdown("### Alternative Player (if HTML player doesn't work)")
1722
- st.video(processed_video)
1723
 
1724
  # Show detailed analysis results
1725
  st.markdown("### Detailed Analysis Results")
 
1683
  # Offer download of processed video
1684
  st.success("Video processing complete!")
1685
  st.download_button(
1686
+ label="⬇️ Download Processed Video",
1687
  data=processed_video,
1688
  file_name=f"processed_{uploaded_file.name}",
1689
  mime="video/mp4"
1690
  )
1691
 
1692
+ # Extract and display thumbnail frames instead of video playback
1693
+ st.markdown("### Video Preview")
1694
+ st.info("To view the full video with analysis results, please download using the button above and play it locally.")
 
 
1695
 
1696
+ # Show preview frames
1697
+ try:
1698
+ st.markdown("#### Preview Frames")
1699
+ frames = extract_video_frames(processed_video, num_frames=4)
1700
+
1701
+ if frames:
1702
+ cols = st.columns(len(frames))
1703
+ for i, frame in enumerate(frames):
1704
+ with cols[i]:
1705
+ st.image(frame, caption=f"Frame {i+1}", use_container_width=True)
1706
+ else:
1707
+ st.warning("Could not extract preview frames from the video.")
1708
+ except Exception as e:
1709
+ st.error(f"Error extracting preview frames: {str(e)}")
 
 
 
 
 
 
 
 
 
 
 
1710
 
1711
  # Show detailed analysis results
1712
  st.markdown("### Detailed Analysis Results")