Skip to content

fix(editor): copy video as playable pasteboard MP4 data - #337

Open
YuriNachos wants to merge 1 commit into
sw33tLie:mainfrom
YuriNachos:YuriNachos/w3-macshot
Open

fix(editor): copy video as playable pasteboard MP4 data#337
YuriNachos wants to merge 1 commit into
sw33tLie:mainfrom
YuriNachos:YuriNachos/w3-macshot

Conversation

@YuriNachos

@YuriNachos YuriNachos commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Closes #329.

Problem

Copy in the video editor wrote only a file URL to the pasteboard. Apps that do not resolve file URLs from the pasteboard (Mail, Notes, Preview) therefore could not paste the recording — the paste was empty.

Fix

Write the video bytes inline on the pasteboard as public.mpeg-4 alongside the file URL, so inline-preferring apps can paste it. The bytes are advertised as MP4 only when they really are MP4:

  • Edited export branch — the export pipeline re-encodes to an MP4 container (AVAssetExportSession outputFileType = .mp4 / AVAssetWriter(fileType: .mp4)), so the bytes are MP4 regardless of the source name. Passes contentIsMP4: true.
  • Direct source-copy branch — gated on UTType(filenameExtension:)?.conforms(to: .mpeg4Movie). .mp4/.m4v → inline bytes; .mov (QuickTime) → falls back to the file URL only (the pre-[BUG] Video editor Copy reports success but clipboard only contains a file URL #329 behavior), so QuickTime bytes are never mislabeled as MP4 and rejected by inline-preferring apps.

Recordings over ~150 MB and read errors also fall back to the file URL. A FileManager size pre-check avoids the OOM/jetsam risk of Data(contentsOf:) on huge files, so the documented "huge file" fallback now actually delivers.

Also adds a CHANGELOG entry.

Verification

  • Build green (xcodebuild build).
  • Confirmed at runtime that UTType(filenameExtension:)?.conforms(to: .mpeg4Movie) behaves as expected: mp4 → true, m4v → true, mov → false, missing extension → false.
  • Manual: paste a copied recording into Mail/Notes/Preview and confirm it pastes as playable video.

Notes

Two pre-existing rough edges surface via this change but are intentionally not fixed here (separate concerns, they mirror the existing copyGIFData path): the Data(contentsOf:) read is synchronous on the main thread (bounded by the 150 MB cap, same as GIF), and exportEditedTemp names the temp file with the source extension while always writing MP4 bytes (only the inline path is correct today).

Copy in the video editor wrote only a file URL, so Mail/Notes/Preview
could not paste the recording (sw33tLie#329). Write MP4 bytes inline as
public.mpeg-4 alongside the file URL, but only when the content really
is MP4: either the export pipeline re-encoded it (.mp4) or the source
extension conforms to mpeg4Movie. Non-MP4 sources (.mov) and recordings
over ~150 MB fall back to the file URL to avoid mislabeling and OOM.
@YuriNachos

Copy link
Copy Markdown
Contributor Author

Thanks for landing the timecode and GIF export fixes yesterday — good to see those in. This one closes #329 by writing the recording inline as public.mpeg-4 alongside the file URL, so Mail and Notes can finally paste a copied video; the remaining checkbox on my side is the manual paste pass, which I can extend to more apps if that helps. Is anything else needed from me, or is there something about the inline-bytes approach you'd like to talk through first?

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.

[BUG] Video editor Copy reports success but clipboard only contains a file URL

1 participant