In my app, few audio files which are downloaded from server are not supported. mpeg,x-wav audio formats are not supported in my Objective-C code. How can I convert them into one of the supported types of iOS?
Asked
Active
Viewed 1,174 times
0
-
Can you specify exactly what file formats (x-wav is MIME). How are you trying to play it? If you want to convert it in code look at the FFmpeg library. – jr.root.cs Mar 20 '17 at 14:02
-
Indeed, you'll have to be more specific, as there are many flavours of "MPEG" and "WAV", and the most common ones are definitely directly supported by iOS, so you don't need to do any conversion. Please share both your code and a link to files which are supposedly not supported, along with any errors you get when you try to play them. – jcaron Mar 20 '17 at 17:37
-
I am having an audio url link which I have to download in to a local filePath and play in my app.That audio url is http://ci.thrymr.net:8082/file/get?fileid=58d0ce23030b28166b322b79 which is a .mpeg format file.remaining formates like .mp3,.mp4,.m4a,.3gpp are working fine but .mpeg and x-wav audio formates are not playing in AVPlayer in my ios objective-c Application. – Ajay Mar 21 '17 at 10:01
2 Answers
0
You could import them into garage band and then export as an IOS compatible format such as .m4a or .mp3

Zambo004
- 21
- 9
0
Below code maybe useful to you.And change the outputFileType what you want
AVAsset * asset = [AVAsset assetWithURL:inputURL];
AVAssetExportSession * exportSession = [[AVAssetExportSession alloc] initWithAsset:asset presetName:AVAssetExportPresetHighestQuality];
exportSession.outputFileType = AVFileTypeMPEG4;
exportSession.outputURL = outputURL;
exportSession.metadata = asset.metadata;
[exportSession exportAsynchronouslyWithCompletionHandler:^{
if (exportSession.status == AVAssetExportSessionStatusCompleted)
{
NSLog(@"AV export succeeded.");
}
else if (exportSession.status == AVAssetExportSessionStatusCancelled)
{
NSLog(@"AV export cancelled.");
}
else
{
NSLog(@"AV export failed with error: %@ (%ld)", exportSession.error.localizedDescription, (long)exportSession.error.code);
}
}];
For Ref:-
https://stackoverflow.com/a/41053633
NOTE:- Not tested

Community
- 1
- 1

Rajesh Dharani
- 285
- 4
- 20
-
This could be useful if the formats actually are supported by iOS. And in that case why not fix the playback instead of conversion? The supported audio formats are listed in Apple's documentation: https://developer.apple.com/reference/coreaudio/core_audio_data_types/1572096-audio_data_format_identifiers – jr.root.cs Mar 20 '17 at 14:08