iphone ios 音频添加,合成,替换到视频(里的音轨)
来源:互联网 发布:三大运营商的网络制式 编辑:程序博客网 时间:2024/04/28 06:43
如果对av foundation 不熟悉得话,建议先看看wwdc 2010 关于av foundation得讲座。http://blog.csdn.net/linzhiji/article/details/6752722
I have a video file and an audio file. Is it possible to merge it to one video with with sound file. I think AVMutableComposition should help me, but I still dont understand how. any advices?
AVURLAsset* audioAsset = [[AVURLAsset alloc]initWithURL:audioUrl options:nil];AVURLAsset* videoAsset = [[AVURLAsset alloc]initWithURL:videoUrl options:nil];AVMutableComposition* mixComposition = [AVMutableComposition composition];AVMutableCompositionTrack *compositionCommentaryTrack = [mixComposition addMutableTrackWithMediaType:AVMediaTypeAudio preferredTrackID:kCMPersistentTrackID_Invalid];[compositionCommentaryTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero, audioAsset.duration) ofTrack:[[audioAsset tracksWithMediaType:AVMediaTypeAudio] objectAtIndex:0] atTime:kCMTimeZero error:nil];AVMutableCompositionTrack *compositionVideoTrack = [mixComposition addMutableTrackWithMediaType:AVMediaTypeVideo preferredTrackID:kCMPersistentTrackID_Invalid];[compositionVideoTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero, videoAsset.duration) ofTrack:[[videoAsset tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0] atTime:kCMTimeZero error:nil];AVAssetExportSession* _assetExport = [[AVAssetExportSession alloc] initWithAsset:mixComposition presetName:AVAssetExportPresetPassthrough]; NSString* videoName = @"export.mov";NSString *exportPath = [NSTemporaryDirectory() stringByAppendingPathComponent:videoName];NSURL *exportUrl = [NSURL fileURLWithPath:exportPath];if ([[NSFileManager defaultManager] fileExistsAtPath:exportPath]) { [[NSFileManager defaultManager] removeItemAtPath:exportPath error:nil];}_assetExport.outputFileType = @"com.apple.quicktime-movie";DLog(@"file type %@",_assetExport.outputFileType);_assetExport.outputURL = exportUrl;_assetExport.shouldOptimizeForNetworkUse = YES;[_assetExport exportAsynchronouslyWithCompletionHandler: ^(void ) { // your completion code here } } ];
- iphone ios 音频添加,合成,替换到视频(里的音轨)
- iphone ios 音频添加,合成,替换到视频(里的音轨)
- iphone ios 音频添加,合成,替换到视频(里的音轨)
- iOS开发之音轨合成(音频与音频,音频与视频)
- ios视频和音频的合成
- iphone ios 视频特效,视频合成
- 音频处理之 音频文件拼接,音轨合成 swift版
- iOS 如何对音频、视频合成,配音、卡拉OK技术
- Android多媒体(一) 音轨合成 我用双手成就你的梦想
- [算法]iOS 视频添加水印,合成视频两种方案(整体渲染和分割渲染)
- 音频与视频合成技术
- iOS 视频的录制、合成以及播放
- iOS 使用mp4v2合成的视频注意事项
- javacv-ffmpeg播放视频里的音频
- iOS 音视频合成
- iOS 音视频合成
- iOS 音视频合成
- iOS 视频合成相关
- 天龙 - Model Decal
- 整合blackberry sdk 5.0,6.0,7.0到同一个Eclipse下,避免重复安装
- hdu 2222:Keywords Search(AC自动机模板)
- lotus notes表单中实现RTF域的值的拷贝
- MFC,单文档视图创建顺序 .
- iphone ios 音频添加,合成,替换到视频(里的音轨)
- 多文档转单文档工程
- 当心注释带来的“惊喜”
- 天龙 - Terrain
- 学习3 数组复制
- Delphi 2010 新增功能之: IOUtils 单元(7): TFile 结构的功能
- 天龙 - Action Buffer
- vc++ resource.h文件出现“fatal error RC1004: unexpected end of file found”问题 .
- android中 sqlite数据库插入速度的优化