Menu

Post image 1
Post image 2
1 / 2
0

How to Crop and Resize Video with FFmpeg

DEV Community·Javid Jamae·27 days ago
#ARSXwQPm
#how#ffmpeg#webdev#crop#scale#fullscreen
Reading 0:00
15s threshold

Originally published at ffmpeg-micro.com You need to resize a video to 720p. Or crop a landscape clip to vertical for TikTok. FFmpeg handles both, but the syntax trips up even experienced developers, especially around aspect ratios and pixel dimension requirements. This guide covers the three filters you actually need: scale , crop , and pad . How to Resize Video with the FFmpeg Scale Filter The scale filter sets the output width and height in pixels. ffmpeg -i input.mp4 -vf "scale=1280:720" -c :v libx264 -crf 23 output.mp4 Enter fullscreen mode Exit fullscreen mode This forces the video to exactly 1280x720. If your source has a different aspect ratio, the output gets stretched. To preserve the aspect ratio, use -2 for the dimension you want FFmpeg to calculate automatically: ffmpeg -i input.mp4 -vf "scale=1280:-2" -c :v libx264 -crf 23 output.mp4 Enter fullscreen mode Exit fullscreen mode Why -2 instead of -1 ? H.264 and H.265 encoders require even pixel dimensions.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More