How to record simulator video and format for App Store Previews
1. Record from the simulator
- output will be portrait
Using the iPhone 8 Plus 5.5” simulator, the video was 1242 × 2208 (iPhone 8 Plus native resolution) and for me, the frame rate was 44fps. This may be due the performance of the simulator for the iPhone 8 Plus. I found out later when recording for 6.5” resolution that my 11 Pro Max simulator rendered at a much lower 18 fps when running the same app on the same functionality.
I am using Xcode 11 but I found that people were complaining about the speed of simulators in Xcode 10.. So try running your app on different simulators and use the settings on the simulator to find the fps. It may vary and you’ll need to change it in ffmpeg.
2. Change the Frame rate (fps)
Run ffmpeg to force changing frame rate to, 24 fps, for example.
- Source: Using ffmpeg to change framerate
3. Rotate the video
portrait -> landscape
For the transpose parameter you can pass:
- 0 = 90 Counter Clockwise and Vertical Flip (default)
- 1 = 90 Clockwise
- 2 = 90 Counter Clockwise
- 3 = 90 Clockwise and Vertical Flip
Source: Rotating videos with FFmpeg
4. Change the scale
You can get the dimensions of your input video like this:
You can also use ffprobe to find all other properties of your input file
If we’d like to keep the aspect ratio, we need to specify only one component, either width or height, and set the other component to -1. For example, this command line:
- Source: FFmpeg wiki: Scaling
…will set the width of the output image to 320 pixels and will calculate the height of the output image according to the aspect ratio of the input image. The resulting image will have a dimension of 320⨉207 pixels.
Some codecs require the size of width and height to be a multiple of n. You can achieve this by setting the width or height to -n:
The output will now be 320⨉206 pixels.
5. Get metadata, frame rate
Get all metadata
Filter metadata for frame rate only
6. Put it all together
To avoid re-encoding you can do all the above on one line
7. Add silent audio track afterward
You probably can combine the following command with the last one but it is complicated. I think the reason is that the “putting it all together” command above is applying a video filter, and the command below is using the copy stream filter for video. However, if you are worried about re-encoding and losing video quality, here is a way to just encode the audio track, and just copy the video track without re-encoding it.
Most people write apps with sound but mine has none. Apple will reject your submission if it doesn’t have an audio track so you can add silence.
Note: Windows users should use
^ instead of
\ for multi-line commands.
8. Cutting video
Most video files have key frames that are like bookmarks at points in time in the video.
If you want to cut precisely starting at a non-keyframe and want it to play starting at the desired point on a player that does not support edit lists, or want to ensure that the cut portion is not actually in the output file then you can do that by re-encoding so that there will be a keyframe precisely at the desired start time. Re-encoding is the default if you do not specify copy. For example:
-t is total time
Example of time snipping including rotation to landscape and a scale filter for dimensions
9. Repeat last frame in video using ffmpeg
A few of my videos were a few fractions of a second short to be accepted by Apple. So I just repeated the last frame in the video a few times to make up the time.
Note: Audio is ignored in the above method.
10. Bitrate Constant Rate Factor (CRF)
You probably won’t need this but you can play around with the video quality this way:
Use this rate control mode if you want to keep the best quality and care less about the file size. This is the recommended rate control mode for most uses.
From FFmpeg wiki:
This method allows the encoder to attempt to achieve a certain output quality for the whole file when output file size is of less importance. This provides maximum compression efficiency with a single pass. By adjusting the so-called quantizer for each frame, it gets the bitrate it needs to keep the requested quality level. The downside is that you can’t tell it to get a specific filesize or not go over a specific size or bitrate, which means that this method is not recommended for encoding videos for streaming.
This command encodes a video with good quality, using slower preset to achieve better compression:
11. Changed the resolution to required dimensions, still gets rejected from Apple
I spent hours banging my head against the wall, trying every combination of filters I could think of to resize my videos. At some point you need to ask yourself “Is it really me? Or am I being misled?”
The problem below matches the one I encountered while formatting videos made with xcrun and the 11 Pro Max simulator:
Question: I need to generate another video with the resolution 1920x886 for supporting 6.5” devices, so I used the following command to perform the scaling:
- ffmpeg -i tells me the video is in the resolution 1920x886.
- macos file properties tells me the video is in the resolution 1575x886.
- VLC tells me the video has a Resolution of 1920x898 and a Display Resolution of 1920x886.
Why are there three different resolutions? How can I change each one of them? I suppose the App Store Connect website expects the file properties resolution to be 1920x886. How can I change that?
Answer: FFmpeg’s scale filter will adjust the sample aspect ratio of the video so that the original display ratio is preserved. Apple, apparently, computes the new effective display resolution using that SAR.
Insert a setsar filter to reset the SAR to 1, so that the display resolution is the same as the stored resolution.‹ ›