11import abc
2- import json
32import subprocess
43import typing
54import urllib .request
2019 create_from_file ,
2120 get_frames_at_indices ,
2221 get_frames_by_pts ,
23- get_json_metadata ,
2422 get_next_frame ,
2523 seek_to_pts ,
2624)
@@ -238,11 +236,7 @@ def decode_frames(self, video_file, pts_list):
238236 color_conversion_library = self ._color_conversion_library ,
239237 device = self ._device ,
240238 )
241- metadata = json .loads (get_json_metadata (decoder ))
242- best_video_stream = metadata ["bestVideoStreamIndex" ]
243- frames , * _ = get_frames_by_pts (
244- decoder , stream_index = best_video_stream , timestamps = pts_list
245- )
239+ frames , * _ = get_frames_by_pts (decoder , timestamps = pts_list )
246240 return frames
247241
248242 def decode_first_n_frames (self , video_file , n ):
@@ -356,11 +350,7 @@ def decode_frames(self, video_file, pts_list):
356350 color_conversion_library = self ._color_conversion_library ,
357351 device = self ._device ,
358352 )
359- metadata = json .loads (get_json_metadata (decoder ))
360- best_video_stream = metadata ["bestVideoStreamIndex" ]
361- frames , * _ = get_frames_by_pts (
362- decoder , stream_index = best_video_stream , timestamps = pts_list
363- )
353+ frames , * _ = get_frames_by_pts (decoder , timestamps = pts_list )
364354 return frames
365355
366356 def decode_first_n_frames (self , video_file , n ):
@@ -371,12 +361,8 @@ def decode_first_n_frames(self, video_file, n):
371361 color_conversion_library = self ._color_conversion_library ,
372362 device = self ._device ,
373363 )
374- metadata = json .loads (get_json_metadata (decoder ))
375- best_video_stream = metadata ["bestVideoStreamIndex" ]
376364 indices_list = list (range (n ))
377- frames , * _ = get_frames_at_indices (
378- decoder , stream_index = best_video_stream , frame_indices = indices_list
379- )
365+ frames , * _ = get_frames_at_indices (decoder , frame_indices = indices_list )
380366 return frames
381367
382368
0 commit comments