Start at random time for 100 frames
This commit is contained in:
parent
581fcd8c85
commit
c9c0dd14b5
|
@ -19,15 +19,19 @@ class Video:
|
||||||
|
|
||||||
print("The total number of frames in this video is ", totalframecount)
|
print("The total number of frames in this video is ", totalframecount)
|
||||||
|
|
||||||
# self.cap.set(cv2.CAP_PROP_POS_FRAMES, randint(0, totalframecount* 0.9))
|
i = randint(0, int(totalframecount * 0.9))
|
||||||
|
self.cap.set(cv2.CAP_PROP_POS_FRAMES, i)
|
||||||
|
|
||||||
# Read until video is completed
|
# Read until video is completed
|
||||||
fps = self.cap.get(cv2.CAP_PROP_FPS)
|
fps = self.cap.get(cv2.CAP_PROP_FPS)
|
||||||
delay = 1/fps * 1000
|
delay = 1/fps * 1000
|
||||||
print(fps, delay)
|
print(fps, delay)
|
||||||
|
i = 0
|
||||||
|
while(self.cap.isOpened() ):
|
||||||
|
i += 1
|
||||||
|
if i > 100:
|
||||||
|
break
|
||||||
|
|
||||||
while(self.cap.isOpened()):
|
|
||||||
|
|
||||||
# Capture frame-by-frame
|
# Capture frame-by-frame
|
||||||
ret, frame = self.cap.read()
|
ret, frame = self.cap.read()
|
||||||
if ret == True:
|
if ret == True:
|
||||||
|
@ -48,18 +52,18 @@ class Video:
|
||||||
self.cap.release()
|
self.cap.release()
|
||||||
|
|
||||||
# Closes all the frames
|
# Closes all the frames
|
||||||
cv2.destroyAllWindows()
|
#cv2.destroyAllWindows()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
video = Video(0, 0)
|
video = Video(0, 0)
|
||||||
x = multiprocessing.Process(target = video.start, args=("slave/sample-mp4-file.mp4",))
|
x = multiprocessing.Process(target = video.start, args=("slave/videos/sample-mp4-file.mp4",))
|
||||||
x.start()
|
x.start()
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
x.terminate()
|
x.terminate()
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
video = Video(4000, 0)
|
video = Video(4000, 0)
|
||||||
x = multiprocessing.Process(target = video.start, args=("slave/sample-mp4-file.mp4",))
|
x = multiprocessing.Process(target = video.start, args=("slave/videos/sample-mp4-file.mp4",))
|
||||||
x.start()
|
x.start()
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
x.terminate()
|
x.terminate()
|
||||||
|
|
Loading…
Reference in New Issue