· 1 min read

How to Record Video with Xcode Simulator

This article was auto-translated from Chinese. Some nuances may be lost in translation.

category: iOS tag: iOS

Screen recording is such a hassle since you have to drag and select the capture area every time. So I looked into whether it’s possible to record directly from the simulator, and it turns out you can! It’s surprisingly simple, too—all it takes is a single command in the terminal:

xcrun simctl io booted recordVideo --codec=h264 transition.mp4

Pressing Ctrl+C will stop recording and automatically generate the video file; just make sure you don’t already have an existing file with the same name. Also, since I often upload repros to GitHub and GitHub doesn’t support video files, I use ffmpeg to convert it into a GIF:

ffmpeg -ss 2 -t 20 -i YOUR_VIDEO_NAME -vf "fps=10,scale=320:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -loop 0 OUTPUT.gif

I’ll dig deeper into ffmpeg parameters later, but anyway, this does the job of turning a video file into a GIF. Awesome!

Related Posts

Explore Other Topics