Я разрабатываю медиа-сервер для Playstation 3 в iPhone.
Я узнал, что 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 конвертировать видео из MOV в Mp4 через AVAssetExportSession ... ИЛИ без сторонних библиотек?
просто хотел сказать, что URL не может быть похожим на
[NSURL URLWithString: [@"~/Documents/movie.mov" stringByExpandingTildeInPath]]
Это должно быть похоже на
[NSURL fileURLWithPath: [@"~/Documents/movie.mov" stringByExpandingTildeInPath]]
Мне понадобилось время, чтобы понять это: -)