I have a toolchain that produces frames that are usually 1920x1080, but occasionally 1919x1080 or 1920x1079. (Yes, this is a bug. Please read on.) When ffmpeg encodes a video from it, with a command like

ffmpeg -y -r 30 -i foo/%04d.png -vcodec h264 out.mp4

then it prints remarks like

Input stream #0:0 frame changed from size:1919x1080 fmt:rgb24 to size:1920x1080 fmt:rgb24

but those frames, rather than being resized and included in out.mp4, are omitted from out.mp4.

Can those frames be included? I found no mention of nonconstant frame size on forums and in documentation, but ffmpeg itself here claims to resize the frame. (The remark is printed at line 1688 of ffmpeg.c. There, a flag resample_changed is set, which causes the width and height fields of InputStream *ist to be corrected.)

David Elliman may be reporting similar behavior in an answer to https://stackoverflow.com/questions/18043841/ffmpeg-missing-image-frames-in-generated-video-from-images?rq=1 .

  • The best elaborated answer seems to be this one: superuser.com/questions/547296/… which adds black borders to the videos of different frame sizes to avoid stretching (i.e. avoid changing the aspect ratio of the videos).
    – erik
    Jun 4, 2016 at 11:05
  • Pillar- or letter-boxing is appropriate when frame size changes a lot, but not in this case, when it changes by one or two pixels. Then, flashing black borders would be distracting. Jun 6, 2016 at 15:33

4 Answers 4


Perhaps the scale video filter can provide what you're looking for:

ffmpeg -r 30 -i foo/%04d.png -vf "scale=1920:1080,format=yuv420p" -codec:v libx264 out.mp4

This will force a size of 1920x1080 for each frame. This may result in a slightly stretched or squished image if your weird sized inputs are simply cropped instead of scaled incorrectly. If that is the case the consider using the pad video filter instead but be aware that it will result in a solid colored bar to compensate for the missing pixels.

scale also accepts various functions if you want to get fancy with it. See Resizing videos with ffmpeg to fit into static sized player for an example.

I added format=yuv420p because, with an RGB input for libx264, ffmpeg will attempt to avoid chroma subsampling resulting in YUV 4:4:4 planar pixel format which most players can not decode.


Whether or not this is a bug in FFmpeg or something FFmpeg should better document support or lack of support for, I don't really see the programming question. You should fix your bug that's generating incorrect frame sizes and be thankful that FFmpeg alerted you to this issue, since silently "fixing" them by expanding or resampling may had led to tiny "jitter" in the encoded video and left you with subtly-defective output video and poor compression quality.

  • I see FFMpeg (compiled version) as an API that happens to be accessed via a CLI, making it an obvious programming question. Aug 6, 2013 at 19:39
  • 2
    @FlavorScape: FFmpeg CLI is not API. libav* is API. The CLI question belongs to SuperUser, there is nothing for programming here.
    – Roman R.
    Aug 6, 2013 at 20:38
  • It's really a matter of nomenclature. In essence they are the same. CLI, API (and Web GUI) are doing the same thing behind the scenes: changing values of configurable variables and data structures. It doesn’t matter which mechanism you use to set a variable value or insert a new data structure in a linked list – no API will save the day if the software you’re interacting with doesn’t support the functionality you need. -blog.ipspace.net/2013/06/… Aug 6, 2013 at 21:13
  • My bad. Based on the answers so far, the question as asked is indeed a better fit for SuperUser.com, where I have an account. (I don't think I can self-migrate it.) Aug 6, 2013 at 22:26

You might have to specify a scale mode for the resizing to work. I grabbed this from my implementation.

--custom-anamorphic --display-width 1920  --keep-display-aspect --modulus 8 --crop 0:0:0:0
  • Has this to do with ffmpeg? I don’t think so. Or tell me please how to use it with ffmpeg.
    – erik
    Jun 2, 2016 at 16:35
  • you can run any of these commands from the command line. any GUI you installed is a flavor of ffmpeg ( a wrapper around it). Jun 2, 2016 at 16:44
  • Which version of ffmpeg do you think has these command line options? I couldn’t find a help file explaining the options you listed.
    – erik
    Jun 2, 2016 at 16:56
  • 1
    Instead of just posting a link, you could have explained: Your answer uses Handbrake instead of ffmpeg. Has nothing to do with ffmpeg, except that this (Handbrake) is a tool which may also use ffmpeg as backend.
    – erik
    Jun 25, 2016 at 14:29

Try omitting the -r 30 parameter for the input framerate and use -framerate 30 for the output framerate instead. I had the same problem and that worked for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.