【发布时间】:2012-01-18 11:00:45
【问题描述】:
我正在为 iPhone 中的 Play Station 3 开发媒体服务器。
我知道 PS3 不支持 .MOV 文件,所以我必须将其转换为 Mp4 或其他 PS3 支持的转码。
这是我所做的,但如果我设置的文件类型与其源文件不同,它会崩溃。
AVURLAsset *avAsset = [AVURLAsset URLAssetWithURL:videoURL options:nil];
NSArray *compatiblePresets = [AVAssetExportSession exportPresetsCompatibleWithAsset:avAsset];
if ([compatiblePresets containsObject:AVAssetExportPresetLowQuality])
{
AVAssetExportSession *exportSession = [[AVAssetExportSession alloc]initWithAsset:avAsset presetName:AVAssetExportPresetLowQuality];
exportSession.outputURL = [NSURL fileURLWithPath:videoPath];
exportSession.outputFileType = AVFileTypeMPEG4;
CMTime start = CMTimeMakeWithSeconds(1.0, 600);
CMTime duration = CMTimeMakeWithSeconds(3.0, 600);
CMTimeRange range = CMTimeRangeMake(start, duration);
exportSession.timeRange = range;
[exportSession exportAsynchronouslyWithCompletionHandler:^{
switch ([exportSession status]) {
case AVAssetExportSessionStatusFailed:
NSLog(@"Export failed: %@", [[exportSession error] localizedDescription]);
break;
case AVAssetExportSessionStatusCancelled:
NSLog(@"Export canceled");
break;
default:
break;
}
[exportSession release];
}];
}
如果我在此处设置 AVFileTypeMPEG4,它会崩溃,并显示“文件类型无效”。所以我必须将它设置为 AVFileTypeQuickTimeMovie 并提供 MOV 文件。
是否可以在 iOS 中通过 AVAssetExportSession 将视频从 MOV 转换为 Mp4...或者无需任何第三方库?
【问题讨论】:
-
你有没有为此找到解决方案?
-
你有这个转换的解决方案吗???
-
您无法在 iOS 上读取任何随机的 .mov 编解码器,AVFoundation 只能读取编码为 .mov/.m4v 的 h.264 视频。
标签: iphone ios video-processing