Update app.py
Browse files
app.py
CHANGED
@@ -131,10 +131,18 @@ def main():
|
|
131 |
|
132 |
source_path = None
|
133 |
uploaded_file = None
|
134 |
-
if source_type == "Video File":
|
135 |
-
|
136 |
-
|
137 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
138 |
elif source_type == "RTSP Stream":
|
139 |
source_path = st.text_input("Enter RTSP URL", placeholder="rtsp://your-camera-url")
|
140 |
|
|
|
131 |
|
132 |
source_path = None
|
133 |
uploaded_file = None
|
134 |
+
if source_type == "Video File" and source_path:
|
135 |
+
# Create a temporary file with a specific extension
|
136 |
+
temp_dir = tempfile.gettempdir()
|
137 |
+
temp_path = os.path.join(temp_dir, 'temp_video.mp4')
|
138 |
+
with open(temp_path, 'wb') as f:
|
139 |
+
f.write(source_path.getvalue())
|
140 |
+
|
141 |
+
cap = cv2.VideoCapture(temp_path)
|
142 |
+
if not cap.isOpened():
|
143 |
+
st.error("Error: Could not open video file. Please ensure it's a supported format (MP4 with H.264 encoding recommended)")
|
144 |
+
return None
|
145 |
+
return cap
|
146 |
elif source_type == "RTSP Stream":
|
147 |
source_path = st.text_input("Enter RTSP URL", placeholder="rtsp://your-camera-url")
|
148 |
|