tomerk commited on
Commit
734480f
·
verified ·
1 Parent(s): c27893f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -12
app.py CHANGED
@@ -10,7 +10,7 @@ from concurrent.futures import ThreadPoolExecutor, as_completed
10
  from datetime import datetime
11
  import json
12
  import os
13
- from moviepy.editor import ImageSequenceClip
14
  from gradio_client import Client, file
15
  import subprocess
16
  import ffmpeg
@@ -89,19 +89,19 @@ def encode_to_video_fast(frames, fps):
89
  return video_clip_path
90
 
91
 
92
- def encode_to_video(frames, fps):
93
- os.makedirs('videos', exist_ok=True)
94
- video_clip_path = f"videos/{uuid.uuid4()}.mp4"
95
 
96
- # Create a video clip from the frames using moviepy
97
- clip = ImageSequenceClip([frame[:, :, ::-1] for frame in frames], fps=fps) # Convert from BGR to RGB
98
- clip.write_videofile(video_clip_path, codec="libx264")
99
 
100
- # Convert the video file to base64
101
- with open(video_clip_path, "rb") as video_file:
102
- video_data = base64.b64encode(video_file.read()).decode('utf-8')
103
 
104
- return video_clip_path
105
 
106
  # Function to process video frames using GPT-4 API
107
  def process_frames(frames, frames_to_skip = 1):
@@ -167,7 +167,7 @@ def process_clip(prompt, frames, chatbot):
167
 
168
  if api_response["condition_met"] == True:
169
  finish_time = datetime.now(israel_tz).strftime('%H:%M:%S')
170
- video_clip_path = encode_to_video(frames, fps)
171
  chatbot.append(((video_clip_path,), None))
172
  chatbot.append((f"Time: {start_time}\nDetails: {api_response.get('details', '')}", None))
173
 
 
10
  from datetime import datetime
11
  import json
12
  import os
13
+ # from moviepy.editor import ImageSequenceClip
14
  from gradio_client import Client, file
15
  import subprocess
16
  import ffmpeg
 
89
  return video_clip_path
90
 
91
 
92
+ # def encode_to_video(frames, fps):
93
+ # os.makedirs('videos', exist_ok=True)
94
+ # video_clip_path = f"videos/{uuid.uuid4()}.mp4"
95
 
96
+ # # Create a video clip from the frames using moviepy
97
+ # clip = ImageSequenceClip([frame[:, :, ::-1] for frame in frames], fps=fps) # Convert from BGR to RGB
98
+ # clip.write_videofile(video_clip_path, codec="libx264")
99
 
100
+ # # Convert the video file to base64
101
+ # with open(video_clip_path, "rb") as video_file:
102
+ # video_data = base64.b64encode(video_file.read()).decode('utf-8')
103
 
104
+ # return video_clip_path
105
 
106
  # Function to process video frames using GPT-4 API
107
  def process_frames(frames, frames_to_skip = 1):
 
167
 
168
  if api_response["condition_met"] == True:
169
  finish_time = datetime.now(israel_tz).strftime('%H:%M:%S')
170
+ video_clip_path = encode_to_video_fast(frames, fps)
171
  chatbot.append(((video_clip_path,), None))
172
  chatbot.append((f"Time: {start_time}\nDetails: {api_response.get('details', '')}", None))
173