小编use*_*209的帖子

如何正确使用AVAssetExportSession为音频资产设置元数据?

我已经查看了我可以找到的用于设置元数据的每个示例AVAssetExportSession,但即使音频导出工作正常(结果音频文件播放正常),仍然没有随文件导出的元数据.我正在使用Xcode 4.5,目标构建iOS 5,测试设备iOS 6.请看下面我正在使用的代码,请让我知道我做错了什么.

// for metadata export

NSArray *MyMetadata;
AVMutableMetadataItem *common1;
AVMutableMetadataItem *common2;
AVMutableMetadataItem *common3;
AVMutableMetadataItem *common4;
Run Code Online (Sandbox Code Playgroud)

履行

AVAsset *asset = [AVAsset assetWithURL:audioFileInput];
AVAssetExportSession *exportSession = [AVAssetExportSession exportSessionWithAsset:asset presetName:AVAssetExportPresetPassthrough];

if (!exportSession) {
    return;
}

CMTime startTime = CMTimeMake((int)(floor(fileStartMarker * 100)), 100);
CMTime stopTime = CMTimeMake((int)(ceil(fileEndMarker * 100)), 100);
CMTimeRange exportTimeRange = CMTimeRangeFromTimeToTime(startTime, stopTime);

exportSession.outputURL = audioFileOutput;
exportSession.outputFileType = @"com.apple.coreaudio-format";
exportSession.timeRange = exportTimeRange;

// define meta data for file
// Common metadata
common1 = [[AVMutableMetadataItem alloc] init]; …
Run Code Online (Sandbox Code Playgroud)

audio metadata ios avassetexportsession

23
推荐指数
1
解决办法
4674
查看次数

标签 统计

audio ×1

avassetexportsession ×1

ios ×1

metadata ×1