fix(editor): copy video as playable pasteboard MP4 data - #337
Open
YuriNachos wants to merge 1 commit into
Open
Conversation
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.
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 |
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.
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-4alongside the file URL, so inline-preferring apps can paste it. The bytes are advertised as MP4 only when they really are MP4:AVAssetExportSessionoutputFileType = .mp4/AVAssetWriter(fileType: .mp4)), so the bytes are MP4 regardless of the source name. PassescontentIsMP4: true.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
FileManagersize pre-check avoids the OOM/jetsam risk ofData(contentsOf:)on huge files, so the documented "huge file" fallback now actually delivers.Also adds a CHANGELOG entry.
Verification
xcodebuild build).UTType(filenameExtension:)?.conforms(to: .mpeg4Movie)behaves as expected:mp4→ true,m4v→ true,mov→ false, missing extension → false.Notes
Two pre-existing rough edges surface via this change but are intentionally not fixed here (separate concerns, they mirror the existing
copyGIFDatapath): theData(contentsOf:)read is synchronous on the main thread (bounded by the 150 MB cap, same as GIF), andexportEditedTempnames the temp file with the source extension while always writing MP4 bytes (only the inline path is correct today).