freealise commited on
Commit
01586cc
1 Parent(s): 0d110ca

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -4
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
- print("video fps: " + str(clip.fps))
 
 
 
 
46
 
47
  #check fps
48
- if clip.fps > 25:
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=clip.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
- print("video fps: " + str(fps))
 
 
 
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()