Menu

1 / 2

How to Create a Video From Images With FFmpeg (Without Stretching Portrait Photos)

DEV Community: python·Voor AI·13 days ago
#LFztniof
#devtopython#devto#dev#hold#height
Reading 0:00
15s threshold

To create a video from images with FFmpeg, fit every image into one fixed canvas before it reaches the encoder: scale with force_original_aspect_ratio=decrease and force_divisible_by=2 , then pad (or a blurred fill) to exactly 1920×1080, convert to limited-range yuv420p , hold each still with -loop 1 plus trim , and join the stills with xfade . Then check the result with ffprobe: frame count, size, SAR, pixel format and a duration of n × hold − (n − 1) × fade .

The usual one-liner skips the fitting step. With a folder of mixed photos it either refuses to start or, worse, exits 0 and quietly stretches every portrait photo.…

Continue reading — create a free account

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