iphone - How to append two audio files? -
i want append 2 audio files in iphone. please me this.
i got solution; following sample code it.
avmutablecomposition* composition = [avmutablecomposition composition]; avurlasset* audioasset1 = [[avurlasset alloc]initwithurl:[nsurl fileurlwithpath:filepath1] options:nil]; avurlasset* audioasset2 = [[avurlasset alloc]initwithurl:[nsurl fileurlwithpath:filepath2] 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:&error]; [audiotrack1 inserttimerange:cmtimerangemake(kcmtimezero, audioasset2.duration) oftrack:[[audioasset2 trackswithmediatype:avmediatypeaudio] objectatindex:0] attime:audioasset1.duration error:&error];
finally, have export single file using avassetexportsession
.
note: work .m4a files
Comments
Post a Comment