Skip to content

feat(video): add a preserveMetadata option to drop source metadata - #432

Open
simongt wants to merge 1 commit into
numandev1:mainfrom
simongt:feat/video-preserve-metadata
Open

simongt wants to merge 1 commit into
numandev1:mainfrom
simongt:feat/video-preserve-metadata

Conversation

@simongt

@simongt simongt commented Oct 27, 2026

Copy link
Copy Markdown

Summary

Since #399, 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. 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?: boolean to the video options. It defaults to true, so the output is unchanged unless a caller opts out. With false:

  • Android skips the location lookup (MediaMetadataRetriever and LocationExtractor), so MP4Builder writes no ©xyz box.
  • iOS doesn't forward the source metadata items to the writer.

The option takes the same path as stripAudio: through VideoCompressorHelper on Android, and the compression helpers in VideoMain.swift on iOS. Options are already an AnyMap, so there's no spec change, and yarn nitrogen produced no diff. The README has a new entry under videoCompresssionType.

Closes #431

Changelog

[GENERAL] [ADDED] - Add a preserveMetadata option to Video.compress to leave the source metadata, such as the GPS location, out of the output

Test Plan

  • Ran local JS PR gate: 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 on main).
  • If this changes compression/upload/download native behavior, ran the Harness tests on a simulator/device: yarn test:harness:android or yarn test:harness:ios. Not run: the harness spec has no Video.compress case, so it wouldn't exercise this. I ran it in an app instead, below.

I packed this branch (yarn prepack, then npm pack) into an Expo SDK 58 / React Native 0.88 app. Then I compressed two phone clips that carry a location, a Pixel .mp4 and an iPhone .MOV, with compressionMethod: 'manual', bitrate: 2_000_000 and maxSize: 1280: once with preserveMetadata: false and once with the option unset. I read each output's metadata with AVFoundation:

Device Option Pixel clip iPhone clip
Pixel 3 XL, Android 12 false no metadata, no ©xyz no metadata, no ©xyz
Pixel 3 XL, Android 12 unset ©xyz location ©xyz location
iPhone 17 Pro simulator, iOS 26.5 false no metadata no metadata
iPhone 17 Pro simulator, iOS 26.5 unset ©xyz location loci location and date

On Android the log also shows the lookup skipped: source location resolved: hasLocation=false source=not preserved. The video stays avc1 720×1280 at about 2 Mbps in every case.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Option to leave source metadata out of Video.compress output

1 participant