Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development > iPhone SDK Development - Advanced Discussion

Reply
 
LinkBack Thread Tools Display Modes
Old 07-23-2011, 07:43 PM   #1 (permalink)
Registered Member
 
Join Date: Mar 2011
Posts: 36
cncool is on a distinguished road
Default Combining two m4a files

I can successfully combine two m4a files one after the other using AVMutableComposition and AVExportSession

Code:
    AVMutableComposition* composition = [AVMutableComposition composition];
    AVURLAsset* audioAsset1 = [[AVURLAsset alloc]initWithURL:[NSURL fileURLWithPath:audioFile1Path] options:nil];
    AVURLAsset* audioAsset2 = [[AVURLAsset alloc]initWithURL:[NSURL fileURLWithPath:audioFile2Path] options:nil];
    
    AVMutableCompositionTrack *audioTrack1 = [composition addMutableTrackWithMediaType:AVMediaTypeAudio 
                                                                      preferredTrackID:kCMPersistentTrackID_Invalid];
    
    [audioTrack1 insertTimeRange:CMTimeRangeMake(kCMTimeZero, audioAsset1.duration)
                         ofTrack:[[audioAsset1 tracksWithMediaType:AVMediaTypeAudio] objectAtIndex:0]
                          atTime:kCMTimeZero
                           error:nil];
    [audioTrack1 insertTimeRange:CMTimeRangeMake(kCMTimeZero, audioAsset2.duration) 
                         ofTrack:[[audioAsset2 tracksWithMediaType:AVMediaTypeAudio] objectAtIndex:0] 
                          atTime:audioAsset1.duration
                           error:nil];
    
    AVAssetExportSession * ex = [[AVAssetExportSession alloc] initWithAsset:[audioTrack1 asset] presetName:AVAssetExportPresetAppleM4A];
When I export, the resulting file is like 10x bigger than the size of the sum of the other two files. How would I combine the files but not have the file size be so big?
cncool is offline   Reply With Quote
Reply

Bookmarks

Tags
audio, combine, export, m4a

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 384
16 members and 368 guests
Absentia, AyClass, Diligent, dre, givensur, hussain1982, jbro, jPuzzle, momolgtm, Newbie123, Paul10, revg, skog, taylor202, tomtom100
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,643
Threads: 94,110
Posts: 402,858
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Diligent
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 04:45 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0