1
1
import abc
2
- import json
3
2
import subprocess
4
3
import typing
5
4
import urllib .request
20
19
create_from_file ,
21
20
get_frames_at_indices ,
22
21
get_frames_by_pts ,
23
- get_json_metadata ,
24
22
get_next_frame ,
25
23
seek_to_pts ,
26
24
)
@@ -238,11 +236,7 @@ def decode_frames(self, video_file, pts_list):
238
236
color_conversion_library = self ._color_conversion_library ,
239
237
device = self ._device ,
240
238
)
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 )
246
240
return frames
247
241
248
242
def decode_first_n_frames (self , video_file , n ):
@@ -356,11 +350,7 @@ def decode_frames(self, video_file, pts_list):
356
350
color_conversion_library = self ._color_conversion_library ,
357
351
device = self ._device ,
358
352
)
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 )
364
354
return frames
365
355
366
356
def decode_first_n_frames (self , video_file , n ):
@@ -371,12 +361,8 @@ def decode_first_n_frames(self, video_file, n):
371
361
color_conversion_library = self ._color_conversion_library ,
372
362
device = self ._device ,
373
363
)
374
- metadata = json .loads (get_json_metadata (decoder ))
375
- best_video_stream = metadata ["bestVideoStreamIndex" ]
376
364
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 )
380
366
return frames
381
367
382
368
0 commit comments