@@ -227,9 +227,12 @@ def get_consecutive_frames_from_video(self, video_file, numFramesToDecode):
227227 )
228228 return frames
229229
230+
230231class TorchCodecPublic (AbstractDecoder ):
231232 def __init__ (self , num_ffmpeg_threads = None ):
232- self ._num_ffmpeg_threads = int (num_ffmpeg_threads ) if num_ffmpeg_threads else None
233+ self ._num_ffmpeg_threads = (
234+ int (num_ffmpeg_threads ) if num_ffmpeg_threads else None
235+ )
233236
234237 def get_frames_from_video (self , video_file , pts_list ):
235238 decoder = VideoDecoder (video_file , num_ffmpeg_threads = self ._num_ffmpeg_threads )
@@ -246,6 +249,7 @@ def get_consecutive_frames_from_video(self, video_file, numFramesToDecode):
246249 break
247250 return frames
248251
252+
249253@torch .compile (fullgraph = True , backend = "eager" )
250254def compiled_seek_and_next (decoder , pts ):
251255 seek_to_pts (decoder , pts )
@@ -468,9 +472,11 @@ def plot_data(df_data, plot_path):
468472 plot_path ,
469473 )
470474
475+
471476def get_metadata (video_file_path : str ) -> VideoStreamMetadata :
472477 return VideoDecoder (video_file_path ).metadata
473478
479+
474480def run_benchmarks (
475481 decoder_dict : dict [str , AbstractDecoder ],
476482 video_files_paths : list [str ],
@@ -492,9 +498,7 @@ def run_benchmarks(
492498 metadata_label = f"{ metadata .codec } { metadata .width } x{ metadata .height } , { metadata .duration_seconds } s { metadata .average_fps } fps"
493499
494500 duration = metadata .duration_seconds
495- uniform_pts_list = [
496- i * duration / num_samples for i in range (num_samples )
497- ]
501+ uniform_pts_list = [i * duration / num_samples for i in range (num_samples )]
498502
499503 # Note that we are using the same random pts values for all decoders for the same
500504 # video. However, because we use the duration as part of this calculation, we
@@ -504,7 +508,10 @@ def run_benchmarks(
504508 for decoder_name , decoder in decoder_dict .items ():
505509 print (f"video={ video_file_path } , decoder={ decoder_name } " )
506510
507- for kind , pts_list in [("uniform" , uniform_pts_list ), ("random" , random_pts_list )]:
511+ for kind , pts_list in [
512+ ("uniform" , uniform_pts_list ),
513+ ("random" , random_pts_list ),
514+ ]:
508515 if verbose :
509516 print (
510517 f"video={ video_file_path } , decoder={ decoder_name } , pts_list={ pts_list } "
0 commit comments