get error code -11843 while exporting mp3 file in ipod library since iOS 5.1 -


i use avassetexportsession export mp3/m4a files in ipod library. method works on ios 5.0 , earlier. after upgrade ios 5.1, method doesn't work mp3 anymore, still works m4a.

here source code.

avurlasset *songasset = [avurlasset urlassetwithurl: [mediaitem asseturl] options:nil];  nslog (@"compatible presets songasset: %@",[avassetexportsession exportpresetscompatiblewithasset:songasset]);  avassetexportsession *exporter = [[avassetexportsession alloc]                                   initwithasset: songasset                                   presetname: avassetexportpresetpassthrough];  nslog (@"created exporter. supportedfiletypes: %@", exporter.supportedfiletypes); nslog(@"output file type=%@",[mediaitem filetype]); nslog(@"export file path=%@",exportpath); exporter.outputfiletype =[mediaitem filetype];  nserror *error1; error1=0;  if([[nsfilemanager defaultmanager] fileexistsatpath:exportpath])  {      [[nsfilemanager defaultmanager] removeitematpath:exportpath error:&error1];     if(error1)         nslog(@"%@",error1);  }  nsurl* exporturl = [nsurl fileurlwithpath:exportpath];  exporter.outputurl = exporturl;   // export [exporter exportasynchronouslywithcompletionhandler:^{      int exportstatus = exporter.status;      switch (exportstatus) {          case avassetexportsessionstatusfailed: {              nserror *exporterror = exporter.error;              nslog (@"avassetexportsessionstatusfailed: %@", exporterror);             [delegate convertcancelled:self];             [exporter release];              break;         }          case avassetexportsessionstatuscompleted: {              nslog (@"avassetexportsessionstatuscompleted");             [delegate convertdone:self];             [exporter release];             break;         }          case avassetexportsessionstatusunknown: { nslog (@"avassetexportsessionstatusunknown");             break;         }         case avassetexportsessionstatusexporting: { nslog (@"avassetexportsessionstatusexporting");              break;         }          case avassetexportsessionstatuscancelled: { nslog (@"avassetexportsessionstatuscancelled");              nslog(@"cancellated");             [delegate convertcancelled:self];              break;         }          case avassetexportsessionstatuswaiting: {             nslog (@"avassetexportsessionstatuswaiting");             break;         }          default:          { nslog (@"didn't export status");              break;         }     }  }]; 

here message in console:

output file type=com.apple.quicktime-movie export file path=/private/var/mobile/applications/xxxxxx/tmp/i see light - instrumental cover.mp3 avassetexportsessionstatusfailed: error domain=avfoundationerrordomain code=-11843 "cannot write output file"  userinfo=0x93876e0 {nslocalizedrecoverysuggestion=change output extension , try again., nslocalizeddescription=cannot write output file} 

anyone knows why? error message tells me change file extension, not reasonable use other file extension mp3 file.

finally found workaround.

use avassetexportsession export append ".mov" @ end of export url. should make avassetexportsession export song. last step, rename exported file nsfilemanager, remove ".mov" @ end.

to rename file saved in documents directory, can use nsfilemanager below:

nsstring *exportfile = ... //.. path of saved *.mov file in documents directory nsstring *newpath = [[exportfile stringbydeletinglastpathcomponent] stringbyappendingpathcomponent:@"newfilename.mp3"];  nserror *renameerror = nil; [[nsfilemanager defaultmanager] moveitematpath:exportfile topath:newpath error:&renameerror];  if (renameerror) {     nslog (@"renameerror=%@",renameerror.localizeddescription); }else {     nslog (@" no renameerror(success) :: newpath=%@",newpath); } 

Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -