AVAssetExportSession无音频(iPhone),适用于iPad [英] AVAssetExportSession no audio (iPhone), works on iPad
问题描述
我们正在尝试使用音频(.mov)拍摄现有视频,并制作更适合电子邮件的版本。看起来非常简单,下面的代码正是我们所需要的...差不多。
We're trying to take an existing video with audio (.mov) and make a more email friendly version. Seems pretty straightforward and the code below does just what we need ... almost.
在iPad2(4.3.3)上,它适用于调试和放大版本一直在构建。在iPhone 4(4.3.3)或第四代iPod Touch上没有音频。它不时会触发它的明显相关性,它将开始在iPhone上运行。删除应用程序,重建/安装,它不再有效。
On an iPad2 (4.3.3) it works in debug & release builds all of the time. On the iPhone 4 (4.3.3) or 4th gen iPod Touch there's no audio. From time to time, no obvious correlation as to what triggers it, it will start working on the iPhone. Delete the app, rebuild/install, and it no longer works.
AVURLAsset* asset = [AVURLAsset URLAssetWithURL:[NSURL fileURLWithPath:sourcePath] options:nil];
session = [[AVAssetExportSession alloc] initWithAsset:asset
presetName:AVAssetExportPresetLowQuality];
session.outputURL = [NSURL fileURLWithPath:destPath];
session.outputFileType = AVFileTypeQuickTimeMovie;
session.shouldOptimizeForNetworkUse = YES;
[session exportAsynchronouslyWithCompletionHandler:^{
[self performSelectorOnMainThread:@selector(conversionFinished)
withObject:nil
waitUntilDone:NO]; }];
推荐答案
你是否正在播放电影,例如MPMoviePlayer?在玩或使用具有相同网址的其他初始化资产时,我偶尔会遇到一些出口问题。
Are you playing the movie too, for example in an MPMoviePlayer? I have had some occasional export quirks while playing or using other initialized assets with the same URLs.
这篇关于AVAssetExportSession无音频(iPhone),适用于iPad的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!