简体   繁体   English

适用于iOS的视频录制格式

[英]Available Video Recording formats for iOS

The functionality is to record a video from iPhone and upload it to server, then it should be synced with android device, and should be playable over there. 该功能是从iPhone录制视频并将其上传到服务器,然后应与android设备同步,并且可以在那儿播放。 From google search I came to know that iPhone records .mov files. 从谷歌搜索中,我知道iPhone记录了.mov文件。

What I would like to know is, if there are any other formats available other than .mov so that it can be playable on android device as well as on the server. 我想知道的是,.mov是否有其他可用格式,以便它可以在android设备以及服务器上播放。

Thanks. 谢谢。

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

.mov isn't a format; .mov不是格式; it's a container file. 这是一个容器文件。 The iPhone uses the popular h.264 encoder for video, and then contains it (with audio and data) in a .mov file, which is a quicktime file format. iPhone将流行的h.264编码器用于视频,然后将其(包含音频和数据)包含在.mov文件中,该文件是quicktime文件格式。 There is no way that you can change the container file or the encoder used by the iPhone. 您无法更改iPhone所使用的容器文件或编码器。

There are services you can use to encoding video files from one format to another. 您可以使用一些服务来将视频文件从一种格式编码为另一种格式。 Check out zencoder and pandastream. 查看zencoder和pandastream。

There is a way indeed. 确实有办法。 You can use the class AVAssetExportSession . 您可以使用类AVAssetExportSession The AVAssetExportSession object has a property called outputFileType which you can set to AVFileTypeMPEG4 . AVAssetExportSession对象具有一个名为outputFileType的属性,您可以将其设置为AVFileTypeMPEG4 By using the preset name AVAssetExportPresetPassthrough the video will not be actually re-encoded but just the container will be changed to mp4 (so it will be super fast). 通过使用预设名称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;
    }
}];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM