Use FFmpeg to speed up iOS Simulator recordings

July 16, 20243 min read#swift, #ios, #ffmpeg

Intro

At work, I usually attach a record video for my features from iOS Simulators to my merge requests. This demo video has many advantages:

  • First of all, to record the video, I’m basically executing the first Quality Assurance round for my code
  • My teammates will get more context about the features
  • The makes it easier for code review as the feature can be visually inspected
  • It serves as documentation for future knowledge sharing or demoing purposes

Sometimes, I even go further by recording the demo videos from my automated UI Tests. This is my ultimate goal that I have for every merge requests that have

One problem I have with my recordings from iOS Simulators, especially the ones from my UI Tests, is that they are pretty long, so people would need more time to watch them.

I have asked ChatGPT to write me an FFmpeg command to speed up the video so that people can watch the video in 2x speed. I pasted the answer from ChatGPT here for references in case anyone need to do the same thing for their demo videos:

FFmpeg command:

To speed up a video using ffmpeg, you can use the setpts filter for the video stream and the atempo filter for the audio stream. Here is the command to speed up an input.mp4 video by 2 times:

ffmpeg -i input.mp4 -vf "setpts=0.5*PTS" -filter:a "atempo=2.0" output.mp4

Here’s what each part of the command does:

  • -i input.mp4: Specifies the input file.
  • -vf “setpts=0.5*PTS”: Applies the video filter setpts to speed up the video. The PTS (Presentation Timestamp) is multiplied by 0.5 to double the speed.
  • -filter:a “atempo=2.0”: Applies the audio filter atempo to speed up the audio. The atempo filter accepts values between 0.5 and 2.0 for a single command, so to speed up the audio by 2 times, we use 2.0.
  • output.mp4: Specifies the output file.
Quick Drop logo

Profile picture

Personal blog by An Tran. I'm focusing on creating useful apps.
#Swift #Kotlin #Mobile #MachineLearning #Minimalist


© An Tran - 2024