Skip to content

Instantly share code, notes, and snippets.

@aliyevorkhan
Created May 10, 2021 12:16
Show Gist options
  • Save aliyevorkhan/f51e15b935e4c9915c27df649255d14d to your computer and use it in GitHub Desktop.
Save aliyevorkhan/f51e15b935e4c9915c27df649255d14d to your computer and use it in GitHub Desktop.
import cv2
import sys
import uuid
from tqdm import tqdm
video_name = str(sys.argv[1])
e_rate = int(sys.argv[2])
cap = cv2.VideoCapture(video_name+'.mp4')
frame_count = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
count=0
pbar = tqdm(total=frame_count,desc ="Extracting")
while True:
ret, frame = cap.read()
if not ret:
break
pbar.update(1)
if count%e_rate==0:
cv2.imwrite('orkhan_hand/'+str(uuid.uuid4())+'.jpg', frame)
count+=1
pbar.close()
@aliyevorkhan
Copy link
Author

simple usage: python3 extract_frame_tqdm.py video_name 5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment