tomerk commited on
Commit
afca745
·
verified ·
1 Parent(s): a907004

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -1
app.py CHANGED
@@ -39,6 +39,8 @@ client = openai.OpenAI(api_key=api_key)
39
  stop_capture = False
40
  alerts_mode = True
41
 
 
 
42
  def clip_video_segment_2(input_video_path, start_time, duration):
43
  os.makedirs('videos', exist_ok=True)
44
  output_video_path = f"videos/{uuid.uuid4()}.mp4"
@@ -139,7 +141,7 @@ def process_clip(prompt, frames, chatbot, id):
139
  # Print current time in Israel
140
  israel_tz = pytz.timezone('Asia/Jerusalem')
141
  start_time = datetime.now(israel_tz).strftime('%H:%M:%S')
142
- print("[Start]:", start_time, len(frames))
143
 
144
  # Encode frames into a video clip
145
  fps = int(len(frames) / LENGTH)
@@ -185,10 +187,17 @@ def process_clip_from_file(prompt, frames, chatbot, fps, video_path, id):
185
  # Function to capture video frames
186
  def analyze_stream(prompt, chatbot):
187
  global stop_capture
 
188
  stop_capture = False
 
 
189
  # stream = "https://streamapi2.eu.loclx.io/video_feed/101"
190
  stream = "https://uqnmqpvwlbpmdvutucia.supabase.co/storage/v1/object/public/videos_test/junction.mp4?t=2024-12-26T09%3A58%3A11.931Z"
191
  cap = cv2.VideoCapture(stream or WEBCAM)
 
 
 
 
192
 
193
  frames = []
194
  start_time = time.time()
 
39
  stop_capture = False
40
  alerts_mode = True
41
 
42
+ base_start_time = time.time()
43
+
44
  def clip_video_segment_2(input_video_path, start_time, duration):
45
  os.makedirs('videos', exist_ok=True)
46
  output_video_path = f"videos/{uuid.uuid4()}.mp4"
 
141
  # Print current time in Israel
142
  israel_tz = pytz.timezone('Asia/Jerusalem')
143
  start_time = datetime.now(israel_tz).strftime('%H:%M:%S')
144
+ print("[Start]:", start_time, len(frames), id)
145
 
146
  # Encode frames into a video clip
147
  fps = int(len(frames) / LENGTH)
 
187
  # Function to capture video frames
188
  def analyze_stream(prompt, chatbot):
189
  global stop_capture
190
+ global base_start_time
191
  stop_capture = False
192
+ video_start = int(time.time() - base_start_time) % 180
193
+
194
  # stream = "https://streamapi2.eu.loclx.io/video_feed/101"
195
  stream = "https://uqnmqpvwlbpmdvutucia.supabase.co/storage/v1/object/public/videos_test/junction.mp4?t=2024-12-26T09%3A58%3A11.931Z"
196
  cap = cv2.VideoCapture(stream or WEBCAM)
197
+ fps = cap.get(cv2.CAP_PROP_FPS)
198
+ cap.set(cv2.CAP_PROP_POS_FRAMES, video_start*fps)
199
+
200
+ print("Vide start", video_start, fps)
201
 
202
  frames = []
203
  start_time = time.time()