Update app.py
Browse files
app.py
CHANGED
@@ -42,17 +42,21 @@ def get_frames(video_in, step, name):
|
|
42 |
frames = []
|
43 |
#resize the video
|
44 |
clip = VideoFileClip(video_in)
|
45 |
-
|
|
|
|
|
|
|
|
|
46 |
|
47 |
#check fps
|
48 |
-
if
|
49 |
print("video rate is over 25, resetting to 25")
|
50 |
clip_resized = clip.resize(height=1024)
|
51 |
clip_resized.write_videofile("video_resized.mp4", fps=25)
|
52 |
else:
|
53 |
print("video rate is OK")
|
54 |
clip_resized = clip.resize(height=1024)
|
55 |
-
clip_resized.write_videofile("video_resized.mp4", fps=
|
56 |
|
57 |
print("video resized to 1024 height")
|
58 |
|
@@ -60,7 +64,10 @@ def get_frames(video_in, step, name):
|
|
60 |
cap = cv2.VideoCapture("video_resized.mp4")
|
61 |
|
62 |
fps = cap.get(cv2.CAP_PROP_FPS)
|
63 |
-
|
|
|
|
|
|
|
64 |
i=0
|
65 |
while(cap.isOpened()):
|
66 |
ret, frame = cap.read()
|
|
|
42 |
frames = []
|
43 |
#resize the video
|
44 |
clip = VideoFileClip(video_in)
|
45 |
+
if clip.fps:
|
46 |
+
cfps = clip.fps
|
47 |
+
else:
|
48 |
+
cfps = 1
|
49 |
+
print("video fps: " + str(cfps))
|
50 |
|
51 |
#check fps
|
52 |
+
if cfps > 25:
|
53 |
print("video rate is over 25, resetting to 25")
|
54 |
clip_resized = clip.resize(height=1024)
|
55 |
clip_resized.write_videofile("video_resized.mp4", fps=25)
|
56 |
else:
|
57 |
print("video rate is OK")
|
58 |
clip_resized = clip.resize(height=1024)
|
59 |
+
clip_resized.write_videofile("video_resized.mp4", fps=cfps)
|
60 |
|
61 |
print("video resized to 1024 height")
|
62 |
|
|
|
64 |
cap = cv2.VideoCapture("video_resized.mp4")
|
65 |
|
66 |
fps = cap.get(cv2.CAP_PROP_FPS)
|
67 |
+
if fps:
|
68 |
+
print("video fps: " + str(fps))
|
69 |
+
else:
|
70 |
+
fps = 1
|
71 |
i=0
|
72 |
while(cap.isOpened()):
|
73 |
ret, frame = cap.read()
|