ios - 捕获 iOS 模拟器视频以进行应用程序预览

标签 ios ios-simulator ios8 video-capture screen-capture

好的,我们现在可以在 App Store 上提交应用程序的视频预览了。根据 Apple 的说法,我们应该使用 iOS8 设备和 OSX 10.10。 问题是您必须拥有所有不同的设备(4 英寸、4.7 英寸、5.5 英寸和iPad)。

有替代方案吗?

我正在考虑捕捉模拟器的视频。问题是,以 100% 分辨率显示时,设备屏幕比我的 FullHD 显示器大。有什么解决方案可以直接从模拟器中以全分辨率捕获视频吗?

编辑: 既然很多人都在回答我的问题,我就不问了,我说: - 记录一种设备的大小并缩放它不是我所要求的; - 如何记录任何应用程序预览不是我要问的; - 我问的不是你如何进行预览;

要问的是如果屏幕不适合,您能否以 100% 分辨率从模拟器录制视频?

最佳答案

适用于 Xcode 8.2 或更高版本

You can take videos and screenshots of Simulator using the xcrun simctl, a command-line utility to control the Simulator

  1. 在模拟器上运行您的应用

  2. 打开终端

  3. 运行命令

    • 截取屏幕截图

      xcrun simctl io booted screenshot <filename>.<file extension>

      例如:

      xcrun simctl io booted screenshot myScreenshot.png

    • 拍摄视频

      xcrun simctl io booted recordVideo <filename>.<file extension>

      例如:

      xcrun simctl io booted recordVideo appVideo.mov

  4. ctrl + C 停止录制视频。

The default location for the created file is the current directory.

Xcode 11.2 及更高版本提供了额外的选项。

来自 Xcode 11.2 Beta 发行说明

simctl video recording now produces smaller video files, supports HEIC compression, and takes advantage of hardware encoding support where available. In addition, the ability to record video on iOS 13, tvOS 13, and watchOS 6 devices has been restored.

您可以使用其他标志:

xcrun simctl io --help
Set up a device IO operation.
Usage: simctl io <device> <operation> <arguments>

...

    recordVideo [--codec=<codec>] [--display=<display>] [--mask=<policy>] [--force] <file or url>
        Records the display to a QuickTime movie at the specified file or url.
        --codec      Specifies the codec type: "h264" or "hevc". Default is "hevc".

        --display    iOS: supports "internal" or "external". Default is "internal".
                     tvOS: supports only "external"
                     watchOS: supports only "internal"

        --mask       For non-rectangular displays, handle the mask by policy:
                     ignored: The mask is ignored and the unmasked framebuffer is saved.
                     alpha: Not supported, but retained for compatibility; the mask is rendered black.
                     black: The mask is rendered black.

        --force      Force the output file to be written to, even if the file already exists.

    screenshot [--type=<type>] [--display=<display>] [--mask=<policy>] <file or url>
        Saves a screenshot as a PNG to the specified file or url(use "-" for stdout).
        --type       Can be "png", "tiff", "bmp", "gif", "jpeg". Default is png.

        --display    iOS: supports "internal" or "external". Default is "internal".
                     tvOS: supports only "external"
                     watchOS: supports only "internal"

                     You may also specify a port by UUID
        --mask       For non-rectangular displays, handle the mask by policy:
                     ignored: The mask is ignored and the unmasked framebuffer is saved.
                     alpha: The mask is used as premultiplied alpha.
                     black: The mask is rendered black.

现在您可以在 jpeg 中截图,带有 mask (用于非矩形显示器)和一些其他标志:

xcrun simctl io booted screenshot --type=jpeg --mask=black screenshot.jpeg

关于ios - 捕获 iOS 模拟器视频以进行应用程序预览,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55819642/

相关文章:

ios - 如何从 iOS 下钥匙串(keychain)中存在的证书中解码序列号、发行者信息等?

ios - 模拟器不播放视频

ios - xib 文件的大小类不起作用

swift - 在 iOS 8 中使用 Swift 更改特定 View Controller 的状态栏颜色

Objective-C:如何在 switch 语句完成后返回到应用程序的开头

ios - Swift 搜索两个字符串集合

iPhone 显示与模拟器不同

iOS TodayView 小部件断点不起作用

ios - 隐藏搜索栏 View 后更新 View 的顶部空间约束

iphone - iOS - 当 AFHTTPClient 完成所有操作时如何获得通知