@@ -691,19 +691,23 @@ def test_get_frames_by_pts_in_range_audio(self, range, asset):
691
691
decoder = create_from_file (str (asset .path ), seek_mode = "approximate" )
692
692
add_audio_stream (decoder )
693
693
694
- frames = get_frames_by_pts_in_range_audio (
694
+ frames , pts_seconds = get_frames_by_pts_in_range_audio (
695
695
decoder , start_seconds = start_seconds , stop_seconds = stop_seconds
696
696
)
697
-
698
697
torch .testing .assert_close (frames , reference_frames )
699
698
699
+ if range == "at_frames_boundaries" :
700
+ assert pts_seconds == start_seconds
701
+ elif range == "not_at_frames_boundaries" :
702
+ assert pts_seconds == start_frame_info .pts_seconds
703
+
700
704
@pytest .mark .parametrize ("asset" , (NASA_AUDIO , NASA_AUDIO_MP3 ))
701
705
def test_decode_epsilon_range (self , asset ):
702
706
decoder = create_from_file (str (asset .path ), seek_mode = "approximate" )
703
707
add_audio_stream (decoder )
704
708
705
709
start_seconds = 5
706
- frames = get_frames_by_pts_in_range_audio (
710
+ frames , * _ = get_frames_by_pts_in_range_audio (
707
711
decoder , start_seconds = start_seconds , stop_seconds = start_seconds + 1e-5
708
712
)
709
713
torch .testing .assert_close (
@@ -720,7 +724,7 @@ def test_decode_just_one_frame_at_boundaries(self, asset):
720
724
721
725
start_seconds = asset .get_frame_info (idx = 10 ).pts_seconds
722
726
stop_seconds = asset .get_frame_info (idx = 11 ).pts_seconds
723
- frames = get_frames_by_pts_in_range_audio (
727
+ frames , pts_seconds = get_frames_by_pts_in_range_audio (
724
728
decoder , start_seconds = start_seconds , stop_seconds = stop_seconds
725
729
)
726
730
torch .testing .assert_close (
@@ -729,15 +733,17 @@ def test_decode_just_one_frame_at_boundaries(self, asset):
729
733
asset .get_frame_index (pts_seconds = start_seconds )
730
734
),
731
735
)
736
+ assert pts_seconds == start_seconds
732
737
733
738
@pytest .mark .parametrize ("asset" , (NASA_AUDIO , NASA_AUDIO_MP3 ))
734
739
def test_decode_start_equal_stop (self , asset ):
735
740
decoder = create_from_file (str (asset .path ), seek_mode = "approximate" )
736
741
add_audio_stream (decoder )
737
- frames = get_frames_by_pts_in_range_audio (
742
+ frames , pts_seconds = get_frames_by_pts_in_range_audio (
738
743
decoder , start_seconds = 1 , stop_seconds = 1
739
744
)
740
745
assert frames .shape == (0 ,)
746
+ assert pts_seconds == 0
741
747
742
748
@pytest .mark .parametrize ("asset" , (NASA_AUDIO , NASA_AUDIO_MP3 ))
743
749
def test_multiple_calls (self , asset ):
0 commit comments