CosmickVisions commited on
Commit
0d1d899
·
verified ·
1 Parent(s): 8200d20

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -1
app.py CHANGED
@@ -724,7 +724,16 @@ def process_video_file(video_file, analysis_types):
724
  st.info(f"Output video will be slowed down to {output_fps:.1f} FPS (60% of original speed) for better visualization.")
725
 
726
  # Create video writer with higher quality settings
727
- fourcc = cv2.VideoWriter_fourcc(*'mp4v') # MP4 codec
 
 
 
 
 
 
 
 
 
728
  out = cv2.VideoWriter(output_path, fourcc, output_fps, (width, height), isColor=True)
729
 
730
  # Process every Nth frame to reduce API calls but increase from 10 to 5 for more detail
 
724
  st.info(f"Output video will be slowed down to {output_fps:.1f} FPS (60% of original speed) for better visualization.")
725
 
726
  # Create video writer with higher quality settings
727
+ try:
728
+ # First try H.264 codec (most widely compatible)
729
+ if cv2.__version__.startswith('4'):
730
+ fourcc = cv2.VideoWriter_fourcc(*'avc1') # H.264 codec
731
+ else:
732
+ # Fallback to older codec naming
733
+ fourcc = cv2.VideoWriter_fourcc(*'H264')
734
+ except Exception:
735
+ # If H.264 isn't available, fall back to MP4V
736
+ fourcc = cv2.VideoWriter_fourcc(*'mp4v')
737
  out = cv2.VideoWriter(output_path, fourcc, output_fps, (width, height), isColor=True)
738
 
739
  # Process every Nth frame to reduce API calls but increase from 10 to 5 for more detail