Skip to content

Convert video to different resolutions with FFmpeg

Converting videos to different resolutions is a common task for anyone working with digital video content. Whether you're a content creator, video editor, or a developer working on video applications, understanding how to adjust video resolutions can help you optimize videos for different devices, platforms, and viewing experiences. This guide will walk you through various methods of changing video resolutions using FFmpeg.

LinkReasons for converting your video to different resolutions

There are several reasons why you might want to convert video to different resolutions:

  1. Device compatibility: Ensure videos play smoothly on devices with different screen sizes and capabilities.
  2. Bandwidth optimization: Lower resolutions require less bandwidth, improving streaming performance on slower connections.
  3. Storage management: Reduce file sizes for more efficient storage and faster uploads.
  4. Platform requirements: Meet specific resolution guidelines set by social media or video sharing platforms.
  5. Adaptive streaming: Create multiple resolution versions for adaptive bitrate streaming.
  6. Quality improvement: Upscale lower resolution footage for use in higher resolution projects.

Let's explore how to use FFmpeg to convert videos to different resolutions in various scenarios.

LinkBasic resolution conversion

The simplest way to change the resolution of a video is to use FFmpeg's scale filter:

bash
ffmpeg -i input_video.mp4 \ -vf "scale=1280:720" \ -c:a copy \ output.mp4

Breakdown of the command:

  • -i input_video.mp4: Specifies the input video file
  • -vf "scale=1280:720": Applies the scale filter to resize the video to 1280x720 pixels
  • -c:a copy: Copies the media streams without re-encoding
  • output.mp4: Name of the output file

This command will produce a video with a resolution of 1280x720 (720p), which is suitable for many web streaming scenarios.

LinkMaintaining aspect ratio

To maintain the original aspect ratio while changing resolution:

bash
ffmpeg -i input_video.mp4 \ -vf "scale=1280:-1" \ -c:a copy \ output.mp4

Here, -1 tells FFmpeg to automatically calculate the height while maintaining the aspect ratio after sizing to the new width.

LinkConverting to common resolutions

Here are commands for converting to some common resolutions, they all specify h264 for the output video codec:

Link4K (3840x2160)

bash
ffmpeg -i input_video.mp4 \ -vf "scale=3840:2160" \ -c:v libx264 -crf 23 \ -c:a copy \ output_4k.mp4

Link1080p (1920x1080)

bash
ffmpeg -i input_video.mp4 \ -vf "scale=1920:1080" \ -c:v libx264 -crf 23 \ -c:a copy \ output_1080p.mp4

Link720p (1280x720)

bash
ffmpeg -i input_video.mp4 \ -vf "scale=1280:720" \ -c:v libx264 -crf 23 \ -c:a copy \ output_720p.mp4

Link480p (854x480)

bash
ffmpeg -i input_video.mp4 \ -vf "scale=854:480" \ -c:v libx264 -crf 23 \ -c:a copy \ output_480p.mp4

LinkAdvanced resolution conversion techniques

LinkUpscaling with enhanced quality

For better quality when upscaling, you can use more advanced scaling algorithms:

bash
ffmpeg -i input_video.mp4 \ -vf "scale=3840:2160:flags=lanczos" \ -c:v libx264 -crf 18 \ -c:a copy \ output_4k_enhanced.mp4

This uses the Lanczos scaling algorithm, which can provide better results for upscaling.

LinkCreating multiple resolutions for adaptive streaming

To create multiple resolutions for adaptive streaming see the guide on converting mp4 to HLS.

LinkChoosing the right resolution conversion method

Different resolution conversion techniques have various benefits and drawbacks:

Simple scaling:

  • Benefits:
    • Fast and straightforward
    • Suitable for most basic needs
  • Drawbacks:
    • May not provide the best quality for significant resolution changes

Advanced scaling algorithms:

  • Benefits:
    • Better quality, especially for upscaling
    • Reduces artifacts and maintains sharpness
  • Drawbacks:
    • Slower processing time
    • May require more experimentation to find optimal settings

Multiple resolution encoding:

  • Benefits:
    • Prepares videos for adaptive streaming
    • Provides options for various playback scenarios
  • Drawbacks:
    • More complex to set up
    • Requires more storage space for multiple versions

LinkTips for effective resolution conversion

  • Consider your target devices: Research common screen resolutions for your target audience's devices.
  • Balance quality and file size: Higher resolutions mean larger file sizes; find the right balance for your needs.
  • Use appropriate codecs: Modern codecs like H.264 or VP9 can provide better quality at various resolutions.
  • Test thoroughly: Always test your converted videos on different devices and screen sizes.
  • Mind the aspect ratio: Be cautious when changing aspect ratios, as this can distort the image.
  • Adjust bitrate accordingly: Higher resolutions typically require higher bitrates to maintain quality.
  • Consider the source material: The quality of your output is limited by the quality of your input video.

No credit card required to start using Mux.