Screenshot logic improvement

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 :slight_smile: 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

1 Like

Updated my wrapper script and you can see now these icons are correctly sized using ceil logic. I am not cropping the image to 16:9 but it is at least correct 4:3 AR picture.

I added this to the latest DVR build, but it appears to have broken thumbnail generation for h264 transcoded recordings made by the HDHR EXTEND in “mobile” mode.

Stream #0:0[0x489]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(tv, progressive), 1280x540 [SAR 3:4 DAR 16:9], Closed Captions, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc