Repository navigation
feat: add startTime/endTime to compressVideo for single-pass trim + compress - #13
Conversation
…ompress Trim-then-compress runs two full encodes on Android, the first at the source resolution (Media3 transcodes any clip that does not start on a keyframe). A range on compressVideo clips inside the same transform: ClippingConfiguration on Android, timeRange on the AVAssetExportSession and AVAssetReader on iOS. The size budget uses the trimmed duration, the smaller-than-original check and the inflation fallback are skipped for a range, and an empty range rejects before a session starts. Closes thangdevalone#12
|
Thanks for the contribution! The single-pass approach makes sense. Before updating this PR, I want to explain two correctness issues found during review and the changes I plan to make.
The intended behavior is unchanged when neither bound is supplied, and one-sided ranges remain supported. I will add regression coverage for omitted, empty, negative, reversed, out-of-bounds, and non-finite ranges, and rerun the checks after the update. The trimmed explicit-bitrate iOS path also needs verification that the output keeps only the requested range even when encoding increases the size. PR #14 has passed all three build checks and has been merged separately. I will bring this PR up to date with main as part of the fixes. |
|
One additional CI correction is needed to make the verification reliable: Turbo resolves the build task inputs relative to the I will qualify the library source, generated bridges, and podspec paths with |
Closes #12.
compressVideoaccepts optionalstartTime/endTimebounds in milliseconds, so a selected range can be trimmed and compressed in one encode instead of creating a re-encoded intermediate.The Android MediaItem and both iOS export paths use the selected range, and size budgets use its duration. Bounds remain optional through the native bridge: omitted values default to the source start/end; supplied values must be finite and satisfy
0 <= startTime < endTime <= duration, spanning at least one millisecond. Invalid ranges reject before starting an export or building Android's clipping configuration.Trimmed outputs are never replaced with the full source when encoding increases their size. Both iOS pipelines use the same tested fallback helper, including the explicit-bitrate reader/writer pipeline. Existing fallback behavior remains available for untrimmed, unmuted exports.
The Nitro bridge files and API documentation are updated. This branch includes the merged software-encoder fallback from #14.
Validation:
The library, iOS, and Android builds all passed for commit
54b9b03cb851c582098efd1ad2bd0cfe014cb04d: https://github.com/thangdevalone/react-native-media-toolkit/actions/runs/38731915633. Logs confirm native build cache misses, execution of the Android unit-test task, and all 30 Swift regression cases passing.Device codec end-to-end tests have not been run locally; the regression coverage above checks range validation and actual fallback file contents, and CI builds the complete native implementations.