Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8568765
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:10:59+00:00 2026-06-11T18:10:59+00:00

i found (customizing a method i found) a way to convert a MpMediaItem and

  • 0

i found (customizing a method i found) a way to convert a MpMediaItem and to obtain a mp3 file. Probably it’s not the best way but it’s working.

Is there a way to obtain an *.ogg file instead of *.mp3 ? What would be the proper approach?

This is the method i use to get the *.mp3 file:

    -(void)exportMP3:(NSURL*)url toFileUrl:(NSString*)fileURL
{
    AVURLAsset *asset=[[AVURLAsset alloc] initWithURL:url options:nil];
    AVAssetReader *reader=[[AVAssetReader alloc] initWithAsset:asset error:nil];
    NSMutableArray *myOutputs =[[NSMutableArray alloc] init];
    for(id track in [asset tracks])
    {
        AVAssetReaderTrackOutput *output=[AVAssetReaderTrackOutput assetReaderTrackOutputWithTrack:track outputSettings:nil];
        [myOutputs addObject:output];   
        [reader addOutput:output];
    }
    [reader startReading];
    NSFileHandle *fileHandle ;
    NSFileManager *fm=[NSFileManager defaultManager];
    if(![fm fileExistsAtPath:fileURL])
    {
        [fm createFileAtPath:fileURL contents:[[NSData alloc] init] attributes:nil];
    }else{
        NSURL *url = [NSURL URLWithString:fileURL];
        [fm removeItemAtURL:url error:nil];
        [fm createFileAtPath:fileURL contents:[[NSData alloc] init] attributes:nil];

    }
    fileHandle=[NSFileHandle fileHandleForWritingAtPath:fileURL];    
    [fileHandle seekToEndOfFile];

    AVAssetReaderOutput *output=[myOutputs objectAtIndex:0];
    int totalBuff=0;
    int test = 1;
    while(test == 1)
    {
        CMSampleBufferRef ref=[output copyNextSampleBuffer];

        if(ref==NULL)
            test = 0;

        if(ref==NULL)
            break;
        //copy data to file
        //read next one
        AudioBufferList audioBufferList;
        NSMutableData *data;
        CMBlockBufferRef blockBuffer;
        CMSampleBufferGetAudioBufferListWithRetainedBlockBuffer(ref, NULL, &audioBufferList, sizeof(audioBufferList), NULL, NULL, 0, &blockBuffer);

        for( int y=0; y<audioBufferList.mNumberBuffers; y++ )
        {
            AudioBuffer audioBuffer = audioBufferList.mBuffers[y];
            void *frame = audioBuffer.mData;

            data = [[NSMutableData alloc] initWithBytes:frame length:audioBuffer.mDataByteSize];
        }
        totalBuff++;
        NSLog(@"\n%d\n",totalBuff);

        int time = [self.mediaPlayer durationOfCurrentItem];

        if (totalBuff * 2 <= time + 1)        
            [fileHandle writeData:data];

    }
    [fileHandle closeFile];
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T18:11:00+00:00Added an answer on June 11, 2026 at 6:11 pm

    You can use libvorbis to encode PCM data to Vorbis.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was trying to customizing the UIBarButtonItem in Navigation Bar I found that there
Found related questions but not the exact variant so I am posting a very
Found This: tyty stack, Social Icons not working with Infinite Scrolling on Wordpress I'm
Found this Multimap containing pairs? , but it is not much help How would
Not sure if this is possible in git (I haven't found it but I
Is there a way to have git status ignore certain changes within a file?
I'm customizing my zsh prompt and have found the following to check if there
found this little code snippet that seems to do what i want, but im
Found this: Sub SurroundWithAppendTag() DTE.ActiveDocument.Selection.Text = .Append( + DTE.ActiveDocument.Selection.Text + ) End Sub But
I am working on customizing the layout of OFC2 so it can be properly

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.