The words Under construction in black text on a yellow background with diagonal black stipes surrounding it
I'm in the process of moving my site. It's still a work in progress. Please excuse the mess and broken links.

Resize A Video With FFmpeg

TODO: Pull subtitle into page object

TL;DR

This is the FFmpeg command I use to resize videos:

NOTE: If audio doesn't copy try adding `-c:a copy``

Code
ffmpeg -i "in.mp4" -vf "scale=720:-2" "out.mp4"

It resizes the _in.mp4__ video to a 720 pixel wide version called _out.mp4__. The height is determined automatically.

Details

Resizing videos with FFmpeg by adding this to the command:

Code
-vf "scale:WIDTH:HEIGHT"

The WIDTH and HEIGHT can be set to arbitrary values. That includes values that don't match the original aspect ratio which would result in distorted output.

Using `-2`` on one of the dimensions automatically resizes it to fit the aspect ratio. For example, a 3840x2160 source video resized with this:

Code
ffmpeg -i "in.mp4" -vf "scale=1920:-2" "out.mp4"

produces a video that's 1920x1080.

Putting the `-2`` on the HEIGHT works as well. For example, this also produces a 1920x1080 video from a 3840x2160 source.

Code
ffmpeg -i "in.mp4" -vf "scale=-2:1080" "out.mp4"

Notes

Debugging Stuff

I'm moving stuff around right now. All this below is helping me figure out where to put stuff

        -- title

Resize A Video With FFmpeg


-- h2

TL;DR

This is the FFmpeg command I use to resize videos:

NOTE: If audio doesn't copy try adding `-c:a copy``

-- code
-- shell

ffmpeg -i "in.mp4" -vf "scale=720:-2" "out.mp4"


-- p 

It resizes the _in.mp4__ video to a 720 pixel
wide version called _out.mp4__. The height is 
determined automatically.


-- h2 

Details

Resizing videos with FFmpeg by adding this 
to the command:


-- code
-- shell

-vf "scale:WIDTH:HEIGHT"


-- p

The WIDTH and HEIGHT can be set to 
arbitrary values. That includes values that don't
match the original aspect ratio which
would result in distorted output.  

Using `-2`` on one of the dimensions 
automatically resizes it to fit the aspect 
ratio. For example, a 3840x2160 source video 
resized with this:

-- code
-- shell

ffmpeg -i "in.mp4" -vf "scale=1920:-2" "out.mp4"


-- p

produces a video that's 1920x1080.

Putting the `-2`` on the HEIGHT 
works as well. For example, this also produces 
a 1920x1080 video from a 3840x2160 source. 


-- code
-- shell

ffmpeg -i "in.mp4" -vf "scale=-2:1080" "out.mp4"


-- notes

- It's possible to use `-1`` instead of `-2`` in 
the examples above, but it's not recommended. Using
`-1`` matches the aspect ratio exactly which means 
it could be an odd number. Some filters can't
deal with odd numbers. Using `-2`` ensures the
value is even. 


-- todo

[] Link to cropping post - id: 2o4bcmue

[] Link to image quality post - id: 2svphsuw

[] Look at `-c:a copy`` which might be for audio and might
be necessary

[] Link to resize with padding example -- id: 2sxx0svx

[] Show examples of cropping and resizing



-- ref
-- title: FFmpeg
-- url: https://ffmpeg.org/


-- categories
-- ffmpeg 

-- metadata
-- date: 2022-06-05 00:20:21
-- id: 2a8t12xg
-- type: post
-- SCRUBBED_NEO: false
-- site: aws
-- status: published