When I try to extract frames from some videos of the HMDB51 dataset, I find I get fewer frames than expected, the code is
<code>def dump_frames(vid_path):
# import cv2
# video = cv2.VideoCapture(vid_path)
video =
vid_name = vid_path.split('/')[-1].split('.')[0]
out_full_path = os.path.join(out_path, vid_name)
# fcount = int(video.get(cv2.CV_CAP_PROP_FRAME_COUNT))
fcount = int(video.get(cv2.CAP_PROP_FRAME_COUNT))
print("Total frame count is", fcount)
try:
os.mkdir(out_full_path)
except OSError:
pass
file_list = []
for i in range(fcount):
ret, frame = video.read()
# print(i, fcount)
# assert ret
cv2.imwrite('{}\{:06d}.jpg'.format(out_full_path, i), frame)
access_path = '{}\{:06d}.jpg'.format(vid_name, i)
file_list.append(access_path)
print('{} done'.format(vid_name))
sys.stdout.flush()
return file_list
dump_frames("April_09_brush_hair_u_nm_np1_ba_goo_0.avi")
</code>
<code>def dump_frames(vid_path):
# import cv2
# video = cv2.VideoCapture(vid_path)
video =
vid_name = vid_path.split('/')[-1].split('.')[0]
out_full_path = os.path.join(out_path, vid_name)
# fcount = int(video.get(cv2.CV_CAP_PROP_FRAME_COUNT))
fcount = int(video.get(cv2.CAP_PROP_FRAME_COUNT))
print("Total frame count is", fcount)
try:
os.mkdir(out_full_path)
except OSError:
pass
file_list = []
for i in range(fcount):
ret, frame = video.read()
# print(i, fcount)
# assert ret
cv2.imwrite('{}\{:06d}.jpg'.format(out_full_path, i), frame)
access_path = '{}\{:06d}.jpg'.format(vid_name, i)
file_list.append(access_path)
print('{} done'.format(vid_name))
sys.stdout.flush()
return file_list
dump_frames("April_09_brush_hair_u_nm_np1_ba_goo_0.avi")
</code>
def dump_frames(vid_path):
# import cv2
# video = cv2.VideoCapture(vid_path)
video =
vid_name = vid_path.split('/')[-1].split('.')[0]
out_full_path = os.path.join(out_path, vid_name)
# fcount = int(video.get(cv2.CV_CAP_PROP_FRAME_COUNT))
fcount = int(video.get(cv2.CAP_PROP_FRAME_COUNT))
print("Total frame count is", fcount)
try:
os.mkdir(out_full_path)
except OSError:
pass
file_list = []
for i in range(fcount):
ret, frame = video.read()
# print(i, fcount)
# assert ret
cv2.imwrite('{}\{:06d}.jpg'.format(out_full_path, i), frame)
access_path = '{}\{:06d}.jpg'.format(vid_name, i)
file_list.append(access_path)
print('{} done'.format(vid_name))
sys.stdout.flush()
return file_list
dump_frames("April_09_brush_hair_u_nm_np1_ba_goo_0.avi")
How can I get the full number of all the frames?