Slide 56
Slide 56 text
"7"TTFU8SJUFS%FMFHBUFͷॲཧ
155Իͷॲཧ
func assetWriter(_ writer: AVAssetWriter, didOutputSegmentData segmentData: Data, segmentType:
AVAssetSegmentType, segmentReport: AVAssetSegmentReport?) {
switch segmentType {
case .initialization:
// mp4ϑΝΠϧ࡞
let fileName = "\(segmentIndex).mp4"
try! segmentData.write(to: URL(fileURLWithPath: fileName, isDirectory: false, relativeTo:
outputDirectoryURL))
case .separable:
// ηάϝϯτϑΝΠϧ࡞
let fileName = "\(segmentIndex).m4s"
try! segmentData.write(to: URL(fileURLWithPath: fileName, isDirectory: false, relativeTo:
outputDirectoryURL))
extinf += "#EXTINF:\(String(format: "%1.5f",
segmentReport!.trackReports.first!.duration.seconds)),\t\n\(fileName)\n"
@unknown default:
print("Skipping segment with unrecognized type")
return
}
// m3u8ϑΝΠϧ࡞
generateIndexFile(segmentData, segmentReport: segmentReport)
segmentIndex += 1
}