मैंने AVAssetExportSession
का उपयोग करके मेटा डेटा सेट करने के लिए हर उदाहरण को देखा है, लेकिन ऑडियो निर्यात ठीक काम करता है (परिणामी ऑडियो फ़ाइल ठीक है), अभी भी फ़ाइल के साथ निर्यात किए गए कोई मेटा डेटा नहीं है। मैं एक्सकोड 4.5 का उपयोग कर रहा हूं, लक्ष्य आईओएस 5, परीक्षण डिवाइस आईओएस 6 का उपयोग कर रहा हूं। कृपया नीचे दिए गए कोड को देखें, और कृपया मुझे बताएं कि मैं क्या गलत कर रहा हूं।ऑडियो संपत्ति के लिए मेटाडेटा सेट करने के लिए AVAssetExportSession का सही तरीके से उपयोग कैसे करें?
हैडर
// for metadata export
NSArray *MyMetadata;
AVMutableMetadataItem *common1;
AVMutableMetadataItem *common2;
AVMutableMetadataItem *common3;
AVMutableMetadataItem *common4;
कार्यान्वयन
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]; // Title
common1.keySpace = AVMetadataKeySpaceCommon;
common1.key = AVMetadataCommonKeyTitle;
common1.value = @"Title Test Value";
common2 = [[AVMutableMetadataItem alloc] init]; // Description
common2.keySpace = AVMetadataKeySpaceCommon;
common2.key = AVMetadataCommonKeyDescription;
common2.value = @"Description Test Value";
common3 = [[AVMutableMetadataItem alloc] init]; // Creation Date
common3.keySpace = AVMetadataKeySpaceCommon;
common3.key = AVMetadataCommonKeyCreationDate;
common3.value = @"Creation Date Test Value";
common4 = [[AVMutableMetadataItem alloc] init]; // Software
common4.keySpace = AVMetadataKeySpaceCommon;
common4.key = AVMetadataCommonKeySoftware;
common4.value = @"My File Trimmer";
MyMetadata = [[NSArray alloc] initWithObjects:common1, common2, common3, common4, nil];
exportSession.metadata = MyMetadata;
[common1 release];
[common2 release];
[common3 release];
[common4 release];
[exportSession exportAsynchronouslyWithCompletionHandler:^{
if (exportSession.status == AVAssetExportSessionStatusCompleted) {
// export done
}
else if (exportSession.status == AVAssetExportSessionStatusFailed) {
// export failed
}
}];
[MyMetadata release];
अद्यतन: एक ही कोड का उपयोग करते हुए, लेकिन इसके बजाय, सीएएफ निर्यात करता है, तो मैं बस ठीक मेटाडाटा निर्यात M4A को निर्यात की। – user15209
मेटाडेटा क्या है और इसके लिए क्या उपयोग किया जाता है? – jgvb
@ user15209 आपको अपनी टिप्पणी को उत्तर के रूप में जोड़ना चाहिए और इसे स्वीकार करना चाहिए –