xmrt commited on
Commit
7839c3e
·
1 Parent(s): beca0c4

test fps reduction function

Browse files
Files changed (1) hide show
  1. main_noweb.py +10 -8
main_noweb.py CHANGED
@@ -46,8 +46,8 @@ def check_fps(video):
46
  return nframes, fps
47
 
48
 
49
- def get_frames(video, fps=30, height=512, width=512):
50
- # extract the file name and extension
51
  split_tup = os.path.splitext(video)
52
 
53
  file_name = split_tup[0]
@@ -57,8 +57,12 @@ def get_frames(video, fps=30, height=512, width=512):
57
  print("Converting to mp4")
58
  video = file_name+".mp4"
59
 
 
60
  clip = moviepy.VideoFileClip(video)
61
 
 
 
 
62
  #check fps
63
  if clip.fps > fps:
64
  print("vide rate is over 15, resetting to 15")
@@ -67,10 +71,8 @@ def get_frames(video, fps=30, height=512, width=512):
67
  else:
68
  print("video rate is OK")
69
  #clip_resized = clip.resize(height=height)
70
- clip.write_videofile(video, fps=clip.fps)
71
 
72
- print("video resized to 512 height")
73
-
74
 
75
  def check_extension(video):
76
  split_tup = os.path.splitext(video)
@@ -194,9 +196,9 @@ def UI():
194
  submit_hand_file = gr.Button("Make 2d hand estimation")
195
 
196
  with gr.Row():
197
- video_output1 = gr.Video(height=512, label = "Estimate human 2d poses", show_label=True)
198
- video_output2 = gr.Video(height=512, label = "Estimate human 3d poses", show_label=True)
199
- video_output3 = gr.Video(height=512, label = "Estimate human hand poses", show_label=True)
200
 
201
  gr.Markdown("Download the .json file that contains the keypoint positions for each frame in the video.")
202
  jsonoutput = gr.File(file_types=[".json"])
 
46
  return nframes, fps
47
 
48
 
49
+ def get_frames(video, fps=20, height=512, width=512):
50
+
51
  split_tup = os.path.splitext(video)
52
 
53
  file_name = split_tup[0]
 
57
  print("Converting to mp4")
58
  video = file_name+".mp4"
59
 
60
+
61
  clip = moviepy.VideoFileClip(video)
62
 
63
+ if clip.duration > 10:
64
+ raise gr.Error("Please provide or record a video shorter than 10 seconds...")
65
+
66
  #check fps
67
  if clip.fps > fps:
68
  print("vide rate is over 15, resetting to 15")
 
71
  else:
72
  print("video rate is OK")
73
  #clip_resized = clip.resize(height=height)
74
+ #clip.write_videofile(video, fps=clip.fps)
75
 
 
 
76
 
77
  def check_extension(video):
78
  split_tup = os.path.splitext(video)
 
196
  submit_hand_file = gr.Button("Make 2d hand estimation")
197
 
198
  with gr.Row():
199
+ video_output1 = gr.PlayableVideo(height=512, label = "Estimate human 2d poses", show_label=True)
200
+ video_output2 = gr.PlayableVideo(height=512, label = "Estimate human 3d poses", show_label=True)
201
+ video_output3 = gr.PlayableVideo(height=512, label = "Estimate human hand poses", show_label=True)
202
 
203
  gr.Markdown("Download the .json file that contains the keypoint positions for each frame in the video.")
204
  jsonoutput = gr.File(file_types=[".json"])