Opened 6 years ago

Closed 6 years ago

#7636 closed defect (invalid)

Creating a video from pictures

Reported by: Artem S. Tashkinov Owned by:
Priority: wish Component: swscale
Version: git-master Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

1 I cannot figure out how to solve the following issue using FFmpeg. Google hasn't helped at all as there are no working examples on the internet.

I have a list of images with varying wildly different dimensions and aspect ratios, from 400x200 (2x1) to 6000x4000 (3:2).

I'm creating a list of them so that I could concatenate them:

$ cat list.txt
file 'IMG_0125.jpg'
duration 3
file 'IMG_0333 (1).jpg'
duration 3
file 'testfile.png'
duration 3

etc.

Now I want all these images to be downscaled or upscaled to my chosen format, e.g. 1920x1080, while smaller images are resized to fill either vertically or horizontally while retaining proportions, e.g. for narrow images we get black bars on the left and on the right, and for very wide images we get black bars at the top and at the bottom.

This is a sample command that I tried which resizes everything to the dimensions of the 1st image which is patently wrong:

$ ffmpeg -f concat -i list.txt -vf fps=24 -pix_fmt yuv420p output.mkv

OK, I've created a 1920x1080 image and put it at the top of list.txt. However now all images are resized to 1920x1080 despite their ratios and the net result is absolutely ugly.

Various scale options do not work:

-vf scale='if(gt(a,1920/1080),1080,-1)':'if(gt(a,1920/1080),-1,1080)':'eval=frame,pad=1920:1080:(ow-iw)/2:(oh-ih)/2'

-vf scale="-1:1080,pad=1920:ih:(ow-iw)/2"

-vf scale="1920:1080:force_original_aspect_ratio=decrease,pad=1920:1080:(ow-iw)/2:(oh-ih)/2,setsar=1"

-vf scale="iw*min($width/iw\,$height/ih):ih*min($width/iw\,$height/ih), pad=$width:$height:($width-iw*min($width/iw\,$height/ih))/2:($height-ih*min($width/iw\,$height/ih))/2"

and many others.

Please advise.

2 While we are at it, please let met know how one can downscale large images to the chosen format while leaving smaller ones intact and centered again with black areas where they are pertinent.

Change History (1)

comment:1 by Elon Musk, 6 years ago

Resolution: invalid
Status: newclosed

This is bug tracker not help forum.
For help ask on user mailing list.

Note: See TracTickets for help on using tickets.