AVAssetExportSession no audio (iPhone), works on iPad

試著忘記壹切 提交于 2019-12-24 02:23:29

问题


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.

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]; }];

回答1:


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.



来源:https://stackoverflow.com/questions/6416511/avassetexportsession-no-audio-iphone-works-on-ipad

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!