为 App Preview 捕捉 iOS 模拟器视频
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25797990/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Capture iOS Simulator video for App Preview
提问by AXE
Okay, so we can now submit video previews of our apps on the App Store. According to Apple we should do so with an iOS8 device and OSX 10.10.
The problem is you have to have all the different devices (4", 4.7", 5.5" and iPad).
好的,现在我们可以在 App Store 上提交我们的应用程序的视频预览。根据 Apple 的说法,我们应该使用 iOS8 设备这样做,OSX 10.10.
但问题是您必须拥有所有不同的设备(4"、4.7"、5.5" 和 iPad)。
Is there an alternative to this?
有没有替代方法?
I am thinking of capturing a video of the simulator. The problem is the device screen is bigger than my FullHD
monitor when shown in 100% resolution. Any solution that can capture a video right from the simulator in full resolution?
我正在考虑拍摄模拟器的视频。问题是设备屏幕FullHD
以 100% 分辨率显示时比我的显示器大。任何可以从模拟器中以全分辨率捕获视频的解决方案?
Edit: Since a lot of people are answering questions I'm not asking let me say: - Recording one device size and scaling it is not what I'm asking; - How to record anyapp preview is not what I'm asking; - How you do your previews is not what I'm asking;
编辑:由于很多人都在回答我不是问的问题,所以我说: - 记录一种设备尺寸并对其进行缩放不是我要问的;- 如何记录任何应用程序预览不是我要问的;- 你如何进行预览不是我要问的;
What I amasking is can you record a video from the simulator in 100% resolution if it doesn't fit on the screen?
什么我问的是你可以记录从100%分辨率模拟器的视频,如果它不适合在屏幕上?
回答by Tikhonov Alexander
For Xcode 8.2 or later
对于 Xcode 8.2 或更高版本
You can take videos and screenshots of Simulator using the
xcrun simctl
, a command-line utility to control the Simulator
您可以使用
xcrun simctl
控制模拟器的命令行实用程序 来拍摄模拟器的视频和屏幕截图
- Run your app on the simulator
- Open a terminal
Run the command
To take a screenshot
xcrun simctl io booted screenshot <filename>.<file extension>
For example:
xcrun simctl io booted screenshot myScreenshot.png
To take a video
xcrun simctl io booted recordVideo <filename>.<file extension>
For example:
xcrun simctl io booted recordVideo appVideo.mov
Press
ctrl + c
to stop recording the video.
- 在模拟器上运行你的应用
- 打开终端
运行命令
截屏
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
按
ctrl + c
停止录制视频。
The default location for the created file is the current directory.
创建的文件的默认位置是当前目录。
Xcode 11.2 and later gives extra options.
Xcode 11.2 及更高版本提供了额外的选项。
From Xcode 11.2 Beta Release Notes
来自 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.
simctl 视频录制现在生成更小的视频文件,支持 HEIC 压缩,并在可用的情况下利用硬件编码支持。此外,还恢复了在 iOS 13、tvOS 13 和 watchOS 6 设备上录制视频的功能。
You could use additional flags:
您可以使用其他标志:
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.
Now you can take a screenshot in jpeg
, with mask (for non-rectangular displays) and some other flags:
现在你可以在 中截取一张jpeg
带有掩码(用于非矩形显示)和一些其他标志的屏幕截图:
xcrun simctl io booted screenshot --type=jpeg --mask=black screenshot.jpeg
xcrun simctl io booted screenshot --type=jpeg --mask=black screenshot.jpeg
回答by Kalpesh
You can use QuickTime Player
to record the screen.
可以QuickTime Player
用来录屏。
- Open
QuickTime Player
- Select
File
from the menu - Select
New Screen recording
- 打开
QuickTime Player
- 选择
File
从菜单 - 选择
New Screen recording
Now from the Screen Recording
window, click on record button.
现在从Screen Recording
窗口中,单击记录按钮。
It will provide you with an option to record the entire screen or a selective portion of your screen.
它将为您提供一个选项来记录整个屏幕或屏幕的选定部分。
You will have to make a selection of your simulator so that only the simulator portion will be recorded.
您必须选择模拟器,以便仅记录模拟器部分。
回答by ali-hk
Apple recommends doing so on an actual device and has a guide on how to do this using QuickTime and iMovie on iOS and OS X: https://developer.apple.com/app-store/app-previews/imovie/Creating-App-Previews-with-iMovie.pdf
Apple 建议在实际设备上执行此操作,并提供有关如何在 iOS 和 OS X 上使用 QuickTime 和 iMovie 执行此操作的指南:https: //developer.apple.com/app-store/app-previews/imovie/Creating-App -Previews-with-iMovie.pdf
Summary:
概括:
Capture Screen Recordings with QuickTime Player
使用 QuickTime Player 捕捉屏幕录像
- Connect your iOS device to your Mac using a Lightning cable.
- Open QuickTime Player.
- Choose File > New Movie Recording.
- In the window that appears, select your iOS device as the Camera and Microphone input source.
- 使用 Lightning 数据线将您的 iOS 设备连接到 Mac。
- 打开 QuickTime 播放器。
- 选择“文件”>“新建影片录制”。
- 在出现的窗口中,选择您的 iOS 设备作为相机和麦克风输入源。
Create an App Preview with iMovie
使用 iMovie 创建 App 预览
Import Screen Recordings
导入屏幕录制
Next you import the screen recording files that you captured with QuickTime Player into iMovie. In iMovie:
接下来,您将使用 QuickTime Player 捕获的屏幕录制文件导入 iMovie。在 iMovie 中:
- Choose File > Import Media.
- In the window that appears, select the screen recording files.
- 选择“文件”>“导入媒体”。
- 在出现的窗口中,选择屏幕录制文件。
Create an App Preview Project
创建 App 预览项目
To start a new app preview project, choose File > New App Preview. A timeline appears where you can add and arrange clips to create your preview.
要启动新的应用程序预览项目,请选择“文件”>“新建应用程序预览”。出现时间线,您可以在其中添加和排列剪辑以创建预览。
回答by Eric Chuang
I'm actually surprised no one provided my answer. This is what you do (this will work if you have at least 1 eligible device):
我实际上很惊讶没有人提供我的答案。这就是您要做的(如果您至少有 1 台符合条件的设备,这将起作用):
- Record, edit and finish the App Preview with the device you have.
- Export as a file.
- Go to your Simulators and print screen 1 shot on each the different sizes of iPhone.
- Create new App Preview in iMovie.
- Insert the screenshot of the desired size FIRST, then add the file of the App Preview you've already made.
- Export using Share -> App Preview
- Repeat step 4 to 6 for new sizes.
- 使用您拥有的设备记录、编辑和完成应用预览。
- 导出为文件。
- 转到您的模拟器并在每个不同尺寸的 iPhone 上打印屏幕 1。
- 在 iMovie 中创建新的应用程序预览。
- 首先插入所需大小的屏幕截图,然后添加您已经制作的 App Preview 文件。
- 使用 Share -> App Preview 导出
- 对新尺寸重复步骤 4 到 6。
You should be able to get your App Preview in the desired resolution.
您应该能够以所需的分辨率获得应用程序预览。
回答by Vadim Bulavin
You can record a portion of the screen with built-in screenshot utility:
您可以使用内置的屏幕截图实用程序记录屏幕的一部分:
- Press Shift-Command-5 to show a control panel.
- Select
.
- Select a portion of the screen you want to record. That would be the iPhone simulator.
- Click
to stop recording.
- 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 Optionscontrol and enable Show Mouse Clicks.
如果要可视化鼠标单击,请在步骤 1 之后选择Optionscontrol 并启用Show Mouse Clicks。
回答by brutella
You should use QuickTime in Yosemiteto connect and record the screen of your iOS devices.
您应该在 Yosemite 中使用QuickTime来连接和录制 iOS 设备的屏幕。
iPhone Portrait
iPhone 人像
When you finished the recording, you can use iMovie to edit the video. When you're working on an iPhone Portrait App Preview, the resolution must be 1080x1920
but iMovie can only export in 16:9
(1920x1080
).
完成录制后,您可以使用 iMovie 编辑视频。当您处理 iPhone Portrait App Preview 时,分辨率必须为,1080x1920
但 iMovie 只能以16:9
( 1920x1080
)格式导出。
One solution would be to imported the recorded video with the resolution 1080x1920
and rotate it 90 degree. Then export the movie at 1920x1080
and rotate the exported video back 90 degrees using ffmpeg and the following command
一种解决方案是导入具有分辨率的录制视频并将其1080x1920
旋转 90 度。然后1920x1080
使用 ffmpeg 和以下命令导出电影并将导出的视频向后旋转 90 度
ffmpeg -i Landscape.mp4 -vf "transpose=1" Portrait.mp4
iPad
iPad
The iPad is a little bit trickier because it requires a resolution of 1200x900
(4:3
) but iMovie only exports in 16:9
.
iPad 有点棘手,因为它需要1200x900
( 4:3
)的分辨率,但 iMovie 只导出16:9
.
Here is what I've done.
这是我所做的。
- Record the movie on iPad Air in Landscape (
1200x900
,4:3
) - Import into iMovie and export as
1920x1080
,16:9
(iPadLandscape16_9-1920x1080.mp4
) Remove left and right black bars to a video with
1440x1080
. The width of one bar is240
ffmpeg -i iPadLandscape16_9-1920x1080.mp4 -filter:v "crop=1440:1080:240:0" -c:a copy iPadLandscape4_3-1440x1080.mp4
Scale down movie to
1220x900
ffmpeg -i iPadLandscape4_3-1440x1080.mp4 -filter:v scale=1200:-1 -c:a copy iPadLandscape4_3-1200x900.mp4
- 在 iPad Air 上以横向 (
1200x900
,4:3
)录制电影 - 导入 iMovie 并导出为
1920x1080
,16:9
(iPadLandscape16_9-1920x1080.mp4
) 使用 删除视频的左右黑条
1440x1080
。一根条的宽度是240
ffmpeg -i iPadLandscape16_9-1920x1080.mp4 -filter:v "crop=1440:1080:240:0" -c:a copy iPadLandscape4_3-1440x1080.mp4
将电影缩小到
1220x900
ffmpeg -i iPadLandscape4_3-1440x1080.mp4 -filter:v scale=1200:-1 -c:a copy iPadLandscape4_3-1200x900.mp4
Taken from my answer on the Apple Developer Forum
摘自我在Apple Developer Forum上的回答
回答by Shady Mostafa
Taking a Screenshot or Recording a Video Using the Command Line
You can take a screenshot or record a video of the simulator window using the
xcrun
command-line utility.
Launch your app in Simulator.
Launch Terminal (located in
/Applications/Utilities
), and enter the appropriate command:
To take a screenshot, use the
screenshot
operation:xcrun simctl io booted screenshot
You can specify an optional filename at the end of the command.
To record a video, use the
recordVideo
operation:xcrun simctl io booted recordVideo <filename>.<extension>
To stop recording, press Control-C in Terminal.
Note: You must specify a filename for recordVideo.
The default location for the created file is the current directory.
For more information on
simctl
, run this command in Terminal:xcrun simctl help
For more information on the
io
subcommand ofsimctl
, run this command:xcrun simctl io help
使用命令行截屏或录制视频
您可以使用
xcrun
命令行实用程序截取模拟器窗口的屏幕截图或录制视频。
在模拟器中启动您的应用程序。
启动终端(位于
/Applications/Utilities
),然后输入适当的命令:
要截取屏幕截图,请使用以下
screenshot
操作:xcrun simctl io booted screenshot
您可以在命令的末尾指定一个可选的文件名。
要录制视频,请使用以下
recordVideo
操作:xcrun simctl io booted recordVideo <filename>.<extension>
要停止录制,请在终端中按 Control-C。
注意:您必须为 recordVideo 指定文件名。
创建的文件的默认位置是当前目录。
有关更多信息
simctl
,请在终端中运行此命令:xcrun simctl help
有关 的
io
子命令的更多信息simctl
,请运行以下命令:xcrun simctl io help
From Apple Documentation.
来自Apple 文档。
回答by vish
You can do this for free with the following tools. You will need at least one real device (I used an iPhone 5)
您可以使用以下工具免费执行此操作。你至少需要一台真机(我用的是 iPhone 5)
Capture the video with the simple, but excellent appshow(note this is a very barebones tool, but it's very easy to learn). This will export at the native device resolution (640x1136).
使用简单但出色的appshow捕获视频(请注意,这是一个非常准系统的工具,但很容易学习)。这将以本机设备分辨率 (640x1136) 导出。
Resize with ffmpeg. Due to rounding, you can go directly between the resolutions, but you have to oversize and then crop.
使用 ffmpeg 调整大小。由于四舍五入,您可以直接在分辨率之间切换,但您必须放大然后裁剪。
ffmpeg -i video.mov -filter:v scale=1084:1924 -c:a copy video_1084.mov
ffmpeg -i video_1084.mov -filter:v "crop=1080:1920:0:0" -c:a copy video_1080.mov
For ipad, you can crop and then add a letterbox. However, cropping like this usually won't yield a video that looks exactly like your app does on the ipad. YMMV.
对于 ipad,您可以裁剪然后添加一个信箱。但是,像这样裁剪通常不会产生与您的应用在 ipad 上显示的完全相同的视频。天啊。
ffmpeg -i video.mov -filter:v "crop=640:960:0:0" -c:a copy video_640_960.mo
ffmpeg -i video_640_960.mov -filter:v "pad=768:1024:64:32" -c:a copy video_768_1024.mov
ffmpeg -i video_768_1024.mov -filter:v scale=900:1200 -c:a copy video_900_1200.mov
回答by Johannes Olsson
This is the way I found easiest and you only need one iPhone and iPad:
这是我发现的最简单的方法,您只需要一部 iPhone 和 iPad:
Record device screen with QuickTime Player:
使用 QuickTime Player 录制设备屏幕:
- Connect your device.
- Open QuickTime Player.
- Choose File > New Movie Recording (CMD + alt + N)
- In the window that appears, select your iOS device as the camera with maximum resolution.
- Save video file (CMD + S)
- 连接您的设备。
- 打开 QuickTime 播放器。
- 选择文件 > 新电影录制(CMD + alt + N)
- 在出现的窗口中,选择您的 iOS 设备作为具有最大分辨率的相机。
- 保存视频文件 (CMD + S)
Open iMovie
打开 iMovie
- Select File -> New App Preview
- Drag an IMAGE from your app with the biggest resolution ex. a 1920 x 1080 screenshot to the project. (This makes the video 1920 x 1080 even if you recorded with a iPhone 5)
- Drag the movie you recorded to the project.
- Save by choosing File -> Share -> App Preview
- 选择文件 -> 新建应用程序预览
- 从您的应用程序中以最大分辨率拖动图像。项目的 1920 x 1080 屏幕截图。(即使您使用 iPhone 5 录制,这也会使视频为 1920 x 1080)
- 将您录制的电影拖到项目中。
- 选择 File -> Share -> App Preview 保存
Now do this with all of your devices or:
现在对您的所有设备执行此操作,或者:
Download Handbreak: https://handbrake.fr/downloads.php
下载 Handbreak:https://handbrake.fr/downloads.php
And resize the high res video:
并调整高分辨率视频的大小:
- Drag your high res video to Handbreak
- Select "Picture Settings" icon
- Resize to the correct size - close and press "Start" icon - gets saved to desktop
- 将您的高分辨率视频拖到 Handbreak
- 选择“图片设置”图标
- 调整到正确的大小 - 关闭并按“开始”图标 - 保存到桌面
回答by Imanou Petit
The Apple's Simulator User Guide states in Taking a Screenshot or Recording a Video Using the Command Line paragraph:
Apple 的模拟器用户指南在使用命令行拍摄屏幕截图或录制视频段落中说明:
You can take a screenshot or record a video of the simulator window using the
xcrun
command-line utility.
您可以使用
xcrun
命令行实用程序截取模拟器窗口的屏幕截图或录制视频。
To record a video, use the recordVideo
operation in your Terminal:
要录制视频,请使用recordVideo
终端中的操作:
xcrun simctl io booted recordVideo <filename>.<extension>
Note that the file will be created in the current directory of your Terminal.
请注意,该文件将在终端的当前目录中创建。
If you want to save the video file in your Desktop folder, use the following command:
如果要将视频文件保存在桌面文件夹中,请使用以下命令:
xcrun simctl io booted recordVideo ~/Desktop/<filename>.<extension>
To stop recording, press Control-C
in Terminal.
要停止录制,请按Control-C
终端。