Repository navigation
Add get_image_metadata() with JPEG support - #1788
Merged
Merged
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/meta-pytorch/torchcodec/1788
Note: Links to docs will display an error until the docs builds have been completed. This comment was automatically generated by Dr. CI and updates every 15 minutes. |
Adds get_image_metadata(source) -> ImageMetadata(format, width, height, num_channels, bit_depth, num_frames, rotation), which parses the image headers without decoding. Every field describes the output of the decoders: post-rotation width/height, channels with mode="UNCHANGED", bit_depth > 8 iff output_dtype="auto" returns uint16, and rotation with the same convention as VideoStreamMetadata.rotation. Paths are read lazily, so only the headers are read. This PR adds the core and JPEG support, parsed in Python (faster than calling into libjpeg).
NicolasHug
force-pushed
the
image_metadata_1_jpeg
branch
from
October 28, 2026 10:40
b3b42d6 to
b808c75
Compare
NicolasHug
commented
Oct 28, 2026
| # is constant. | ||
| for diff in seconds_between_clip_starts: | ||
| assert diff == pytest.approx(seconds_between_clip_starts[0], abs=0.05) | ||
| assert diff == pytest.approx(seconds_between_clip_starts[0].item(), abs=0.05) |
Contributor
Author
There was a problem hiding this comment.
drive for new pytest version which tries to iterate on this 0-d tensor (ugh)
NicolasHug
marked this pull request as ready for review
October 28, 2026 11:14
This was referenced Oct 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
First of various PRs to add image metadata probing. This one is for JPEG. The probes are 100% vibed, obviously. Some will be in Python, some will be in C++, depending on benchmark results on small and large image files.
Adds
get_image_metadata(source) -> ImageMetadata(format, width, height, num_channels, bit_depth, num_frames, rotation), which parses the image headers without decoding. Every field describes the output of the decoders: post-rotation width/height, channels with mode="UNCHANGED", bit_depth > 8 iff output_dtype="auto" returns uint16, and rotation with the same convention as VideoStreamMetadata.rotation.Stack created with GitHub Stacks CLI • Give Feedback 💬