@@ -47,7 +47,7 @@ def report_stats(times: Tensor, unit: str = "ms", prefix: str = "") -> float:
4747def torchvision_resize (
4848 path : Path , pts_seconds : list [float ], dims : tuple [int , int ]
4949) -> None :
50- decoder = create_from_file (str (path ))
50+ decoder = create_from_file (str (path ), seek_mode = "approximate" )
5151 add_video_stream (decoder )
5252 raw_frames , * _ = get_frames_by_pts (decoder , timestamps = pts_seconds )
5353 return v2 .functional .resize (raw_frames , size = dims )
@@ -56,7 +56,7 @@ def torchvision_resize(
5656def torchvision_crop (
5757 path : Path , pts_seconds : list [float ], dims : tuple [int , int ], x : int , y : int
5858) -> None :
59- decoder = create_from_file (str (path ))
59+ decoder = create_from_file (str (path ), seek_mode = "approximate" )
6060 add_video_stream (decoder )
6161 raw_frames , * _ = get_frames_by_pts (decoder , timestamps = pts_seconds )
6262 return v2 .functional .crop (raw_frames , top = y , left = x , height = dims [0 ], width = dims [1 ])
@@ -65,15 +65,15 @@ def torchvision_crop(
6565def decoder_native_resize (
6666 path : Path , pts_seconds : list [float ], dims : tuple [int , int ]
6767) -> None :
68- decoder = create_from_file (str (path ))
68+ decoder = create_from_file (str (path ), seek_mode = "approximate" )
6969 add_video_stream (decoder , transform_specs = f"resize, { dims [0 ]} , { dims [1 ]} " )
7070 return get_frames_by_pts (decoder , timestamps = pts_seconds )[0 ]
7171
7272
7373def decoder_native_crop (
7474 path : Path , pts_seconds : list [float ], dims : tuple [int , int ], x : int , y : int
7575) -> None :
76- decoder = create_from_file (str (path ))
76+ decoder = create_from_file (str (path ), seek_mode = "approximate" )
7777 add_video_stream (decoder , transform_specs = f"crop, { dims [0 ]} , { dims [1 ]} , { x } , { y } " )
7878 return get_frames_by_pts (decoder , timestamps = pts_seconds )[0 ]
7979
0 commit comments