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

  • Home
  • SEARCH
  • 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 3310012
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T21:42:32+00:00 2026-05-17T21:42:32+00:00

I try to add a .mp3-file to an AVMutableCompositionTrack and after that I want

  • 0

I try to add a .mp3-file to an AVMutableCompositionTrack and after that I want to export the new file. The Problem is: The generated file exists after exporting but it is empty and can not be played. Does someone see the error in my code?

AVMutableComposition *saveComposition = [AVMutableComposition composition];
 NSArray *docpaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
 NSString *tempPath = [docpaths objectAtIndex:0];

 NSLog(@"Temporary Path: %@", tempPath);

 NSString *audioPath = [[NSBundle mainBundle] pathForResource: @"1" ofType: @"mp3"];
 NSURL *audioUrl = [[NSURL alloc] initFileURLWithPath:audioPath];
 AVURLAsset *audio = [AVURLAsset URLAssetWithURL:audioUrl options:nil];
 NSLog(@"%@", audio);
 [audioUrl release];
 AVMutableCompositionTrack *compositionAudioTrack = [saveComposition addMutableTrackWithMediaType:AVMediaTypeAudio preferredTrackID:kCMPersistentTrackID_Invalid];
 AVAssetTrack *clipAudioTrack = [ objectAtIndex:0];

 [compositionAudioTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero, )  ofTrack:clipAudioTrack atTime:kCMTimeZero error:nil];

 NSString *path = [tempPath stringByAppendingPathComponent:@"mergedaudio.m4a"];
 if([[NSFileManager defaultManager] fileExistsAtPath:path])
 {
  [[NSFileManager defaultManager] removeItemAtPath:path error:nil];
 }
 NSURL *url = [[NSURL alloc] initFileURLWithPath: path];

 AVAssetExportSession *exporter = [[[AVAssetExportSession alloc] initWithAsset:saveComposition presetName:AVAssetExportPresetAppleM4A] autorelease];
 exporter.outputURL=url;
 [exporter setOutputFileType:@"com.apple.m4a-audio"];

 NSLog(@"%@", [exporter supportedFileTypes]);
 exporter.outputFileType=[[exporter supportedFileTypes] objectAtIndex:0];

 [exporter exportAsynchronouslyWithCompletionHandler:^{

 }];

Thank you in advance !

  • 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-05-17T21:42:32+00:00Added an answer on May 17, 2026 at 9:42 pm

    Like I wrote in the comments it had something to do with the different file formats. I changed my files to .m4a and also the code – so everything (the sources and the targets of this operation) is .m4a related and it works.

    by the way: I tried also working with .wav-files, but there are strange things happening while the operations with wav. I don’t recommend it.

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

Sidebar

Related Questions

I try to add Message.framework to my project frameworks directory. After that I compile
So, I know some Python but I thought that I should try to add
i try to add facebook like button on my root domain that will like
I have an example web solution that I downloaded and when I try Add
Have a question.. I have a list of mp3 filenames to add a new
I have some problem with show and delay.. When I try add .delay to
I am making an android application that will play an mp3 file once a
My IDE crashes any time I try add a new component to the toolbar.
I try add to some table new column, how its described in documentation for
This is the VBA code im using to try add a new sheet to

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.