0

功能是从 iPhone 录制视频并将其上传到服务器,然后它应该与 android 设备同步,并且应该可以在那里播放。从谷歌搜索我知道 iPhone 记录 .mov 文件。

我想知道的是,除了 .mov 之外是否还有其他可用的格式,以便它可以在 android 设备和服务器上播放。

谢谢。

SDK: 5.0;    
Xcode: 4.2;
Devices: iPhone 4,4S, iPad2,3
4

2 回答 2

6

.mov 不是一种格式;这是一个容器文件。iPhone 使用流行的 h.264 视频编码器,然后将其(包括音频和数据)包含在 .mov 文件中,这是一种快速文件格式。您无法更改 iPhone 使用的容器文件或编码器。

您可以使用一些服务将视频文件从一种格式编码为另一种格式。查看 zencoder 和 pandastream。

于 2012-08-11T06:28:44.363 回答
5

确实有办法。您可以使用AVAssetExportSession类。AVAssetExportSession 对象有一个名为outputFileType的属性,您可以将其设置为AVFileTypeMPEG4。通过使用预设名称AVAssetExportPresetPassthrough,视频实际上不会被重新编码,而只是将容器更改为 mp4(因此速度会非常快)。

AVAssetExportSession *exporter = [[AVAssetExportSession alloc] initWithAsset:#videoAsset# composition presetName:AVAssetExportPresetPassthrough];
exporter.outputFileType = AVFileTypeMPEG4;
exporter.outputURL = outputURL;

[exporter exportAsynchronouslyWithCompletionHandler:^(void){
    switch (exporter.status) {
        case AVAssetExportSessionStatusFailed:
            // Failed!
            break;
        case AVAssetExportSessionStatusCompleted:
            // Success!
            break;
        case AVAssetExportSessionStatusCancelled:
            // Cancelled!
            break;
    }
}];
于 2013-03-08T17:46:56.957 回答