Hi
I'm wondering what the correct way to save an m4b file is. Even if I just open a file and then immediately save it, the chapters information gets lost, like in this straightforward function:
func openSave(fileName: String, newFileName: String) {
let fileUrl = URL(fileURLWithPath: fileName)
let asset = AVURLAsset(url: fileUrl)
let metadata = asset.metadata
let exporter = AVAssetExportSession(asset: asset,
presetName: AVAssetExportPresetPassthrough)
exporter?.outputURL = URL(fileURLWithPath: newFileName)
exporter?.outputFileType = AVFileType.m4a
exporter?.metadata = metadata
exporter?.exportAsynchronously {
if exporter?.status == .completed {
print("completed")
} else if exporter?.status == .failed {
print("M4bFile.write error \(newFileName)")
}
}
}
So what am I doing wrong? If I open a new file, all other tags are still there, but the chapter list is not, or rather asset.availableChapterLocales is empty.
Alex