请稍侯

生成iOS App Preview的几种方案

26 May 2020

生成iOS App Preview的几种方案

参考:Capture iOS Simulator video for App Preview

xcode自带的command tools

For Xcode 8.2 or later

You can take videos and screenshots of Simulator using the xcrun Xcode command-line utility.

  1. Run your app on the simulator.
  2. Open Terminal.app
  3. Run the command
    • To take a screenshot, xcrun simctl io booted screenshot <filename>.<file extension>
    • To take a video, xcrun simctl io booted recordVideo <filename>.<file extension>.
      For example screenshot: xcrun simctl io booted screenshot myScreenshot.png
      For example video:xcrun simctl io booted recordVideo appVideo.mov
  4. Press ctrl + c to stop recording the video.

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

Xcode 11.2 gives extra options.
From Xcode 11.2 Beta Release Notes

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.

Now you could use additional flags for video recording:

  • –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.

Now you can record a video in h264 codec, with mask (for non-rectangular displays) and some other flags:

xcrun simctl io booted recordVideo --codec=h264 --mask=black --force appVideo.mov

然后再使用Handbreak转码
Download Handbreak: https://handbrake.fr/downloads.php

And resize the high res video:

  1. Drag your high res video to Handbreak
  2. Select “Picture Settings” icon
  3. Resize to the correct size - close and press “Start” icon - gets saved to desktop

and for screenshoting:

  • –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”.
  • –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. You may also specify a port by UUID.
      Now you can take a screenshot in jpeg, with mask (for non-rectangular displays) and some other flags:
      xcrun simctl io booted screenshot --type=jpeg --mask=black screenshot.jpeg

使用QuickTime Player

  1. Open QuickTime Player.
  2. Select File from the menu.
  3. Select New Screen recording.
  4. Record, edit and finish the App Preview with the device you have.
  5. Export as a file.
  6. Go to your Simulators and print screen 1 shot on each the different sizes of iPhone.
  7. Create new App Preview in iMovie.
  8. Insert the screenshot of the desired size FIRST, then add the file of the App Preview you’ve already made.
  9. Export using Share -> App Preview.
  10. Repeat step 7 to 9 for new sizes.

使用系统内置的截屏工具

  1. Press Shift-Command-5 to show a control panel.
  2. Select 录制所选部分 按钮.
  3. Select a portion of the screen you want to record. That would be the iPhone simulator.
  4. Click 停止录制 按钮 to stop recording.
  5. A thumbnail will appear at the bottom right corner of the screen. You can edit it before saving.
    If you want to visualize mouse clicks, after step 1 select Options control and enable Show Mouse Clicks.