1

I wanna resize an upscaled 1366x768 image down to its native 480x270 again.

Every time I do it, lines of pixels are misplaced. Example with highlighted areas. The image on the right is slightly out of frame, but the differences are clearly visible.

I tried using variations of the following command to no avail: ffmpeg -i "imagepath" -q:v 1 -vf scale=480:-1 -sws_flags neighbor "outputpath"

Some advice on what's going on and how I could resample it down without misplacing columns and rows of pixels would be much appreciated.

This is the image in question.

3

Your results are normal, because your input size is not an exact multiple of your output size – it is not an exact downscale like 3-to-1 but more like 2.85(ish)-to-1; so eventually there will be output pixels that only correspond to e.g. 2 or 4 or 3½ input pixels and have to be stretched or compressed.

The provided image seems to have 3×3 "large pixels" (dots? cells? squares? I don't know of a good term), so if you claim the original was 480×270, this means it was actually upscaled to 1440×810 and then cropped to fit 1366×768. So the recoverable original is only 456×256.

(To see this visually, open the file in GIMP, select "Enable grid", "Configure grid", choose 3×3px. Note that vertically it doesn't even have an integer amount of "large pixels"; the leftmost and rightmost columns are only 2px wide and cause everything to be offset from the grid.)

So what you'd need to do is:

  1. Pad or crop the image so that both dimensions are multiples of 3 (the "large pixel" size). The vertical size is already good, but horizontally you must pad by 1px left & right – this will also realign the columns to grid. I used GIMP's "Canvas Size" because I don't know ffmpeg filters.

  2. Scale down to 456:256 or 456:-1 because that's the actual data you've got – the rest had been cropped away. I used your ffmpeg command for this.

Here's the result:

Output image

  • Huh. I'd never have known. I really appreciate the help, thanks a lot. – Unknow0059 Jul 10 at 5:04

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.