How to Convert a Video to Multiple Resolutions in 1 Click

If you want a video to be output in multiple resolutions, this article is for you. In this guide, I will give you a terminal command that can scale a video to multiple resolutions while maintaining the aspect ratio.

If you are a content creator, you may want to publish your videos to different social media platforms. But this creates a friction — different social media platforms have different preferences for aspect-ratios: YouTube prefers 16:9 (horizontal videos) whereas Tik-Tok and Instagram want them vertical.

This can be frustrating because you don’t want to post the same video everywhere and have it look weird due to cropping. The best experience is to tailor each video to the platform you’re posting on.

Unfortunately, editing a separate version for each platform is time-consuming. You’d have to open your video editor, change the project settings, and export multiple files. Plus, changing a video’s aspect ratio often means adding black bars (like in a movie) to avoid distorting the picture.

Also read: 4 Awesome tricks to Change the Default Fonts in Excalidraw

Wouldn’t it be great if there was a tool that could resize your videos automatically without distorting the original video? Something that could reduce this 10-minute ordeal to a single command?

Luckily, there is! It’s a software called FFMPEG, and it works within your computer’s terminal to manipulate videos and audio. In fact, many professional video editing programs use FFMPEG in the background.

FFMPEG is completely free to use and is available for Mac, Windows and Linux.

To get started, you’ll need to install FFMPEG. If you have Homebrew, it’s easy. Open your terminal and run this command:

brew install ffmpeg

For more help with the installation process, read this guide.

Once you have FFMPEG installed, you’re ready to start resizing those videos!

Creating multiple resolutions of a video using FFMPEG

FFMPEG works in terminal with commands. You write commands to tell it exactly how you want to transform your video.

Let’s focus on a specific transformation: resizing your video for different platforms while keeping everything nicely centered.

Here’s what the command will do:

  • Resize to different dimensions: We’ll tell FFMPEG the different resolutions you need (like 1920×1080 for classic YouTube, or 1080×1920 for TikTok).
  • Preserve the look: Your original video won’t get stretched or squished. FFMPEG will maintain the aspect ratio.
  • Add stylish padding: If the new size leaves empty space, FFMPEG will add black bars to keep your video in the center. You can even customize the color if you like!

Also read: How to Read the New Yorker and Atlantic articles for FREE

Now, imagine you have a video and want it in these four sizes:

  • 1920 x 1080
  • 1280 x 720
  • 1080 x 1920
  • 1920 x 1920

This command will do it:

ffmpeg -i input_video.mp4 \
-filter_complex "\
[0:v]scale=w=1920:h=1080:force_original_aspect_ratio=decrease,pad=1920:1080:(ow-iw)/2:(oh-ih)/2:black[out1]; \
[0:v]scale=w=1280:h=720:force_original_aspect_ratio=decrease,pad=1280:720:(ow-iw)/2:(oh-ih)/2:black[out2]; \
[0:v]scale=h=1920:w=1080:force_original_aspect_ratio=decrease,pad=1080:1920:(ow-iw)/2:(oh-ih)/2:black[out3]; \
[0:v]scale=w=1920:h=1920:force_original_aspect_ratio=decrease,pad=1920:1920:(ow-iw)/2:(oh-ih)/2:black[out4]" \
-map "[out1]" -map 0:a -c:v libx264 -c:a copy 1920x1080_video.mp4 \
-map "[out2]" -map 0:a -c:v libx264 -c:a copy 1280x720_video.mp4 \
-map "[out3]" -map 0:a -c:v libx264 -c:a copy 1080x1920_video.mp4 \
-map "[out4]" -map 0:a -c:v libx264 -c:a copy 1920x1920_video.mp4

It looks like a giant blob of text but here’s a breakdown:

Detailed explanation:

  • -i input_video.mp4: input_video.mp4 is the name of your input video file.
  • -filter_complex: Allows complex filter graphs to be created.
  • [0:v]: Refers to the video stream of the input file.
  • scale: Resizes the video to the specified width and height while maintaining the aspect ratio.
  • force_original_aspect_ratio=decrease: Ensures that the original aspect ratio of the video is maintained while resizing.
  • pad: Adds black padding to the video to keep it centered.
  • 1920:1080, 1280:720, 1080:1920, 1920:1920: Specifies the output resolutions.
  • map: Specifies the mapping of input and output streams.
  • -c:v libx264: Sets the video codec to libx264 for encoding.
  • -c:a copy: Copies the audio stream without re-encoding (speeds up the process)
  • 1920x1080_video.mp4, 1280x720_video.mp4, 1080x1920_video.mp4, 1920x1920_video.mp4: Names of the output files denoting their resolutions.

This command will produce four different outputs, each in desired resolution while maintaining the aspect ratio.

How did I got this command:

To be frank, this command is intimidating. Also, I didn’t come up with it myself. I used ChatGPT.

How to use ChatGPT to generate exact FFMPEG commands

The magic of ChatGPT is that you can ask it to customize the command to get the output exactly how you want. You don’t have to settle for anything less.

I have also written another article which goes into most common video manipulation commands, such as converting a video to GIF, speeding up or slowing it down or removing audio etc.

If this is your frequent use case, you may want to convert this command to a shortcut and run it directly from Raycast. For more information, read our guide on how to run a terminal command from Raycast.

I hope this article introduced you to the awesomeness of FFMPEG.

I hope you got some value out of this article. If you did, please share it on social media. If you have got any queries, you may drop a line below or contact me on X (Twitter).

Thanks for reading.