feat(source_sampling): sample keyframes from remote video through a byte-range reader - #636
Merged
Merged
Conversation
…yte-range reader KEYFRAMES sampling now seeks to each bin start and extracts each selected keyframe on its own, instead of decoding every keyframe in the window in one pass. It selects the same frames and writes byte-identical JPEGs, and reads only the bytes near the selected keyframes. hflow.serve_byte_ranges serves a caller's ByteRangeReader to FFmpeg on loopback, so probe_video and sample_source_frames can read an object in storage without downloading it. Reader failures are re-raised as the reader's own exception rather than reported as unreadable media.
Contributor
|
…found; join loopback handlers; refuse unverifiable digests
Contributor
|
Want your agent to iterate on Greptile's feedback? Try greploops. |
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.
Lets
probe_videoandsample_source_framesread a video in object storage without downloading it.KEYFRAMESseeks per bin. It used to decode every keyframe in the window in one pass, which reads the whole window even though it keeps at mostmaximum_frames. It now probes each bin start for its first keyframe and extracts that keyframe on its own. Selection and JPEG bytes are unchanged, soSOURCE_FRAME_SAMPLING_VERSIONstaysv1:tests/test_byte_range_source.pycompares both against the old one-pass command across B-frames, scene-cut keyframes, a nonzero container start, mid-video windows, 1 to 16 frames, and both canvas modes.hflow.serve_byte_ranges(reader)serves a caller'sByteRangeReader(size_bytes,read_range(start, stop)) to FFmpeg on 127.0.0.1 and yields a source both functions accept in place of a path. It fetches 256 KiB blocks as FFmpeg reads them and caches them for thewithblock. Credentials stay in the reader. A reader exception is re-raised as itself, never asUnreadableVideoorSourceSamplingError.hflow.sources.PinnedSourceRangeReaderis that reader for an obstore object: it takes aSourceExpectationwith the revision and size (refusing a digest it cannot verify), sends the version with every range, and re-checks revision, path, and size, so a replaced object raisesSourceReadError.On four 90 MB, 2-minute test files (MP4 with the index at either end, MOV with B-frames, MKV), probing plus 3-frame
KEYFRAMES_FIRSTsampling fetched 4.5 to 5.5 MB.UNIFORM,NEAREST_KEYFRAMES, and the keyframes-first fallback still read the whole window.