Get Error Code -11843 While Exporting Mp3 File in Ipod Library Since iOS 5.1

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

Finally found a workaround.

Use AVAssetExportSession to export but append ".mov" at the end of export url.
This should make AVAssetExportSession successfully export the song.
Last step, rename the exported file with NSFileManager, remove the ".mov" at end.

To rename a file saved in documents directory, you can use NSFileManager as 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);
}

Songs imported from ipod Library not working for iOS 5.1 but Works fine for 5.0 and later OS

Finally i got answer from here

really it's nice solution given by Albert.

How can I export an mp3 file from an iOS device's iPod library?

I am facing the same problem. Unfortunately, non of the iOS frameworks (AVFoundation, CoreMedia, etc) support encoding to MP3.

An answer to a similar question suggest using the Lame Encoder, and another question mentions that some user was able to compile is successfully for iOS ("I have just attempted to build the static library for LAME and confirmed that it 'works'...").

Another alternative would be to go with FFMpeg. It seems like some users have successfully compiled it for iOS 4.3 (see this reference).

Take into account that you may have to pay royalties for encoding MP3. Also, the licenses for FFMpeg/Lame may prevent you from using their code in a closed-source application.

Good luck!

GetAudio Plugin for MvvmCross

Found the solution. As I thought the error was in the outputURL file.

Changed it to:

        var count = 0;
string filePath = null;
do
{
var extension = "mp3.mov";//( NSString *)UTTypeCopyPreferredTagWithClass(( CFStringRef)AVFileTypeQuickTimeMovie, kUTTagClassFilenameExtension);
var fileNameNoExtension = "AUD_" + Guid.NewGuid ().ToString ();
var fileName = (count == 0) ? fileNameNoExtension : string.Format ("{0}({1})", fileNameNoExtension, count);
filePath = NSBundle.MainBundle.BundlePath + "/../tmp/" + fileName; /* HERE WAS THE FIRST PROBLEM, USE NSBUNDLE... */
filePath = filePath + fileName + "." + extension;
count++;

} while (manager.FileExists (filePath));
var outputURL = NSUrl.FromFilename(filePath); /* HERE WAAS THE SECOND PROBLEM, CREATE IT WITH FROMFILENAME INSTEAD OF NEW... */

And then in the export, just remove the .mov extension...

        var withoutMOVPath = outputURL.Path.Remove(outputURL.Path.Length - 4);
NSError error = null;
manager.Move (outputURL.Path, withoutMOVPath, out error);

if(error != null && assumeCancelled != null)
{
assumeCancelled();
return;
}

var mediaStream = new FileStream (withoutMOVPath, FileMode.Open);
mediaAvailable (mediaStream);
break;

Adding and including LAME static libraries to xcode 5

When using a static library, you need 2 things:

  • The static library itself (.a)
  • Header files to access its public interface

In the list of libraries you've posted, it would seem libmp3lame.a is the one you require. The three listed above it are for individual architectures, whereas the last one is a 'fat library', which is a collection of the individual architecture libraries. You can confirm this by running lipo on the fat library:

lipo -info libmp3lame.a

In order to incorporate it within your application, you need to:

  1. Add the .a and header files to your project (with the application
    being the intended target)

  2. Add the library to the "Link binary with libraries" build phase,
    found under 'Build Phases' for your target, within the Project
    settings

    Build Phases - Link binary with libraries

  3. Import/include the header files where you wish to use LAME

Ideally, it's worth having 2 sets of fat libraries; one for the simulator, and the other for the device. You can then include the appropriate one for the respective build target. This ensures the size of the application is the lowest it can be, but it's fairly harmless to include the simulator library within an App Store binary (it doesn't cause side effects).

Your question doesn't mention header files, and I don't see any reference within the build script as part of the build artefacts. You may need to copy the ones you require from the source itself into the project.

Can I assign the sample rate or bit rate of m4a which was exported by AVAssetExportSession

You cannot specify that directly. Your only options are:

NSString *const AVAssetExportPresetLowQuality;
NSString *const AVAssetExportPresetMediumQuality;
NSString *const AVAssetExportPresetHighestQuality;


Related Topics



Leave a reply



Submit