Skip to content

Fix ffmpeg snapshot aspect ratio with auto width#167

Merged
tatsumoto-ren merged 1 commit into
Ajatt-Tools:masterfrom
cnra:agent/fix-ffmpeg-snapshot-aspect
Jul 13, 2026
Merged

Fix ffmpeg snapshot aspect ratio with auto width#167
tatsumoto-ren merged 1 commit into
Ajatt-Tools:masterfrom
cnra:agent/fix-ffmpeg-snapshot-aspect

Conversation

@cnra

@cnra cnra commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

I was trying to create cards with 480px height and auto width.

  • Source video: 1280x720 SAR 3:4 DAR 4:3
  • Expected WebP: 640x480 SAR 1:1
  • Actual result before this fix: 854x480, which appears stretched as WebP

Here is the config I was using:

use_ffmpeg=yes
snapshot_format=webp
snapshot_width=-2
snapshot_height=480

This changes the auto-dimension scale filter to calculate the output size from the display aspect ratio and normalize the snapshot with setsar=1.

@tatsumoto-ren

tatsumoto-ren commented Jul 9, 2026

Copy link
Copy Markdown
Member

Source video: 1280x720
Expected WebP: 720/480=1.5, so 1280/1.5=854.

Your webp snapshot should be 854x480, not 640x480. The current behavior appears to be correct.

@cnra

cnra commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

The source video is a little confusing because its stored frame size is 1280x720, which looks like 16:9 at first.

But it has SAR 3:4, so it is not displayed as square-pixel 1280x720. mpv displays it as 4:3, not 16:9.

here is screenshot to be clear with the mpv and the generated image before this fix:
comparison

Here is a clip from video I was working with. ffprobe shows is as 1280x720 with sar SAR 3:4 and it plays as 4:3 not 16:9

25_03m30s-03m40s_sar_sample.mp4

@tatsumoto-ren

Copy link
Copy Markdown
Member

What about regular 1920x1080 videos, such as anime from nyaa.si? Have you checked that generated images are correctly scaled?

@cnra

cnra commented Jul 12, 2026

Copy link
Copy Markdown
Contributor Author

I tested it with a 1080p video using SAR 1:1, and there were no issues.

Here are the stream details for the tested video:

Stream #0:0[0x1](und): Video: hevc (Main 10) (hev1 / 0x31766568), yuv420p10le(tv, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 754 kb/s, 23.98 fps, 23.98 tbr, 24k tbn (default)
image

@tatsumoto-ren
tatsumoto-ren merged commit c32a748 into Ajatt-Tools:master Jul 13, 2026
@tatsumoto-ren

Copy link
Copy Markdown
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants