I have a file of resolution 3840x1632, but my TV stretches the picture vertically to fill up all 2160 pixels of height. Is it possible to use ffmpeg to add blank / black height, while preserving the video and audio quality?

Tried doing this, which seemed to work (took about 2 hours, the same length of the video), but greatly reduced the file size/video quality):

ffmpeg -i input.mkv -filter:v "pad=3840:2160:0:280" -c:a copy my_output_video.mkv

Is there a switch to say "keep everything else the same"?

Thank you!

3 Answers 3


You'll have to manually set encoding parameters.

ffmpeg -i input.mkv -filter:v "pad=3840:2160:0:280,setsar=1" -crf 18 -preset faster -c:a copy my_output_video.mkv

The CRF option sets the tradeoff for size/quality. Lower values produce better quality but larger files. The preset will increase speed, but for same quality, the file size will be larger.

The setsar filter has been added as a precaution in case your player reads the SAR stored in the file and stretches the video based on that value.


You can do transformations with -c:v libx264 -crf 0 X264 has lossless mode, which it enters with -crf 0. They implemented real lossless video encoding, this is not widely known - but it works perfectly.

I use it all the time.

Be ready - it takes GBs - especially for videos of real-life (not graphics etc...)

Doing screen recording for programs and graphis in -crf 0 - is perfect - it compresses them really great and uses relatively small CPU power.

You also can control compression complexity it uses, with the presets (fast, veryslow ... etc). And you also can recomress lossles into more compressed lossless.

Everything for lossless is the same as for all x264's, except that it is the real lossless.

  • The OP intends to play the files on a TV, and most h/w or s/w decoders don't support Hi444 profile which is what crf/qp 0 requires.
    – Gyan
    Oct 12, 2019 at 19:39
  • @Gyan Yep, what you say is true. Except I said "transformations". The idea I represent - person does not know how to play with lossless processing. He can develop workflow in lossless form in stages, and then all that can be moved into on-the-fly bulk processing into lossy. Also lossless can be directly compared. Like I had two days before. If input file has 11.8 GB, letterboxed file also would be 11.8 GB - you see right away that all information is preserved. & Lossless can always be encoded into lossy. Oct 13, 2019 at 23:11
Here is my solution with explanation
ffmpeg -i input.mkv -filter:v "pad=3840:2160:0:280,setsar=1" -c:a copy -c:v libx265 -x265-params lossless=1 my_output_video.mkv

1 - input filename
2 - Target X dimension
3 - Target Y
4 - Bar's target X pos. Best: Floor( (Target X - Current X) / 2) . If the value is 0, no vertical baps will be present.
5 - Bar's target Y pos. Best: Floor( (Target Y - Current Y) / 2) . If the value is 0, no horizontal baps will be present.
6 - output filename

-c:a copy is to maintain lossless-ness
-x265-params lossless=1 option is for lossless encoding. Adding -crf 0 is not required.
-c:v libx265 - added to reduce output video quality while maintaining lossless-ness
Floor() - means to floor DOWN where applicable (ideally, no non-integer calculations occur)

My example command to add bars from 1660x780 to 1920x1080,

ffmpeg -i input.mp4 -filter:v "pad=1920:1080:130:150,setsar=1" -crf 0 -c:v libx265 -x265-params lossless=1 my_output_video.mp4

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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