DEV Community

Picoable
Picoable

Posted on • Originally published at bashlinux.picoable.com

Creating App Store-Compliant App Previews with FFmpeg

Creating app previews for the Apple App Store can be a meticulous process. Apple has a strict set of requirements that your videos must meet to be accepted. Fortunately, the powerful and versatile command-line tool FFmpeg can make this process much easier. This guide will walk you through the steps to create a compliant app preview using FFmpeg.

Key App Store Preview Requirements

Before we dive into the FFmpeg commands, let's summarize the key requirements from Apple's official documentation:

  • Video Codec: H.264 or ProRes 422 (HQ)
  • Audio Codec: AAC or PCM
  • Frame Rate: Up to 30 fps
  • Duration: 15 to 30 seconds
  • Audio: Must include a stereo audio track, even if silent.
  • Resolution: Varies by device, but you must provide a video with the correct resolution for the devices you are targeting.
  • File Format: .mp4, .mov, or .m4v

The Magic of FFmpeg

FFmpeg is a free and open-source software project consisting of a vast software suite of libraries and programs for handling video, audio, and other multimedia files and streams. It can be used to convert between different file formats, resize videos, and much more.

Crafting the FFmpeg Command

Here is a template for an FFmpeg command that you can adapt to create your app previews. This command assumes you have an input video file named input.mp4 and are targeting a portrait resolution common for iPhones.

ffmpeg -i input.mp4 -c:v libx264 -profile:v high -level 4.0 -pix_fmt yuv420p -r 30 -vf "scale=1080:1920,setsar=1:1" -t 30 -c:a aac -b:a 256k -ar 44100 -ac 2 -f lavfi -i anullsrc=channel_layout=stereo:sample_rate=44100 -shortest output.mp4
Enter fullscreen mode Exit fullscreen mode

Let's break down this command:

  • -i input.mp4: Specifies the input file.
  • -c:v libx264: Sets the video codec to H.264.
  • -profile:v high -level 4.0: Sets the H.264 profile and level. These are common and widely supported settings.
  • -pix_fmt yuv420p: Sets the pixel format. This is a common and compatible pixel format.
  • -r 30: Sets the frame rate to 30 frames per second.
  • -vf "scale=1080:1920,setsar=1:1": This filter resizes the video to a portrait resolution of 1080x1920 pixels and sets the Sample Aspect Ratio to 1:1 to ensure square pixels. You will need to change the resolution to match your target device.
  • -t 30: Sets the duration of the video to 30 seconds. You can adjust this as needed, but it must be between 15 and 30 seconds.
  • -c:a aac -b:a 256k -ar 44100 -ac 2: Sets the audio codec to AAC with a bitrate of 256k, a sample rate of 44.1kHz, and explicitly sets 2 audio channels for stereo.
  • -f lavfi -i anullsrc=channel_layout=stereo:sample_rate=44100: This is the key part for adding a silent audio track. It generates a silent audio stream.
  • -shortest: This option ensures that the output file is the same length as the shortest input stream (your video).
  • output.mp4: The name of the output file.

Important Considerations

  • Resolution: The -vf "scale=1080:1920,setsar=1:1" part of the command is critical. You must replace 1080:1920 with the correct resolution for the device you are targeting. You can find the full list of required resolutions in the Apple Developer documentation.
  • Silent Audio: Even if your app preview has no sound, you must include a silent audio track. The command above handles this for you.
  • Quality: The H.264 profile and level settings in this command are a good starting point for achieving a balance between quality and file size. You can experiment with these settings to fine-tune the quality of your video.

Conclusion

FFmpeg is an incredibly powerful tool that can simplify the process of creating App Store-compliant app previews. By using the command in this guide as a starting point, you can easily create high-quality app previews that meet all of Apple's requirements.

Top comments (0)