Repository navigation
Conversation
Video.compress copies the source video's metadata into the output on both platforms: Android writes the location as a udta/©xyz box, and iOS forwards every source metadata item to the writer. An app that uploads the compressed video has no way to leave the location out. preserveMetadata defaults to true, so the output is unchanged unless the caller opts out. With false, Android skips the location lookup and writes no ©xyz box, and iOS forwards no source metadata. The option takes the same path as stripAudio.
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.
Summary
Since #399,
Video.compresscopies the source video's metadata into the output on both platforms: Android writes the location as audta/©xyzbox, and iOS forwards every source metadata item to the writer. An app that uploads the compressed video has no way to leave the location out. We drop GPS from photos before they leave the device, and right now we carry a local patch to do the same for video.This adds
preserveMetadata?: booleanto the video options. It defaults totrue, so the output is unchanged unless a caller opts out. Withfalse:MediaMetadataRetrieverandLocationExtractor), soMP4Builderwrites no©xyzbox.The option takes the same path as
stripAudio: throughVideoCompressorHelperon Android, and the compression helpers inVideoMain.swifton iOS. Options are already anAnyMap, so there's no spec change, andyarn nitrogenproduced no diff. The README has a new entry undervideoCompresssionType.Closes #431
Changelog
[GENERAL] [ADDED] - Add a
preserveMetadataoption toVideo.compressto leave the source metadata, such as the GPS location, out of the outputTest Plan
yarn test:pr. 14 tests pass, including a new one for the option forwarding. Typecheck is clean, and lint has 0 errors (the 9 warnings are already onmain).yarn test:harness:androidoryarn test:harness:ios. Not run: the harness spec has noVideo.compresscase, so it wouldn't exercise this. I ran it in an app instead, below.I packed this branch (
yarn prepack, thennpm pack) into an Expo SDK 58 / React Native 0.88 app. Then I compressed two phone clips that carry a location, a Pixel.mp4and an iPhone.MOV, withcompressionMethod: 'manual',bitrate: 2_000_000andmaxSize: 1280: once withpreserveMetadata: falseand once with the option unset. I read each output's metadata with AVFoundation:false©xyz©xyz©xyzlocation©xyzlocationfalse©xyzlocationlocilocation anddateOn Android the log also shows the lookup skipped:
source location resolved: hasLocation=false source=not preserved. The video staysavc1720×1280 at about 2 Mbps in every case.