- Note: This is an adaptation for iOS of the sample code project associated with WWDC20 session 10011: Authoring Fragmented MPEG-4 with AVAssetWriter.
- Select the iOSWriter schema and run it.
The segment generation will start after the view controller is loaded and once it's done, it'll show you a UIActivityController
to share the output folder.
Notice that the input video is 10 seconds long but the output is only 6 seconds long.
Before you run the sample code project in Xcode:
- Edit the shared scheme called
fmp4Writer
. - Open the Run action.
- Replace the <path to movie file on disk> argument with the path to a movie file on your local hard drive.
- Replace the <path to output directory> argument with your desired output directory; for example
~/Desktop/fmp4writer/
.
- Use an asset from the app bundle instead of reading the asset from the file system.
- Copy the code from main.swift file to the ViewController.swift
- In
videoCompressionSettings
, change the value of the keykVTCompressionPropertyKey_ProfileLevel
fromkVTProfileLevel_H264_High_4_2
tokVTProfileLevel_H264_High_4_1
.