scanner-research / hwang

Fast sparse video decode
33 stars 12 forks source link

'list index out of range' occured when trying to retrieve the frame at the end of the video #1

Open Haotianz94 opened 6 years ago

Haotianz94 commented 6 years ago

Hi Alex,

I am Haotian. When I used this lib to retrieve the frame at the end of the video, I met the error of 'list index out of range'. A simple test case is shown below:

import cv2
cap = cv2.VideoCapture('../data/videos/CNNW_20150219_200000_CNN_Newsroom_With_Brooke_Baldwin.mp4')
video_frames = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
print(video_frames)

storage = StorageBackend.make_from_config(StorageConfig.make_gcs_config('esper'))
video_path = 'tvnews/videos/CNNW_20150219_200000_CNN_Newsroom_With_Brooke_Baldwin.mp4'
video_file = RandomReadFile(storage, video_path.encode('ascii'))
video = Decoder(video_file)
img_list = video.retrieve([109600])

While this video has total frames of 109714.

Error is like:

IndexError                                Traceback (most recent call last)
<ipython-input-105-172b45060365> in <module>()
      7 video_file = RandomReadFile(storage, video_path.encode('ascii'))
      8 video = Decoder(video_file)
----> 9 img_list = video.retrieve([109600])

/home/zhanghaotiansola/.local/lib/python2.7/site-packages/hwang/decoder.pyc in retrieve(self, rows)
     34             start_offset = self.video_index.sample_offsets[start_index]
     35             end_offset = (
---> 36                 self.video_index.sample_offsets[end_index] +
     37                 self.video_index.sample_sizes[end_index])
     38             # Read data buffer

IndexError: list index out of range

Thank you!

fpoms commented 6 years ago

I'll look into this by this week. Apologies for the delay!