I want to generate 16:9 thumbnails from videos with white padding but the resulting picture has grey padding instead of white. This is the command line (input here is a jpg but the effect is the same when using a video):

ffmpeg.exe -i "https://gooseberry.blender.org/wp-content/uploads/2014/01/franck.jpg" -filter_complex scale=iw*min(852/iw\,480/ih):ih*min(852/iw\,480/ih),pad=852:480:(852-iw*min(852/iw\,480/ih))/2:(480-ih*min(852/iw\,480/ih))/2:white,fps=fps=50/5.000000 output.jpg

the resulting image (text and white box added with paint): enter image description here

even though the padding color is white it's light grey in reality. Is there a way to get it 'whiter'? It's especially ugly if you plan to print it on paper.

  • Please show the complete console output from your ffmpeg command. – llogan Oct 23 '15 at 17:41
  • The padding is RGB 235, which is the upper limit in conventional video. So, a video player will expand 235 to show white. – Gyan Oct 23 '15 at 17:44
  • @mulvya that's great for conventional video but not if you plan to print it. Any way to override this – Sebastian Annies Oct 23 '15 at 18:22
  • Outputting to PNG will get you pure white. Then using ffmpeg again to convert to JPG preserves the values. – Gyan Oct 23 '15 at 18:28
  • 1
    So, first ffmpeg.exe -i franck.jpg -filter_complex "scale=iwmin(852/iw\,480/ih):ihmin(852/iw\,480/ih),pad=852:480:(852-iwmin(852/iw\,480/ih))/2:(480-ihmin(852/iw\,480/ih))/2:white,fps=fps=50/5.000000 franck-padded.png – Gyan Oct 23 '15 at 18:29

The end of the filter chain should output full RGB, like this:

Windows batch:

ffmpeg.exe -i "https://gooseberry.blender.org/wp-content/uploads/2014/01/franck.jpg" ^
  -filter_complex ^
format=rgb24 franck-padded.jpg

Linux bash:

ffmpeg -i "https://gooseberry.blender.org/wp-content/uploads/2014/01/franck.jpg" \
  -filter_complex \
format=rgb24" franck-padded.jpg

The important part is format=rgb24 which keeps or converts the final filter output to the RGB pixel format, which allows full range values from 0-255. Without that final filter, ffmpeg will convert the filter output to the YUV pixel format where the range of legal values is 16 to 235 for luma (brightness) - 16 maps to black and 235 to white - and 16 to 240 for the chroma components (color). (The default YUV colorspace range is a legacy of analog television signals and carried over into the digital realm by the MPEG committee and hence still widely adhered to by most digital video formats)

enter image description here

| improve this answer | |
  • It doesn't work for me. Still get grey color. – Tyler Long Nov 10 '16 at 15:22
  • What command are you using? – Gyan Nov 10 '16 at 15:26
  • ffmpeg -i input.png -vf "pad=iw+0:ih+300:0:300:#FFFFFF@1,format=rgb24" -y output.png – Tyler Long Nov 10 '16 at 15:34
  • Don't see anything wrong. How are you checking the output? – Gyan Nov 10 '16 at 15:52
  • I open the output in both Chrome and Preview on Mac and I confirm that the color is grey instead of white. FFmpeg is based on an old version (2015-02), I will try the latest version soon. – Tyler Long Nov 11 '16 at 1:42

The accepted answer doesn't work for me. I find a work around to this problem. PNG images doesn't have this issue. So you could first convert the file into PNG, then do the padding and convert it back to original image type. Let's say you have a file named input.jpeg, try something like this:

ffmpeg -i input.jpeg -y temp.png
ffmpeg -i temp.png -vf "pad=iw+0:ih+300:0:300:#FFFFFF@1" -y output.jpeg
| improve this answer | |
  • 1
    This is the workaround @Mulvya posted last year under Sebastian's answer – Dr Mayhem Nov 11 '16 at 17:53
  • @DrMayhem looked carefully and I didn't see it. And it turns out to be under the question (instead of the answer). I didn't see it before I posted my answer. – Tyler Long Nov 12 '16 at 0:15

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.