资源库兼容哪些视频格式?
iPhone 的资源库兼容哪些视频格式?
换句话说,对于哪些视频格式,ALAssetsLibrary 的 videoAtPathIsCompatibleWithSavedPhotosAlbum 将返回 YES?
我似乎无法在 iPhone 参考库中找到任何相关信息。
What video formats are compatible with the iPhone's assets library?
In other words, for what video formats will ALAssetsLibrary's videoAtPathIsCompatibleWithSavedPhotosAlbum return YES?
I can't seem to locate any information on this in the iPhone Reference Library.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
目前还没有人提到这一点,但这取决于 iPhone/iOS 设备。在制作一个尝试将 Flickr 视频复制到相册的应用程序时,当我在 writeVideoAtPathToSavedPhotosAlbum: 调用非 Retina iPhone 上不断收到无效数据结果时,我感到很沮丧。
我按照这个问题的要求,对各种大小的 Flickr 视频运行了一些 videoAtPathIsCompatibleWithSavedPhotosAlbum 测试。
根据这一有限的测试,对于给定的格式和设备,大小似乎最重要。 (对于当前的 Flickr 编码方法和 url 方案、
移动
视频适用于所有 iOS 设备相册,而hd
和site
视频仅适用于 Retina iPhone和 iPad。)一个有趣的旁注是,高清视频可以通过 MPMoviePlayerController 在非视网膜 iPhone 上播放 - 您只是无法将它们保存到相册中。
No one has mentioned this yet, but it depends on the iPhone / iOS device. In making an app that tries to copy Flickr videos to the photo album, I was getting frustrated when I kept getting invalid data results on writeVideoAtPathToSavedPhotosAlbum: calls for a non-Retina iPhone.
I ran some videoAtPathIsCompatibleWithSavedPhotosAlbum tests on Flickr videos of various sizes, as requested in this question.
Based on this limited testing, for a given format and device, it looks like size matters most. (For the current Flickr encoding methods and url scheme,
mobile
videos work on all iOS device photo albums, whereashd
andsite
videos only work on Retina iPhones and iPads.)An interesting side note is that HD videos will play on non-retina iPhones with the MPMoviePlayerController -- you just can't save them to the photo album.
如果您想要支持的音频/视频技术的列表,请阅读 iOS 技术概述,特别是 媒体层(向下滚动到显示“视频技术”的位置)。
这是iOS中媒体框架的参考信息。
If you want a list of supported audio/video technologies, read the iOS Technology Overview, in particular the Media Layer (scroll down to where it says "Video Technologies").
That's the reference information for the media frameworks in iOS.
我最近在我的超快相机应用 SnappyCam Pro 中添加了视频导出功能,用于静态照片连拍。
为了满足新旧设备的需求,我最终创建了一些 MPEG-4“探测”视频,每个视频都有一个黑帧,具有各种 4:3 分辨率:
这四个视频文件仅添加了 12KB到应用程序包。
然后使用
-[ALAssetsLibrary videoAtPathIsCompatibleWithSavedPhotosAlbum:]
迭代每个选项,我就能够确定哪些选项对于最终相机胶卷视频导出有效。I recently added a video export feature for the living photo burst of stills in my super-fast camera app SnappyCam Pro.
To cater for old and new devices alike, I ended up creating a few MPEG-4 "probe" videos, each with a single black frame, at a variety of 4:3 resolutions:
The four video files added just 12KB to the App Bundle.
By then iterating through each, with
-[ALAssetsLibrary videoAtPathIsCompatibleWithSavedPhotosAlbum:]
, I was able to then work out which options are valid for the final Camera Roll video export.如果我必须猜测,我可能会使用 iPhone 自己的规格作为测试指南:
支持的视频格式:H.264 视频高达 720p、每秒 30 帧、Main Profile level 3.1,AAC-LC 音频高达 160 Kbps、48kHz、.m4v、.mp4 和 .mov 文件中的立体声音频格式; MPEG-4 视频,高达 2.5 Mbps,640 x 480 像素,每秒 30 帧,简单配置文件,AAC-LC 音频高达每通道 160 Kbps,48kHz,立体声音频采用 .m4v、.mp4 和 .mov 文件格式; Motion JPEG (M-JPEG) 高达 35 Mbps、1280 x 720 像素、每秒 30 帧、ulaw 音频、.avi 文件格式的 PCM 立体声音频
If I had to guess, I might use the iPhone's own specifications as a guideline for testing:
Video formats supported: H.264 video up to 720p, 30 frames per second, Main Profile level 3.1 with AAC-LC audio up to 160 Kbps, 48kHz, stereo audio in .m4v, .mp4, and .mov file formats; MPEG-4 video, up to 2.5 Mbps, 640 by 480 pixels, 30 frames per second, Simple Profile with AAC-LC audio up to 160 Kbps per channel, 48kHz, stereo audio in .m4v, .mp4, and .mov file formats; Motion JPEG (M-JPEG) up to 35 Mbps, 1280 by 720 pixels, 30 frames per second, audio in ulaw, PCM stereo audio in .avi file format
似乎没有记录的方法来查询什么格式将使
videoAtPathIsCompatibleWithSavedPhotosAlbum
满意,并且设备可以解码某种格式这一事实并不意味着 AssetLibrary 会接受它。 但是,您可能会期望配备相机的设备始终能够将相机的最高分辨率输出保存到相机胶卷中。如果您可以接受这个假设,那么您所要做的就是枚举
AVCaptureDevices
并使用supportsAVCaptureSessionPreset
查询各种预设。维克多的测试表明像素面积似乎最重要,所以一旦你查询过
AVCaptureSessionPreset1920x1080、AVCaptureSessionPreset1280x720、AVCaptureSessionPreset640x480
您应该能够选择一个使videoAtPathIsCompatibleWithSavedPhotosAlbum
说“是”的大小。我不知道对于没有摄像头的设备你会如何计算。
There doesn't seem to be a documented way to query what formats will make
videoAtPathIsCompatibleWithSavedPhotosAlbum
happy and the fact that a device can decode a certain format doesn't mean the AssetLibrary will accept it. However, you would expect that a camera equipped device will always be able to save the camera's highest resolution output to the camera roll.If you can live with this assumption, then all you have to do is enumerate the
AVCaptureDevices
and query the various presets withsupportsAVCaptureSessionPreset
.Victor's tests show that pixel area seems to matter most, so once you've queried
AVCaptureSessionPreset1920x1080, AVCaptureSessionPreset1280x720, AVCaptureSessionPreset640x480
you should be able to choose a size that will makevideoAtPathIsCompatibleWithSavedPhotosAlbum
say YES.I have no idea how you'd figure it for devices without cameras.