[FFmpeg-trac] #7636(swscale:new): Creating a video from pictures

FFmpeg trac at avcodec.org
Tue Dec 25 22:24:56 EET 2018


#7636: Creating a video from pictures
---------------------------------+--------------------------------------
             Reporter:  birdie   |                     Type:  defect
               Status:  new      |                 Priority:  wish
            Component:  swscale  |                  Version:  git-master
             Keywords:           |               Blocked By:
             Blocking:           |  Reproduced by developer:  0
Analyzed by developer:  0        |
---------------------------------+--------------------------------------
 **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.

--
Ticket URL: <https://trac.ffmpeg.org/ticket/7636>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list