xmrt commited on
Commit
2f92165
1 Parent(s): f10c44c

added threads

Browse files
Files changed (1) hide show
  1. main_noweb.py +2 -38
main_noweb.py CHANGED
@@ -43,49 +43,13 @@ hand = MMPoseInferencer("hand", device=device)
43
 
44
  print("[INFO]: Downloaded models!")
45
 
46
- def check_fps(video):
47
- cap = cv2.VideoCapture(video)
48
- nframes = cap.get(cv2.CAP_PROP_FRAME_COUNT)
49
- fps = cap.get(cv2.CAP_PROP_FPS)
50
- return nframes, fps
51
-
52
-
53
- def get_frames(video, fps=50, height=512, width=512):
54
-
55
- clip = moviepy.VideoFileClip(video)
56
- print(clip.duration)
57
- if clip.duration > 10:
58
- raise gr.Error("Please provide or record a video shorter than 10 seconds...")
59
-
60
- split_tup = os.path.splitext(video)
61
-
62
- file_name = split_tup[0]
63
- file_extension = split_tup[1]
64
-
65
- if file_extension != ".mp4":
66
- print("Converting to mp4")
67
- video = file_name+".mp4"
68
-
69
- #check fps
70
- if clip.fps > fps:
71
- print("vide rate is over 15, resetting to 15")
72
- #clip_resized = moviepy.clip.resize(height=height)
73
- clip.write_videofile(video, fps=fps)
74
- else:
75
- print("video rate is OK")
76
- #clip_resized = clip.resize(height=height)
77
- #clip.write_videofile(video, fps=clip.fps)
78
- return video
79
-
80
-
81
  def check_extension(video):
82
 
83
  clip = moviepy.VideoFileClip(video)
84
- print(clip.duration)
85
  if clip.duration > 10:
86
  raise gr.Error("Please provide or record a video shorter than 10 seconds...")
87
 
88
-
89
  split_tup = os.path.splitext(video)
90
 
91
  # extract the file name and extension
@@ -96,7 +60,7 @@ def check_extension(video):
96
  print("Converting to mp4")
97
 
98
  video = file_name+".mp4"
99
- clip.write_videofile(video)
100
 
101
  return video
102
 
 
43
 
44
  print("[INFO]: Downloaded models!")
45
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  def check_extension(video):
47
 
48
  clip = moviepy.VideoFileClip(video)
49
+
50
  if clip.duration > 10:
51
  raise gr.Error("Please provide or record a video shorter than 10 seconds...")
52
 
 
53
  split_tup = os.path.splitext(video)
54
 
55
  # extract the file name and extension
 
60
  print("Converting to mp4")
61
 
62
  video = file_name+".mp4"
63
+ clip.write_videofile(video, threads = 8)
64
 
65
  return video
66