decord icon indicating copy to clipboard operation
decord copied to clipboard

How can I quickly sort files for thousands of video data sets in terms of duration/frames?

Open cuixing158 opened this issue 4 years ago • 0 comments
trafficstars

How can I quickly sort files for thousands of video data sets in terms of duration/frames? In the usual way, the length of the video is sorted using the following code orderdNames = VideoNames[np.argsort([len(decord.VideoReader(x)) for x in VideoNames])] VideoReader(x) one by one to get the total number of frames in the video is very time consuming, is there any good technique to increase the efficiency? Thank you! The results of the test in 9848 videos are as follows:

 t1 = time.time()
framesList1 = [cv2.VideoCapture(x).get(cv2.CAP_PROP_FRAME_COUNT) for x in VideoNames]
t2 = time.time()
framesList2 = [len(decord.VideoReader(x)) for x in VideoNames]
t3 = time.time()
import operator
print('opencv 耗时:{}\n'.format(t2-t1))
print('decord 耗时:{}\n'.format(t3-t2))

opencv 耗时:177.791166305542 秒

decord 耗时:255.77367973327637 秒 How are the results explained?

cuixing158 avatar Jun 22 '21 11:06 cuixing158