Hello,
Your current screenshot logic only works correctly on videos with SAR 1:1.
Your current logic uses this video filter:
-vf scale=640:-2,thumbnail=5
If you use that logic against 528x480 [SAR 40:33 DAR 4:3] you get an image that is 640x582 [SAR 97:80 DAR 4:3]
I propose you change your logic to:
-vf scale="${output_width}:ceil((out_w/dar/2)*2)",thumbnail=5
using that logic generates an icon 640x480 [SAR 1:1 DAR 4:3] which is correctly sized.
trunc logic works in some instances, such as 720x480 [SAR 8:9 DAR 4:3] it will output a correctly sized 640:480. However it will mess up if you provide it 528x480 [SAR 40:33 DAR 4:3].
I suggest you use ceil logic as provided above. Let me know if you have any questions or I can elaborate further. If your super anal retentive you could check to see if the picture first needs cropping and apply a crop filter to it too I suppose I could run this through my crop routines in my wrapper and auto crop it to 16:9 if needed as well, but where does it end....
Attached are 2 pictures, 640x480 and 640x582. The 640x582 was created by your screenshot logic. The 640x480 was created by ceil logic.
A little script here to aid you in your testing of the new logic
https://www.dropbox.com/s/e7ytaystvi03xro/screenshot.sh?dl=0