- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我一直在尝试使用 AVMutableComposition 将音频(录制的)与视频(.mp4)混合,这意味着我需要 2 个文件在混合后并行播放,这是我使用的代码:temporaryRecFile 为录制文件url路径audiosURL 为视频文件url路径
NSURL *audiosURL =[[NSURL alloc] initFileURLWithPath:[[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"dam3.mp4"] ofType:nil]];
NSLog(@"SOMEDATA IS THERE ");
AVURLAsset* audioAsset = [[AVURLAsset alloc]initWithURL:temporaryRecFile options:nil];
AVURLAsset* audio2Asset = [[AVURLAsset alloc]initWithURL:audiosURL options:nil];
AVMutableComposition* mixComposition = [AVMutableComposition composition];
AVMutableCompositionTrack *compositionCommentary2Track = [mixComposition addMutableTrackWithMediaType:AVMediaTypeVideo preferredTrackID:kCMPersistentTrackID_Invalid];
[compositionCommentary2Track insertTimeRange:CMTimeRangeMake(kCMTimeZero, audio2Asset.duration) ofTrack:[[audio2Asset tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0] atTime:kCMTimeZero error:nil];
NSLog(@"audio =%@",audioAsset);
AVMutableCompositionTrack *compositionCommentaryTrack = [mixComposition addMutableTrackWithMediaType:AVMediaTypeAudio preferredTrackID:kCMPersistentTrackID_Invalid];
[compositionCommentaryTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero, audioAsset.duration) ofTrack:[[audioAsset tracksWithMediaType:AVMediaTypeAudio] 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 = AVFileTypeQuickTimeMovie;
//@"com.apple.quicktime-movie";
NSLog(@"file type %@",_assetExport.outputFileType);
_assetExport.outputURL = exportUrl;
_assetExport.shouldOptimizeForNetworkUse = YES;
[_assetExport exportAsynchronouslyWithCompletionHandler:
^(void )
{
switch (_assetExport.status)
{
case AVAssetExportSessionStatusCompleted:
// export complete
NSLog(@"Export Complete");
// From Here I want play movie using MPMoviePlayerController.<<<---------
NSString *fileNamePath = @"sound_record.mov";
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *oldappSettingsPath = [documentsDirectory stringByAppendingPathComponent:fileNamePath];
if ([[NSFileManager defaultManager] fileExistsAtPath:oldappSettingsPath]) {
NSFileManager *fileManager = [NSFileManager defaultManager];
[fileManager removeItemAtPath: oldappSettingsPath error:NULL];
}
NSURL *documentDirectoryURL = [NSURL fileURLWithPath:oldappSettingsPath];
[[NSFileManager defaultManager] copyItemAtURL:exportUrl toURL:documentDirectoryURL error:nil];
[audioAsset release];
[audio2Asset release];
[_assetExport release];
[self performSelectorOnMainThread:@selector(playVideo:) withObject:documentDirectoryURL waitUntilDone:NO];
break;
case AVAssetExportSessionStatusFailed:
NSLog(@"Export Failed");
NSLog(@"ExportSessionError: %@", [_assetExport.error localizedDescription]);
// export error (see exportSession.error)
break;
case AVAssetExportSessionStatusCancelled:
NSLog(@"Export Failed");
NSLog(@"ExportSessionError: %@", [_assetExport.error localizedDescription]);
// export cancelled
break;
}
}
];
因此,导出的视频成功播放录制的音频和视频,但是视频的音轨被删除了,所以导出的.mov只播放录制的音频文件和视频的图像,没有它的声音,为什么会这样?
最佳答案
您必须将视频中的音频添加为单独的轨道。因此,您将拥有一个视频轨道和两个音频轨道。在您的代码中,您没有添加视频中的音频。
关于ios - AVMutableComposition 去除视频音轨,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15338824/
给定一个字符串"5 900 000" 我想通过以下模式使用 gsub 去除空格: gsub(/\s/, '') 但这似乎行不通。也没有: gsub(' ', '') 最佳答案 如果你想就地替换,你需要
我编写了一个程序来抓取网站以获取数据并输出到 Excel 表。该程序使用 Microsoft Visual Studio 2010 用 C# 编写。 大多数时候,我从网站获取内容、解析内容并将数据存储
在 MS Access 2007 项目报告中,我有以下(已编辑)查询: SELECT SomeCol FROM SomeTable 问题是, SomeCol 显然包含一些不可见的字符。例如,我看到一个
如 Removing left recursion 中所述,有两种方法可以去除左递归。 使用一些过程修改原始语法以删除左递归 写文法原来没有左递归 人们通常使用什么来删除(没有)ANTLR 的左递归?
我在 CoreData 中存储了一堆艺术家,并希望按名称对它们进行排序,但忽略前缀“the”。例如,“The Beatles”将被排序为“Beatles”,有点像 iTunes/iPod 的做法。 因
我有一个 WebView ,我想从中删除弹性。现在,当滚动小于 webview 的页面时,它会产生弹性效果,显示下面的背景。我想删除这个。 我尝试过执行以下操作,但没有成功。它找到了 WebDynam
我正在调查我们公司使用 Prometheus 从我们在 Kubernetes 上运行的实验中收集统计数据。有计划使用标签来标记我们的云/集群中特定实验的名称。这意味着我们将生成大量标签,这些标签会随着
我正在添加聚合物元素。我想在单击其(自己的)图像时删除元素(自我)。根据封装,我将不得不让 parent 删除 child 。但这也需要为母体生成聚合物元素(我在这里吗??)。 children.ad
现在如果我点击按钮 A,按钮 B 会显示 DropShadow 效果: Private Sub ButtonA_Click(ByVal sender As System.Object, ByVal
我尝试过这个,但它对我不起作用: char * remove_nl(char * newstr) { newstr = strdup(newstr); newstr[strlen(ne
我陷入了两难境地。我有一个图像,我想占据网页的背景。我希望它横跨屏幕的宽度和高度,并保持那个尺寸。当我使用 标签,我不知道如何将它拉伸(stretch)到没有白条的屏幕上。 wspace 和 hspa
Jade .foo .foo 结果 想要的结果 在 haml 中我会做类似 .foo>< 的事情但这在 Jade 中不起作用。我已经搜索并空手而归如何处理这个问题。我如何达到预期的结果
我是 Maven 的新手,当我尝试将我当前的项目从使用 Ant 转换为 -> 使用 Maven 时遇到了问题。 那个项目需要很多 Jar,我在 mvnrepository 上查找这些 jar 并将它们
我需要一个正则表达式来删除 xml 标记开头和结尾之间的空格。例如:有人创建 xml 并将其发送给我,这样我就可以验证、签名并发送到网络服务。 为此,我需要删除标签开头和结尾之间的空格: String
我写了几个方法来将项目添加到数组中,如果它们已经在数组中,它们将被忽略。在对数据结构做了一些研究之后,我意识到我可以通过简单地将它们放在一个集合中来摆脱重复(特别是因为我不关心对象的顺序)。然而,在玩
使用 HighCharts,我想移除 SVG 曲线上的抗锯齿。 到目前为止,我正在使用这个: $('path').each(function(i,j){$(j).attr('shape-renderi
由于某些奇怪的原因(黑色但不是黑色部分),我的 SeekBar 和拇指后面出现随机阴影。我该如何摆脱它? 我的搜索栏: 拇指.xml progress_appearance.xml(有一些
我有一个 Url,我想获取路径部分但没有尾随文件名。如果 Url 是 http://my.com/dir1/dir2/file.ext 那么我想获取 /dir1/dir2 . 我已经尝试了各种拆分(l
我有这个字符串: dataSourceURL = URL(string:"https://api.abc.com/api/p4/products?pid=uid8225&format=json&off
在我的网页中,我有一个菜单 (HorizontalPanel) 应该隐藏在页面的底部。为此,我尝试使用 RootLayoutPanel 类并在其中添加一个 south 小部件,我成功地做到了。但问
我是一名优秀的程序员,十分优秀!