category: iOS tag: iOS
It's quite troublesome to do screen recording. Every time I have to manually select the area. So I looked up if it's possible to record using the simulator, and it turns out it is, and surprisingly, it's very simple. Just run the following command in the command line:
xcrun simctl io booted recordVideo --codec=h264 transition.mp4
After pressing ctl+c
, the video file will be generated automatically. Just make sure there are no files with the same name. Additionally, because I often put repro on GitHub, which doesn't support video files, I convert them to gif using ffmpeg:
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
Later, I will gradually study the parameters of ffmpeg. In any case, this way you can convert video files to gif files. Awesome!