Skip to content

Audio decoding support: range-based core API #538

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 28 commits into from
Mar 12, 2025
Merged
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
ae15304
Add basic range support
NicolasHug Mar 6, 2025
29e0b8d
Add more tests
NicolasHug Mar 6, 2025
cad69da
Merge branch 'main' of github.com:pytorch/torchcodec into audioooooooo
NicolasHug Mar 6, 2025
04f6282
Add separate audio decoding method
NicolasHug Mar 7, 2025
f8dfcda
Merge branch 'main' of github.com:pytorch/torchcodec into audioooooooo
NicolasHug Mar 7, 2025
da40954
More stuff
NicolasHug Mar 7, 2025
3881586
Cleanups
NicolasHug Mar 7, 2025
82bea4a
Remove old code
NicolasHug Mar 7, 2025
ce12f03
More validation, more tests
NicolasHug Mar 8, 2025
59b0d15
remove next() support
NicolasHug Mar 8, 2025
f4bed23
Rename
NicolasHug Mar 8, 2025
fe04cd2
Add support for None stop_seconds
NicolasHug Mar 8, 2025
98fee85
Remove pre-alloc logic
NicolasHug Mar 8, 2025
d2357fe
Add test
NicolasHug Mar 8, 2025
f3b56f8
Add proper error when backward seek is neede
NicolasHug Mar 8, 2025
5f2800a
Cleanup
NicolasHug Mar 8, 2025
2f020f2
Add TODO
NicolasHug Mar 9, 2025
0c11f72
Put back original compilation flags
NicolasHug Mar 9, 2025
de4facc
Fix
NicolasHug Mar 9, 2025
b5f2df0
nit
NicolasHug Mar 9, 2025
09e6f44
Oops, fix
NicolasHug Mar 9, 2025
3d955c1
Add case for start=stop
NicolasHug Mar 9, 2025
d791d2a
Simplify
NicolasHug Mar 9, 2025
0c0f62b
Don't use a lambda
NicolasHug Mar 9, 2025
893c358
Merge branch 'main' of github.com:pytorch/torchcodec into audioooooooo
NicolasHug Mar 11, 2025
c35ae47
Fix
NicolasHug Mar 11, 2025
c453a3c
Address comments
NicolasHug Mar 12, 2025
dafb927
Add comment
NicolasHug Mar 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Cleanup
  • Loading branch information
NicolasHug committed Mar 8, 2025
commit 5f2800a80c6df0d9d9cc99cfc2a20b6c93450e4d
16 changes: 7 additions & 9 deletions test/decoders/test_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -661,12 +661,12 @@ def test_get_frames_by_pts_in_range_audio(self, range, asset):
elif range == "begin_to_beyond_end":
start_seconds, stop_seconds = 0, asset.duration_seconds + 10
elif range == "at_frame_boundaries":
start_seconds = asset.frames[asset.default_stream_index][10].pts_seconds
stop_seconds = asset.frames[asset.default_stream_index][40].pts_seconds
start_seconds = asset.get_frame_info(idx=10).pts_seconds
stop_seconds = asset.get_frame_info(idx=40).pts_seconds
else:
assert range == "not_at_frame_boundaries"
start_frame_info = asset.frames[asset.default_stream_index][10]
stop_frame_info = asset.frames[asset.default_stream_index][40]
start_frame_info = asset.get_frame_info(idx=10)
stop_frame_info = asset.get_frame_info(idx=40)
start_seconds = start_frame_info.pts_seconds + (
start_frame_info.duration_seconds / 2
)
Expand Down Expand Up @@ -716,8 +716,8 @@ def test_decode_just_one_frame_at_boundaries(self, asset, expected_shape):
decoder = create_from_file(str(asset.path), seek_mode="approximate")
add_audio_stream(decoder)

start_seconds = asset.frames[asset.default_stream_index][10].pts_seconds
stop_seconds = asset.frames[asset.default_stream_index][11].pts_seconds
start_seconds = asset.get_frame_info(idx=10).pts_seconds
stop_seconds = asset.get_frame_info(idx=11).pts_seconds
frames = get_frames_by_pts_in_range_audio(
decoder, start_seconds=start_seconds, stop_seconds=stop_seconds
)
Expand Down Expand Up @@ -761,9 +761,7 @@ def get_reference_frames(start_seconds, stop_seconds):
# Starting at the frame immediately after the previous one is OK
index_of_frame_at_4 = asset.get_frame_index(pts_seconds=4)
start_seconds, stop_seconds = (
asset.frames[asset.default_stream_index][
index_of_frame_at_4 + 1
].pts_seconds,
asset.get_frame_info(idx=index_of_frame_at_4 + 1).pts_seconds,
5,
)
frames = get_frames_by_pts_in_range_audio(
Expand Down
Loading