Skip to content

Commit b32aabe

Browse files
authored
Add test to illustrate audio bug (#568)
1 parent 64919ba commit b32aabe

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test/decoders/test_ops.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,23 @@ def test_pts(self, asset):
860860

861861
assert pts_seconds == start_seconds
862862

863+
def test_decode_before_frame_start(self):
864+
# Test illustrating bug described in
865+
# https://github.com/pytorch/torchcodec/issues/567
866+
asset = NASA_AUDIO_MP3
867+
868+
decoder = create_from_file(str(asset.path), seek_mode="approximate")
869+
add_audio_stream(decoder)
870+
871+
frames, *_ = get_frames_by_pts_in_range_audio(
872+
decoder, start_seconds=0, stop_seconds=0.05
873+
)
874+
all_frames, *_ = get_frames_by_pts_in_range_audio(
875+
decoder, start_seconds=0, stop_seconds=None
876+
)
877+
# TODO fix this. `frames` should be empty.
878+
torch.testing.assert_close(frames, all_frames)
879+
863880

864881
if __name__ == "__main__":
865882
pytest.main()

0 commit comments

Comments
 (0)