@@ -646,6 +646,7 @@ def test_audio_bad_seek_mode(self):
646646 "range" ,
647647 (
648648 "begin_to_end" ,
649+ "begin_to_None" ,
649650 "begin_to_beyond_end" ,
650651 "at_frame_boundaries" ,
651652 "not_at_frame_boundaries" ,
@@ -655,6 +656,8 @@ def test_audio_bad_seek_mode(self):
655656 def test_get_frames_by_pts_in_range_audio (self , range , asset ):
656657 if range == "begin_to_end" :
657658 start_seconds , stop_seconds = 0 , asset .duration_seconds
659+ elif range == "begin_to_None" :
660+ start_seconds , stop_seconds = 0 , None
658661 elif range == "begin_to_beyond_end" :
659662 start_seconds , stop_seconds = 0 , asset .duration_seconds + 10
660663 elif range == "at_frame_boundaries" :
@@ -671,18 +674,23 @@ def test_get_frames_by_pts_in_range_audio(self, range, asset):
671674 stop_frame_info .duration_seconds / 2
672675 )
673676
674- decoder = create_from_file (str (asset .path ), seek_mode = "approximate" )
675- add_audio_stream (decoder )
676-
677- # stop_offset logic: if stop_seconds is at a frame boundary i.e. when a
678- # frame starts, then that frame should *not* be included in the output.
679- # Otherwise, it should be part of it, hence why we add 1 to `stop=`.
680- stop_offset = 0 if range == "at_frame_boundaries" else 1
677+ ref_start_index = asset .get_frame_index (pts_seconds = start_seconds )
678+ if range == "begin_to_None" :
679+ ref_stop_index = (
680+ asset .get_frame_index (pts_seconds = asset .duration_seconds ) + 1
681+ )
682+ elif range == "at_frame_boundaries" :
683+ ref_stop_index = asset .get_frame_index (pts_seconds = stop_seconds )
684+ else :
685+ ref_stop_index = asset .get_frame_index (pts_seconds = stop_seconds ) + 1
681686 reference_frames = asset .get_frame_data_by_range (
682- start = asset . get_frame_index ( pts_seconds = start_seconds ) ,
683- stop = asset . get_frame_index ( pts_seconds = stop_seconds ) + stop_offset ,
687+ start = ref_start_index ,
688+ stop = ref_stop_index ,
684689 )
685690
691+ decoder = create_from_file (str (asset .path ), seek_mode = "approximate" )
692+ add_audio_stream (decoder )
693+
686694 frames = get_frames_by_pts_in_range_audio (
687695 decoder , start_seconds = start_seconds , stop_seconds = stop_seconds
688696 )
0 commit comments