reab5555 commited on
Commit
302c86c
·
verified ·
1 Parent(s): 7a942e5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -36,7 +36,7 @@ def frame_to_timecode(frame_num, original_fps, desired_fps):
36
  seconds = int(total_seconds % 60)
37
  milliseconds = int((total_seconds - int(total_seconds)) * 1000)
38
  return f"{hours:02d}:{minutes:02d}:{seconds:02d}.{milliseconds:03d}"
39
-
40
  def get_face_embedding_and_emotion(face_img):
41
  face_tensor = torch.tensor(face_img).permute(2, 0, 1).unsqueeze(0).float() / 255
42
  face_tensor = (face_tensor - 0.5) / 0.5
@@ -92,6 +92,8 @@ def extract_frames(video_path, output_folder, fps):
92
  print(f"FFmpeg output: {e.output}")
93
  raise
94
 
 
 
95
  def extract_and_align_faces_from_video(video_path, aligned_faces_folder, desired_fps):
96
  print(f"Processing video: {video_path}")
97
 
@@ -111,7 +113,10 @@ def extract_and_align_faces_from_video(video_path, aligned_faces_folder, desired
111
  ]
112
  ffprobe_output = subprocess.check_output(ffprobe_command, universal_newlines=True).strip().split(',')
113
  frame_count = int(ffprobe_output[0])
114
- original_fps = eval(ffprobe_output[1])
 
 
 
115
 
116
  print(f"Total frames: {frame_count}, Original FPS: {original_fps}, Desired FPS: {desired_fps}")
117
 
 
36
  seconds = int(total_seconds % 60)
37
  milliseconds = int((total_seconds - int(total_seconds)) * 1000)
38
  return f"{hours:02d}:{minutes:02d}:{seconds:02d}.{milliseconds:03d}"
39
+
40
  def get_face_embedding_and_emotion(face_img):
41
  face_tensor = torch.tensor(face_img).permute(2, 0, 1).unsqueeze(0).float() / 255
42
  face_tensor = (face_tensor - 0.5) / 0.5
 
92
  print(f"FFmpeg output: {e.output}")
93
  raise
94
 
95
+ import fractions
96
+
97
  def extract_and_align_faces_from_video(video_path, aligned_faces_folder, desired_fps):
98
  print(f"Processing video: {video_path}")
99
 
 
113
  ]
114
  ffprobe_output = subprocess.check_output(ffprobe_command, universal_newlines=True).strip().split(',')
115
  frame_count = int(ffprobe_output[0])
116
+
117
+ # Convert fractional frame rate to float
118
+ frac = fractions.Fraction(ffprobe_output[1])
119
+ original_fps = float(frac.numerator) / float(frac.denominator)
120
 
121
  print(f"Total frames: {frame_count}, Original FPS: {original_fps}, Desired FPS: {desired_fps}")
122